From b5d6f6c362bce8e7d4e123acd9c494bd58b939d8 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Tue, 22 Dec 2015 04:20:26 -0800 Subject: [PATCH] gdb - Local mods (compile) --- contrib/gdb-7/{gdb => }/amd64dfly-nat.c | 0 contrib/gdb-7/{gdb => }/amd64dfly-tdep.c | 0 contrib/gdb-7/gdb/amd64dfly-nat.c | 22 +- contrib/gdb-7/gdb/amd64dfly-tdep.c | 1 - contrib/gdb-7/gdb/arch-utils.c | 3 +- contrib/gdb-7/gdb/common/common-defs.h | 4 +- contrib/gdb-7/gdb/common/ptid.h | 2 +- contrib/gdb-7/gdb/defs.h | 4 + contrib/gdb-7/gdb/extension.c | 4 - contrib/gdb-7/gdb/fbsd-nat.c | 6 +- contrib/gdb-7/gdb/fbsd-nat.h | 3 + .../gdb/gnulib/import/canonicalize-lgpl.c | 1 - contrib/gdb-7/gdb/gnulib/import/malloca.h | 1 - contrib/gdb-7/gdb/inferior.c | 2 - contrib/gdb-7/gdb/main.c | 3 + contrib/gdb-7/gdb/osabi.c | 1 + contrib/gdb-7/gdb/top.c | 4 +- contrib/gdb-7/gdb/utils.c | 2 + contrib/gdb-7/i386dfly-nat.c | 223 ++++++++++++++++++ contrib/gdb-7/i386dfly-tdep.c | 103 ++++++++ gnu/usr.bin/gdb/gdb/Makefile | 3 +- gnu/usr.bin/gdb/kgdb/kgdb.c | 23 +- gnu/usr.bin/gdb/kgdb/kld.c | 2 +- gnu/usr.bin/gdb/kgdb/trgt.c | 41 ++-- gnu/usr.bin/gdb/libbfd/Makefile.x86_64 | 16 +- gnu/usr.bin/gdb/libgdb/Makefile | 40 +++- gnu/usr.bin/gdb/libgdb/Makefile.x86_64 | 2 +- gnu/usr.bin/gdb/libiberty/Makefile | 3 + 28 files changed, 436 insertions(+), 83 deletions(-) copy contrib/gdb-7/{gdb => }/amd64dfly-nat.c (100%) copy contrib/gdb-7/{gdb => }/amd64dfly-tdep.c (100%) create mode 100644 contrib/gdb-7/i386dfly-nat.c create mode 100644 contrib/gdb-7/i386dfly-tdep.c diff --git a/contrib/gdb-7/gdb/amd64dfly-nat.c b/contrib/gdb-7/amd64dfly-nat.c similarity index 100% copy from contrib/gdb-7/gdb/amd64dfly-nat.c copy to contrib/gdb-7/amd64dfly-nat.c diff --git a/contrib/gdb-7/gdb/amd64dfly-tdep.c b/contrib/gdb-7/amd64dfly-tdep.c similarity index 100% copy from contrib/gdb-7/gdb/amd64dfly-tdep.c copy to contrib/gdb-7/amd64dfly-tdep.c diff --git a/contrib/gdb-7/gdb/amd64dfly-nat.c b/contrib/gdb-7/gdb/amd64dfly-nat.c index 7ff041d661..c44f2429c1 100644 --- a/contrib/gdb-7/gdb/amd64dfly-nat.c +++ b/contrib/gdb-7/gdb/amd64dfly-nat.c @@ -36,7 +36,7 @@ #include "amd64-tdep.h" #include "amd64-nat.h" #include "amd64bsd-nat.h" -#include "i386-nat.h" +#include "x86-nat.h" /* Offset in `struct reg' where MEMBER is stored. */ @@ -209,7 +209,7 @@ amd64dfly_mourn_inferior (struct target_ops *ops) { #ifdef HAVE_PT_GETDBREGS if (!is_vkernel()) - i386_cleanup_dregs (); + x86_cleanup_dregs (); #endif super_mourn_inferior (ops); } @@ -232,14 +232,14 @@ _initialize_amd64dfly_nat (void) #ifdef HAVE_PT_GETDBREGS if (!is_vkernel()) { - i386_use_watchpoints (t); - - i386_dr_low.set_control = amd64bsd_dr_set_control; - i386_dr_low.set_addr = amd64bsd_dr_set_addr; - i386_dr_low.get_addr = amd64bsd_dr_get_addr; - i386_dr_low.get_status = amd64bsd_dr_get_status; - i386_dr_low.get_control = amd64bsd_dr_get_control; - i386_set_debug_register_length (8); + x86_use_watchpoints (t); + + x86_dr_low.set_control = amd64bsd_dr_set_control; + x86_dr_low.set_addr = amd64bsd_dr_set_addr; + x86_dr_low.get_addr = amd64bsd_dr_get_addr; + x86_dr_low.get_status = amd64bsd_dr_get_status; + x86_dr_low.get_control = amd64bsd_dr_get_control; + x86_set_debug_register_length (8); } #endif /* HAVE_PT_GETDBREGS */ @@ -249,7 +249,7 @@ _initialize_amd64dfly_nat (void) t->to_pid_to_exec_file = fbsd_pid_to_exec_file; t->to_find_memory_regions = fbsd_find_memory_regions; - t->to_make_corefile_notes = fbsd_make_corefile_notes; + //t->to_make_corefile_notes = fbsd_make_corefile_notes; add_target (t); #ifdef DFLY_PCB_SUPPLY diff --git a/contrib/gdb-7/gdb/amd64dfly-tdep.c b/contrib/gdb-7/gdb/amd64dfly-tdep.c index 1f59876f03..f3a57e88a8 100644 --- a/contrib/gdb-7/gdb/amd64dfly-tdep.c +++ b/contrib/gdb-7/gdb/amd64dfly-tdep.c @@ -25,7 +25,6 @@ #include "osabi.h" #include "gdb_assert.h" -#include "gdb_string.h" #include "amd64-tdep.h" #include "solib-svr4.h" diff --git a/contrib/gdb-7/gdb/arch-utils.c b/contrib/gdb-7/gdb/arch-utils.c index e9c622dd87..f5b7163386 100644 --- a/contrib/gdb-7/gdb/arch-utils.c +++ b/contrib/gdb-7/gdb/arch-utils.c @@ -33,11 +33,10 @@ #include "language.h" #include "symtab.h" -#include "version.h" +#include "common/version.h" #include "floatformat.h" - struct displaced_step_closure * simple_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, diff --git a/contrib/gdb-7/gdb/common/common-defs.h b/contrib/gdb-7/gdb/common/common-defs.h index 2be0d7d374..4860e27d1f 100644 --- a/contrib/gdb-7/gdb/common/common-defs.h +++ b/contrib/gdb-7/gdb/common/common-defs.h @@ -24,7 +24,7 @@ #ifdef GDBSERVER #include "build-gnulib-gdbserver/config.h" #else -#include "build-gnulib/config.h" +#include "libgnu/config.h" #endif #include @@ -34,10 +34,8 @@ #include #include #include -#include #include "ansidecl.h" #include "libiberty.h" -#include "pathmax.h" #include "gdb/signals.h" #include "gdb_locale.h" #include "ptid.h" diff --git a/contrib/gdb-7/gdb/common/ptid.h b/contrib/gdb-7/gdb/common/ptid.h index a21d2d4b08..2b9ebaedd1 100644 --- a/contrib/gdb-7/gdb/common/ptid.h +++ b/contrib/gdb-7/gdb/common/ptid.h @@ -41,7 +41,7 @@ struct ptid long lwp; /* Thread id. */ - long tid; + unsigned long tid; }; typedef struct ptid ptid_t; diff --git a/contrib/gdb-7/gdb/defs.h b/contrib/gdb-7/gdb/defs.h index 0bd8304002..448dffbd7f 100644 --- a/contrib/gdb-7/gdb/defs.h +++ b/contrib/gdb-7/gdb/defs.h @@ -25,6 +25,7 @@ # error gdbserver should not include gdb/defs.h #endif +#include "config.h" /* Generated by configure. */ #include "common-defs.h" #include @@ -676,6 +677,9 @@ extern int (*deprecated_ui_load_progress_hook) (const char *section, extern void initialize_progspace (void); extern void initialize_inferiors (void); +/* For DragonFly kgdb */ +extern int kernel_debugger; + /* * Special block numbers */ enum block_enum { diff --git a/contrib/gdb-7/gdb/extension.c b/contrib/gdb-7/gdb/extension.c index dac203b0dd..f476b8c383 100644 --- a/contrib/gdb-7/gdb/extension.c +++ b/contrib/gdb-7/gdb/extension.c @@ -29,8 +29,6 @@ #include "extension-priv.h" #include "observer.h" #include "cli/cli-script.h" -#include "python/python.h" -#include "guile/guile.h" /* Iterate over all external extension languages, regardless of whether the support has been compiled in or not. @@ -101,8 +99,6 @@ const struct extension_language_defn extension_language_gdb = static const struct extension_language_defn * const extension_languages[] = { /* To preserve existing behaviour, python should always appear first. */ - &extension_language_python, - &extension_language_guile, NULL }; diff --git a/contrib/gdb-7/gdb/fbsd-nat.c b/contrib/gdb-7/gdb/fbsd-nat.c index 9705d45a16..5754793241 100644 --- a/contrib/gdb-7/gdb/fbsd-nat.c +++ b/contrib/gdb-7/gdb/fbsd-nat.c @@ -39,7 +39,7 @@ /* Return the name of a file that can be opened to get the symbols for the child process identified by PID. */ -static char * +char * fbsd_pid_to_exec_file (struct target_ops *self, int pid) { ssize_t len = PATH_MAX; @@ -73,7 +73,7 @@ fbsd_pid_to_exec_file (struct target_ops *self, int pid) calling FUNC for each memory region. OBFD is passed as the last argument to FUNC. */ -static int +int fbsd_find_memory_regions (struct target_ops *self, find_memory_region_ftype func, void *obfd) { @@ -151,7 +151,7 @@ fbsd_read_mapping (FILE *mapfile, unsigned long *start, unsigned long *end, calling FUNC for each memory region. OBFD is passed as the last argument to FUNC. */ -static int +int fbsd_find_memory_regions (struct target_ops *self, find_memory_region_ftype func, void *obfd) { diff --git a/contrib/gdb-7/gdb/fbsd-nat.h b/contrib/gdb-7/gdb/fbsd-nat.h index 03f6bb11b8..f25a6ed0f2 100644 --- a/contrib/gdb-7/gdb/fbsd-nat.h +++ b/contrib/gdb-7/gdb/fbsd-nat.h @@ -23,5 +23,8 @@ /* Register the customized FreeBSD target. This should be used instead of calling add_target directly. */ extern void fbsd_nat_add_target (struct target_ops *); +extern char *fbsd_pid_to_exec_file (struct target_ops *, int); +extern int fbsd_find_memory_regions (struct target_ops *, + find_memory_region_ftype, void *); #endif /* fbsd-nat.h */ diff --git a/contrib/gdb-7/gdb/gnulib/import/canonicalize-lgpl.c b/contrib/gdb-7/gdb/gnulib/import/canonicalize-lgpl.c index 6d26fa6ee3..70e73a196d 100644 --- a/contrib/gdb-7/gdb/gnulib/import/canonicalize-lgpl.c +++ b/contrib/gdb-7/gdb/gnulib/import/canonicalize-lgpl.c @@ -29,7 +29,6 @@ /* Specification. */ #include -#include #include #include #include diff --git a/contrib/gdb-7/gdb/gnulib/import/malloca.h b/contrib/gdb-7/gdb/gnulib/import/malloca.h index f06e9e7b46..fea61cef03 100644 --- a/contrib/gdb-7/gdb/gnulib/import/malloca.h +++ b/contrib/gdb-7/gdb/gnulib/import/malloca.h @@ -18,7 +18,6 @@ #ifndef _MALLOCA_H #define _MALLOCA_H -#include #include #include diff --git a/contrib/gdb-7/gdb/inferior.c b/contrib/gdb-7/gdb/inferior.c index a808664d32..aed1b63c33 100644 --- a/contrib/gdb-7/gdb/inferior.c +++ b/contrib/gdb-7/gdb/inferior.c @@ -358,8 +358,6 @@ find_inferior_pid (int pid) /* Looking for inferior pid == 0 is always wrong, and indicative of a bug somewhere else. There may be more than one with pid == 0, for instance. */ - gdb_assert (kernel_debugger || pid != 0); - for (inf = inferior_list; inf; inf = inf->next) if (inf->pid == pid) return inf; diff --git a/contrib/gdb-7/gdb/main.c b/contrib/gdb-7/gdb/main.c index 5fec25c61e..891ce0996e 100644 --- a/contrib/gdb-7/gdb/main.c +++ b/contrib/gdb-7/gdb/main.c @@ -93,6 +93,9 @@ int return_child_result_value = -1; /* GDB as it has been invoked from the command line (i.e. argv[0]). */ static char *gdb_program_name; +/* DragonFly kgdb support */ +int kernel_debugger; + /* Return read only pointer to GDB_PROGRAM_NAME. */ const char * get_gdb_program_name (void) diff --git a/contrib/gdb-7/gdb/osabi.c b/contrib/gdb-7/gdb/osabi.c index 731ade850c..09978ea1cf 100644 --- a/contrib/gdb-7/gdb/osabi.c +++ b/contrib/gdb-7/gdb/osabi.c @@ -69,6 +69,7 @@ static const struct osabi_names gdb_osabi_names[] = { "NetBSD a.out", NULL }, { "NetBSD ELF", NULL }, { "OpenBSD ELF", NULL }, + { "DragonFly", NULL }, { "Windows CE", NULL }, { "DJGPP", NULL }, { "Irix", NULL }, diff --git a/contrib/gdb-7/gdb/top.c b/contrib/gdb-7/gdb/top.c index 01fddd2c95..7a002226a1 100644 --- a/contrib/gdb-7/gdb/top.c +++ b/contrib/gdb-7/gdb/top.c @@ -38,7 +38,7 @@ #include "annotate.h" #include "completer.h" #include "top.h" -#include "version.h" +#include "common/version.h" #include "serial.h" #include "doublest.h" #include "main.h" @@ -81,7 +81,7 @@ extern void initialize_all_files (void); /* Initialization file name for gdb. This is host-dependent. */ -const char gdbinit[] = GDBINIT; +const char gdbinit[] = ".gdbinit"; int inhibit_gdbinit = 0; diff --git a/contrib/gdb-7/gdb/utils.c b/contrib/gdb-7/gdb/utils.c index ffac4eea19..3032daaff9 100644 --- a/contrib/gdb-7/gdb/utils.c +++ b/contrib/gdb-7/gdb/utils.c @@ -79,6 +79,8 @@ extern PTR realloc (); /* ARI: PTR */ extern void free (); #endif +extern char *canonicalize_file_name (const char *); + void (*deprecated_error_begin_hook) (void); /* Prototypes for local functions */ diff --git a/contrib/gdb-7/i386dfly-nat.c b/contrib/gdb-7/i386dfly-nat.c new file mode 100644 index 0000000000..cd12d1d231 --- /dev/null +++ b/contrib/gdb-7/i386dfly-nat.c @@ -0,0 +1,223 @@ +/* Native-dependent code for DragonFly/i386. + + Copyright (C) 2001-2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "inferior.h" +#include "regcache.h" +#include "target.h" +#include "gregset.h" + +#include +#include +#include +#include + +#include "fbsd-nat.h" +#include "i386-tdep.h" +#include "i386-nat.h" +#include "i386bsd-nat.h" + +#ifdef DFLY_PCB_SUPPLY +/* Resume execution of the inferior process. If STEP is nonzero, + single-step it. If SIGNAL is nonzero, give it that signal. */ + +static void +i386dfly_resume (struct target_ops *ops, + ptid_t ptid, int step, enum gdb_signal signal) +{ + pid_t pid = ptid_get_pid (ptid); + int request = PT_STEP; + + if (pid == -1) + /* Resume all threads. This only gets used in the non-threaded + case, where "resume all threads" and "resume inferior_ptid" are + the same. */ + pid = ptid_get_pid (inferior_ptid); + + if (!step) + { + struct regcache *regcache = get_current_regcache (); + ULONGEST eflags; + + /* Workaround for a bug in FreeBSD. Make sure that the trace + flag is off when doing a continue. There is a code path + through the kernel which leaves the flag set when it should + have been cleared. If a process has a signal pending (such + as SIGALRM) and we do a PT_STEP, the process never really has + a chance to run because the kernel needs to notify the + debugger that a signal is being sent. Therefore, the process + never goes through the kernel's trap() function which would + normally clear it. */ + + regcache_cooked_read_unsigned (regcache, I386_EFLAGS_REGNUM, + &eflags); + if (eflags & 0x0100) + regcache_cooked_write_unsigned (regcache, I386_EFLAGS_REGNUM, + eflags & ~0x0100); + + request = PT_CONTINUE; + } + + /* An addres of (caddr_t) 1 tells ptrace to continue from where it + was. (If GDB wanted it to start some other way, we have already + written a new PC value to the child.) */ + if (ptrace (request, pid, (caddr_t) 1, + gdb_signal_to_host (signal)) == -1) + perror_with_name (("ptrace")); +} + + +/* Transfering the registers between GDB, inferiors and core files. */ + +/* Fill GDB's register array with the general-purpose register values + in *GREGSETP. */ + +void +supply_gregset (struct regcache *regcache, const gregset_t *gregsetp) +{ + i386bsd_supply_gregset (regcache, gregsetp); +} + +/* Fill register REGNUM (if it is a general-purpose register) in + *GREGSETPS with the value in GDB's register array. If REGNUM is -1, + do this for all registers. */ + +void +fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum) +{ + i386bsd_collect_gregset (regcache, gregsetp, regnum); +} + +#include "i387-tdep.h" + +/* Fill GDB's register array with the floating-point register values + in *FPREGSETP. */ + +void +supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp) +{ + i387_supply_fsave (regcache, -1, fpregsetp); +} + +/* Fill register REGNUM (if it is a floating-point register) in + *FPREGSETP with the value in GDB's register array. If REGNUM is -1, + do this for all registers. */ + +void +fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regnum) +{ + i387_collect_fsave (regcache, regnum, fpregsetp); +} + + +/* Support for debugging kernel virtual memory images. */ + +#include +#include + +#include "bsd-kvm.h" + +static int +i386dfly_supply_pcb (struct regcache *regcache, struct pcb *pcb) +{ + /* The following is true for FreeBSD 4.7: + + The pcb contains %eip, %ebx, %esp, %ebp, %esi, %edi and %gs. + This accounts for all callee-saved registers specified by the + psABI and then some. Here %esp contains the stack pointer at the + point just after the call to cpu_switch(). From this information + we reconstruct the register state as it would look when we just + returned from cpu_switch(). */ + + /* The stack pointer shouldn't be zero. */ + if (pcb->pcb_esp == 0) + return 0; + + pcb->pcb_esp += 4; + regcache_raw_supply (regcache, I386_EDI_REGNUM, &pcb->pcb_edi); + regcache_raw_supply (regcache, I386_ESI_REGNUM, &pcb->pcb_esi); + regcache_raw_supply (regcache, I386_EBP_REGNUM, &pcb->pcb_ebp); + regcache_raw_supply (regcache, I386_ESP_REGNUM, &pcb->pcb_esp); + regcache_raw_supply (regcache, I386_EBX_REGNUM, &pcb->pcb_ebx); + regcache_raw_supply (regcache, I386_EIP_REGNUM, &pcb->pcb_eip); + regcache_raw_supply (regcache, I386_GS_REGNUM, &pcb->pcb_gs); + + return 1; +} +#endif /* DFLY_PCB_SUPPLY */ + + +/* Prevent warning from -Wmissing-prototypes. */ +void _initialize_i386dfly_nat (void); + +void +_initialize_i386dfly_nat (void) +{ + struct target_ops *t; + + /* Add some extra features to the common *BSD/i386 target. */ + t = i386bsd_target (); + +#ifdef HAVE_PT_GETDBREGS + + i386_use_watchpoints (t); + + i386_dr_low.set_control = i386bsd_dr_set_control; + i386_dr_low.set_addr = i386bsd_dr_set_addr; + i386_dr_low.get_addr = i386bsd_dr_get_addr; + i386_dr_low.get_status = i386bsd_dr_get_status; + i386_dr_low.get_control = i386bsd_dr_get_control; + i386_set_debug_register_length (4); + +#endif /* HAVE_PT_GETDBREGS */ + + + t->to_pid_to_exec_file = fbsd_pid_to_exec_file; + t->to_find_memory_regions = fbsd_find_memory_regions; + t->to_make_corefile_notes = fbsd_make_corefile_notes; + add_target (t); + +#ifdef DFLY_PCB_SUPPLY + /* Support debugging kernel virtual memory images. */ + bsd_kvm_add_target (i386dfly_supply_pcb); +#endif + + /* DragonFly provides a kern.ps_strings sysctl that we can use to + locate the sigtramp. That way we can still recognize a sigtramp + if its location is changed in a new kernel. Of course this is + still based on the assumption that the sigtramp is placed + directly under the location where the program arguments and + environment can be found. */ +#ifdef KERN_PS_STRINGS + { + int mib[2]; + u_long ps_strings; + size_t len; + + mib[0] = CTL_KERN; + mib[1] = KERN_PS_STRINGS; + len = sizeof (ps_strings); + if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0) + { + i386dfly_sigtramp_start_addr = ps_strings - 128; + i386dfly_sigtramp_end_addr = ps_strings; + } + } +#endif +} diff --git a/contrib/gdb-7/i386dfly-tdep.c b/contrib/gdb-7/i386dfly-tdep.c new file mode 100644 index 0000000000..0830c60b9b --- /dev/null +++ b/contrib/gdb-7/i386dfly-tdep.c @@ -0,0 +1,103 @@ +/* Target-dependent code for DragonFly/i386. + + Copyright (C) 2003-2013 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "arch-utils.h" +#include "gdbcore.h" +#include "osabi.h" +#include "regcache.h" + +#include "gdb_assert.h" + +#include "i386-tdep.h" +#include "i387-tdep.h" +#include "solib-svr4.h" + +static int i386dfly_r_reg_offset[] = +{ + 44, /* %eax */ + 40, /* %ecx */ + 36, /* %edx */ + 32, /* %ebx */ + 72, /* %esp */ + 24, /* %ebp */ + 20, /* %esi */ + 16, /* %edi */ + 60, /* %eip */ + 68, /* %eflags */ + 64, /* %cs */ + 76, /* %ss */ + 12, /* %ds */ + 8, /* %es */ + 4, /* %fs */ + 0 /* %gs */ +}; + +/* Sigtramp routine location. */ +CORE_ADDR i386dfly_sigtramp_start_addr = 0xbfbfdf20; +CORE_ADDR i386dfly_sigtramp_end_addr = 0xbfbfdff0; + +int i386dfly_sc_reg_offset[] = +{ + 64, /* %eax */ + 60, /* %ecx */ + 56, /* %edx */ + 52, /* %ebx */ + 92, /* %esp */ + 44, /* %ebp */ + 40, /* %esi */ + 36, /* %edi */ + 80, /* %eip */ + 88, /* %eflags */ + 84, /* %cs */ + 96, /* %ss */ + 32, /* %ds */ + 28, /* %es */ + 24, /* %fs */ + 20 /* %gs */ +}; + +static void +i386dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + i386_elf_init_abi(info, gdbarch); + + tdep->gregset_reg_offset = i386dfly_r_reg_offset; + tdep->gregset_num_regs = ARRAY_SIZE (i386dfly_r_reg_offset); + tdep->sizeof_gregset = 80; + + tdep->sc_reg_offset = i386dfly_sc_reg_offset; + tdep->sc_num_regs = ARRAY_SIZE (i386dfly_sc_reg_offset); + + set_solib_svr4_fetch_link_map_offsets + (gdbarch, svr4_ilp32_fetch_link_map_offsets); +} + + +/* Provide a prototype to silence -Wmissing-prototypes. */ +void _initialize_i386dfly_tdep (void); + +void +_initialize_i386dfly_tdep (void) +{ + gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_DRAGONFLY, + i386dfly_init_abi); +} diff --git a/gnu/usr.bin/gdb/gdb/Makefile b/gnu/usr.bin/gdb/gdb/Makefile index 3b55377f58..2aa26ec25c 100644 --- a/gnu/usr.bin/gdb/gdb/Makefile +++ b/gnu/usr.bin/gdb/gdb/Makefile @@ -2,6 +2,7 @@ PROG= gdb SRCS= gdb.c MAN= gdb.1 gdbint.7 stabs.7 +CONTRIBDIR= ${BASEDIR}/gdb CFLAGS+= -I${.OBJDIR}/../libgdb -I${.CURDIR}/../libgdb -I${.CURDIR}/.. CFLAGS+= -I${BASEDIR}/include CFLAGS+= -I${BASEDIR}/bfd -I${BASEDIR}/gdb @@ -21,4 +22,4 @@ LDADD+= -lncurses -lm -lz -lkvm -llzma .include -.PATH: ${BASEDIR}/gdb +.PATH: ${BASEDIR}/gdb ${CONTRIBDIR}/doc diff --git a/gnu/usr.bin/gdb/kgdb/kgdb.c b/gnu/usr.bin/gdb/kgdb/kgdb.c index e6061f90c5..52821a76e0 100644 --- a/gnu/usr.bin/gdb/kgdb/kgdb.c +++ b/gnu/usr.bin/gdb/kgdb/kgdb.c @@ -183,31 +183,35 @@ int gdb_parse_exp_1 (const char **stringptr, struct block *block, int comma, struct expression **expression) { - volatile struct gdb_exception except; CORE_ADDR pc = 0; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { *expression = parse_exp_1 (stringptr, pc ,block, comma); } + CATCH (except, RETURN_MASK_ERROR) + { + return 0; + } + END_CATCH - if (except.reason < 0) - return 0; return 1; } int gdb_evaluate_expression (struct expression *exp, struct value **value) { - volatile struct gdb_exception except; - TRY_CATCH (except, RETURN_MASK_ERROR) + TRY { *value = evaluate_expression(exp); } + CATCH (except, RETURN_MASK_ERROR) + { + return 0; + } + END_CATCH - if (except.reason < 0) - return 0; return 1; } @@ -365,7 +369,6 @@ main(int argc, char *argv[]) quiet = 0; memset (&args, 0, sizeof args); - args.use_windows = 0; args.interpreter_p = INTERP_CONSOLE; args.argv = malloc(sizeof(char *)); args.argv[0] = argv[0]; @@ -507,7 +510,7 @@ main(int argc, char *argv[]) /* Terminate argv list. */ add_arg(&args, NULL); - deprecated_init_ui_hook = kgdb_init; + kgdb_init(NULL); return (gdb_main(&args)); } diff --git a/gnu/usr.bin/gdb/kgdb/kld.c b/gnu/usr.bin/gdb/kgdb/kld.c index c7857cb0da..3994b624b4 100644 --- a/gnu/usr.bin/gdb/kgdb/kld.c +++ b/gnu/usr.bin/gdb/kgdb/kld.c @@ -208,7 +208,7 @@ static void adjust_section_address (struct target_section *sec, CORE_ADDR *curr_base) { struct bfd_section *asect = sec->the_bfd_section; - bfd *abfd = sec->bfd; + bfd *abfd = sec->owner; if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) { sec->addr += *curr_base; diff --git a/gnu/usr.bin/gdb/kgdb/trgt.c b/gnu/usr.bin/gdb/kgdb/trgt.c index fc1f248430..7d0224dbae 100644 --- a/gnu/usr.bin/gdb/kgdb/trgt.c +++ b/gnu/usr.bin/gdb/kgdb/trgt.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -57,7 +58,7 @@ static void kgdb_core_cleanup(void *); -static char *vmcore; +static const char *vmcore; static struct target_ops kgdb_trgt_ops; kvm_t *kvm; @@ -70,21 +71,21 @@ static CORE_ADDR kgdb_kernbase (void) { static CORE_ADDR kernbase; - struct minimal_symbol *sym; + struct bound_minimal_symbol sym; if (kernbase == 0) { sym = lookup_minimal_symbol ("kernbase", NULL, NULL); - if (sym == NULL) { + if (sym.minsym == NULL) { kernbase = KERNBASE; } else { - kernbase = SYMBOL_VALUE_ADDRESS (sym); + kernbase = BMSYMBOL_VALUE_ADDRESS (sym); } } return kernbase; } static void -kgdb_trgt_open(char *filename, int from_tty) +kgdb_trgt_open(const char *filename, int from_tty) { struct cleanup *old_chain; struct kthr *kt; @@ -102,14 +103,14 @@ kgdb_trgt_open(char *filename, int from_tty) if (!exec_bfd) error ("Can't open a vmcore without a kernel"); - filename = tilde_expand (filename); + filename = tilde_expand (__DECONST(char *, filename)); if (filename[0] != '/') { temp = concat (current_directory, "/", filename, NULL); - xfree(filename); +// xfree(filename); filename = temp; } - old_chain = make_cleanup (xfree, filename); + old_chain = make_cleanup (xfree, __DECONST(char *, filename)); nkvm = kvm_openfiles(bfd_get_filename(exec_bfd), filename, NULL, write_files ? O_RDWR : O_RDONLY, kvm_err); @@ -178,11 +179,11 @@ kgdb_trgt_open(char *filename, int from_tty) kld_init(kgdbarch); reinit_frame_cache(); select_frame (get_current_frame()); - print_stack_frame(get_selected_frame(NULL), 0, SRC_AND_LOC); + print_stack_frame(get_selected_frame(NULL), 0, SRC_AND_LOC, 1); } static void -kgdb_trgt_close(int quitting) +kgdb_trgt_close(struct target_ops *self) { if (kvm != NULL) { @@ -192,7 +193,6 @@ kgdb_trgt_close(int quitting) warning("cannot close \"%s\": %s", vmcore, kvm_geterr(kvm)); kvm = NULL; - xfree(vmcore); vmcore = NULL; } } @@ -205,7 +205,7 @@ kgdb_core_cleanup(void *arg) } static void -kgdb_trgt_detach(struct target_ops *target, char *args, int from_tty) +kgdb_trgt_detach(struct target_ops *target, const char *args, int from_tty) { if (args) @@ -217,10 +217,10 @@ kgdb_trgt_detach(struct target_ops *target, char *args, int from_tty) } static char * -kgdb_trgt_extra_thread_info(struct thread_info *ti) +kgdb_trgt_extra_thread_info(struct target_ops *self, struct thread_info *arg1) { - return (kgdb_thr_extra_thread_info(ptid_get_tid(ti->ptid))); + return (kgdb_thr_extra_thread_info(ptid_get_tid(arg1->ptid))); } static void @@ -241,8 +241,8 @@ kgdb_trgt_find_new_threads(struct target_ops *target_ops) return; tb = find_target_beneath(target_ops); - if (tb->to_find_new_threads != NULL) - tb->to_find_new_threads(target_ops); + if (tb->to_update_thread_list != NULL) + tb->to_update_thread_list(target_ops); } static char * @@ -257,11 +257,11 @@ kgdb_trgt_thread_alive(struct target_ops *target_ops __unused, ptid_t ptid) return (kgdb_thr_lookup_tid(ptid_get_tid(ptid)) != NULL); } -static LONGEST +static enum target_xfer_status kgdb_trgt_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, - ULONGEST offset, LONGEST len) + ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) { if (kvm != NULL) { if (len == 0) @@ -272,7 +272,7 @@ kgdb_trgt_xfer_partial(struct target_ops *ops, enum target_object object, return (kvm_read(kvm, offset, readbuf, len)); } return (ops->beneath->to_xfer_partial(ops->beneath, object, annex, - readbuf, writebuf, offset, len)); + readbuf, writebuf, offset, len, xfered_len)); } static void @@ -351,12 +351,11 @@ initialize_kgdb_target(void) kgdb_trgt_ops.to_open = kgdb_trgt_open; kgdb_trgt_ops.to_close = kgdb_trgt_close; - kgdb_trgt_ops.to_attach = find_default_attach; kgdb_trgt_ops.to_detach = kgdb_trgt_detach; kgdb_trgt_ops.to_extra_thread_info = kgdb_trgt_extra_thread_info; kgdb_trgt_ops.to_fetch_registers = kgdb_trgt_fetch_registers; kgdb_trgt_ops.to_files_info = kgdb_trgt_files_info; - kgdb_trgt_ops.to_find_new_threads = kgdb_trgt_find_new_threads; + kgdb_trgt_ops.to_update_thread_list = kgdb_trgt_find_new_threads; kgdb_trgt_ops.to_pid_to_str = kgdb_trgt_pid_to_str; /* kgdb_trgt_ops.to_store_registers = NULL; diff --git a/gnu/usr.bin/gdb/libbfd/Makefile.x86_64 b/gnu/usr.bin/gdb/libbfd/Makefile.x86_64 index 0116283f5d..68d1a43f8d 100644 --- a/gnu/usr.bin/gdb/libbfd/Makefile.x86_64 +++ b/gnu/usr.bin/gdb/libbfd/Makefile.x86_64 @@ -7,15 +7,15 @@ SRCS+= cpu-i386.c cpu-l1om.c # BFD64_LIBS SRCS+= archive64.c -VECTORS= bfd_elf64_x86_64_vec \ - bfd_elf32_i386_vec \ - bfd_elf64_l1om_vec \ - bfd_elf64_little_generic_vec \ - bfd_elf64_big_generic_vec \ - bfd_elf32_little_generic_vec \ - bfd_elf32_big_generic_vec +VECTORS= x86_64_elf64_vec \ + i386_elf32_vec \ + l1om_elf64_vec \ + elf64_le_vec \ + elf64_be_vec \ + elf32_le_vec \ + elf32_be_vec -DEFAULT_VECTOR= bfd_elf64_x86_64_vec +DEFAULT_VECTOR= x86_64_elf64_vec ARCHITECTURES= bfd_i386_arch bfd_l1om_arch diff --git a/gnu/usr.bin/gdb/libgdb/Makefile b/gnu/usr.bin/gdb/libgdb/Makefile index cd51583833..1d804e7c56 100644 --- a/gnu/usr.bin/gdb/libgdb/Makefile +++ b/gnu/usr.bin/gdb/libgdb/Makefile @@ -7,8 +7,9 @@ INTERNALLIB= yes CONTRIBDIR= ${BASEDIR}/gdb .PATH: ${CONTRIBDIR} ${CONTRIBDIR}/cli ${CONTRIBDIR}/mi -.PATH: ${CONTRIBDIR}/common ${CONTRIBDIR}/python ${CONTRIBDIR}/features -.PATH: ${CONTRIBDIR}/tui +.PATH: ${CONTRIBDIR}/common ${CONTRIBDIR}/nat ${CONTRIBDIR}/features +.PATH: ${CONTRIBDIR}/tui ${CONTRIBDIR}/target ${CONTRIBDIR}/gnulib/import +.PATH: ${CONTRIBDIR}/compile VERSION!= cat ${CONTRIBDIR}/version.in @@ -16,8 +17,9 @@ CFLAGS+= -I${.OBJDIR} -I${.CURDIR} -I${.CURDIR}/.. CFLAGS+= -I${BASEDIR}/include -I${BASEDIR}/bfd CFLAGS+= -I${CONTRIBDIR} -I${CONTRIBDIR}/common CFLAGS+= -I${BASEDIR}/libdecnumber +CFLAGS+= -I${BASEDIR}/import CFLAGS+= -I${.CURDIR}/../libbfd -I${.OBJDIR}/../libbfd -CFLAGS+= -I${BASEDIR} +CFLAGS+= -I${BASEDIR} CFLAGS+= -DMACHINE_ARCH='"${MACHINE_ARCH}"' CFLAGS+= -DTARGET_ARCH='"${TARGET_ARCH}"' CFLAGS+= -DVERSION_STRING='"${VERSION}"' @@ -85,7 +87,7 @@ SRCS+= \ inline-frame.c \ gnu-v2-abi.c gnu-v3-abi.c cp-abi.c cp-support.c \ cp-namespace.c \ - reggroups.c regset.c \ + reggroups.c \ trad-frame.c \ tramp-frame.c \ solib.c solib-target.c \ @@ -95,7 +97,11 @@ SRCS+= \ inferior.c osdata.c gdb_usleep.c record.c record-full.c gcore.c \ gdb_vecs.c jit.c progspace.c skip.c probe.c \ common-utils.c buffer.c ptid.c gdb-dlfcn.c common-agent.c \ - format.c registry.c btrace.c record-btrace.c + format.c registry.c btrace.c btrace-common.c record-btrace.c utils.c \ + errors.c common-exceptions.c filestuff.c extension.c print-utils.c \ + posix-strerror.c break-catch-syscall.c rsp-low.c target-dcache.c \ + symfile-debug.c debug.c c-varobj.c jv-varobj.c build-id.c tracefile.c \ + ctf.c tracefile-tfile.c fileio.c common-debug.c # TSOBS SRCS+= inflow.c @@ -121,11 +127,24 @@ SRCS+= mi-out.c mi-console.c \ mi-cmd-target.c mi-cmd-info.c mi-interp.c \ mi-main.c mi-parse.c mi-getopt.c -# PYTHON OBJS -SRCS+= python.c \ - py-auto-load.c \ - py-value.c \ - py-prettyprint.c +# SUBDIR_NAT_OBS +SRCS+= x86-dregs.c + +# SUBDIR_TARGET_OBS +SRCS+= waitstatus.c + +# SUBDIR_IMPORT_OBS +SRCS+= canonicalize-lgpl.c malloca.c + +# SUBDIR_COMPILE_OBS +SRCS+= compile.c compile-c-support.c \ + compile-c-types.c compile-c-symbols.c \ + compile-loc2c.c + +#SRCS+= python.c \ +# py-auto-load.c \ +# py-value.c \ +# py-prettyprint.c # CONFIG_OBS SRCS+= elfread.c posix-hdep.c stap-probe.c @@ -151,6 +170,7 @@ SRCS+= tui-command.c \ # YYOBJ SRCS+= c-exp.y \ + d-exp.y \ cp-name-parser.y \ ada-exp.y \ jv-exp.y \ diff --git a/gnu/usr.bin/gdb/libgdb/Makefile.x86_64 b/gnu/usr.bin/gdb/libgdb/Makefile.x86_64 index 26d7196a0a..30a9794a34 100644 --- a/gnu/usr.bin/gdb/libgdb/Makefile.x86_64 +++ b/gnu/usr.bin/gdb/libgdb/Makefile.x86_64 @@ -6,5 +6,5 @@ SRCS+= amd64-tdep.c amd64dfly-tdep.c i386-tdep.c i387-tdep.c i386bsd-tdep.c \ # NATDEPFILES SRCS+= fork-child.c inf-ptrace.c \ fbsd-nat.c amd64-nat.c amd64bsd-nat.c amd64dfly-nat.c \ - i386-nat.c gcore.c + x86-nat.c gcore.c fbsd-tdep.c .endif diff --git a/gnu/usr.bin/gdb/libiberty/Makefile b/gnu/usr.bin/gdb/libiberty/Makefile index c7437374c0..9dc17ef5f1 100644 --- a/gnu/usr.bin/gdb/libiberty/Makefile +++ b/gnu/usr.bin/gdb/libiberty/Makefile @@ -13,6 +13,8 @@ SRCS+= ./argv.c \ ./cp-demint.c \ ./cplus-dem.c \ ./concat.c \ + ./d-demangle.c \ + ./crc32.c \ ./dwarfnames.c \ ./dyn-string.c \ ./filename_cmp.c \ @@ -40,6 +42,7 @@ SRCS+= ./argv.c \ ./unlink-if-ordinary.c \ ./xexit.c \ ./xstrdup.c \ + ./xstrndup.c \ ./xstrerror.c .include -- 2.41.0