1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/gdb/6.3/650-debian_vsyscall-gdb-support.patch Tue May 22 20:36:05 2007 +0000
1.3 @@ -0,0 +1,245 @@
1.4 +Status: Checked in to HEAD after 6.3.
1.5 +
1.6 +2004-11-07 Andrew Cagney <cagney@redhat.com>
1.7 + Daniel Jacobowitz <dan@debian.org>
1.8 + Roland McGrath <roland@redhat.com>
1.9 +
1.10 + * Makefile.in (symfile-mem.o): Update dependencies.
1.11 + * i386-linux-tdep.c (i386_linux_dwarf_signal_frame_p): New.
1.12 + (i386_linux_init_abi): Call dwarf2_frame_set_signal_frame_p.
1.13 + * inf-ptrace.c (inf_ptrace_attach): Call
1.14 + observer_notify_inferior_created.
1.15 + * inftarg.c (child_attach): Likewise.
1.16 + * symfile-mem.c: Include "observer.h", "auxv.h", and "elf/common.h".
1.17 + (symbol_file_add_from_memory): Take NAME argument. Use it for
1.18 + the new BFD's filename.
1.19 + (add_symbol_file_from_memory_command): Update call to
1.20 + symbol_file_add_from_memory.
1.21 + (struct symbol_file_add_from_memory_args, add_vsyscall_page)
1.22 + (symbol_file_add_from_memory_wrapper): New.
1.23 + (_initialize_symfile_mem): Register add_vsyscall_page as an
1.24 + inferior_created observer.
1.25 +
1.26 +Index: gdb-6.3/gdb/i386-linux-tdep.c
1.27 +===================================================================
1.28 +--- gdb-6.3.orig/gdb/i386-linux-tdep.c 2004-08-06 16:58:28.000000000 -0400
1.29 ++++ gdb-6.3/gdb/i386-linux-tdep.c 2004-11-10 00:55:06.669398770 -0500
1.30 +@@ -27,6 +27,7 @@
1.31 + #include "inferior.h"
1.32 + #include "osabi.h"
1.33 + #include "reggroups.h"
1.34 ++#include "dwarf2-frame.h"
1.35 +
1.36 + #include "gdb_string.h"
1.37 +
1.38 +@@ -244,6 +245,27 @@ i386_linux_sigtramp_p (struct frame_info
1.39 + || strcmp ("__restore_rt", name) == 0);
1.40 + }
1.41 +
1.42 ++/* Return one if the unwound PC from NEXT_FRAME is in a signal trampoline
1.43 ++ which may have DWARF-2 CFI. */
1.44 ++
1.45 ++static int
1.46 ++i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
1.47 ++ struct frame_info *next_frame)
1.48 ++{
1.49 ++ CORE_ADDR pc = frame_pc_unwind (next_frame);
1.50 ++ char *name;
1.51 ++
1.52 ++ find_pc_partial_function (pc, &name, NULL, NULL);
1.53 ++
1.54 ++ /* If a vsyscall DSO is in use, the signal trampolines may have these
1.55 ++ names. */
1.56 ++ if (name && (strcmp (name, "__kernel_sigreturn") == 0
1.57 ++ || strcmp (name, "__kernel_rt_sigreturn") == 0))
1.58 ++ return 1;
1.59 ++
1.60 ++ return 0;
1.61 ++}
1.62 ++
1.63 + /* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
1.64 + #define I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 20
1.65 +
1.66 +@@ -414,6 +436,8 @@ i386_linux_init_abi (struct gdbarch_info
1.67 +
1.68 + /* GNU/Linux uses the dynamic linker included in the GNU C Library. */
1.69 + set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
1.70 ++
1.71 ++ dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p);
1.72 + }
1.73 +
1.74 + /* Provide a prototype to silence -Wmissing-prototypes. */
1.75 +Index: gdb-6.3/gdb/inf-ptrace.c
1.76 +===================================================================
1.77 +--- gdb-6.3.orig/gdb/inf-ptrace.c 2004-10-15 09:29:33.000000000 -0400
1.78 ++++ gdb-6.3/gdb/inf-ptrace.c 2004-11-10 00:53:43.697615843 -0500
1.79 +@@ -220,6 +220,10 @@ inf_ptrace_attach (char *args, int from_
1.80 +
1.81 + inferior_ptid = pid_to_ptid (pid);
1.82 + push_target (ptrace_ops_hack);
1.83 ++
1.84 ++ /* Do this first, before anything has had a chance to query the
1.85 ++ inferior's symbol table or similar. */
1.86 ++ observer_notify_inferior_created (¤t_target, from_tty);
1.87 + }
1.88 +
1.89 + static void
1.90 +Index: gdb-6.3/gdb/inftarg.c
1.91 +===================================================================
1.92 +--- gdb-6.3.orig/gdb/inftarg.c 2004-10-08 16:29:47.000000000 -0400
1.93 ++++ gdb-6.3/gdb/inftarg.c 2004-11-10 00:53:43.711613107 -0500
1.94 +@@ -211,6 +211,10 @@ child_attach (char *args, int from_tty)
1.95 +
1.96 + inferior_ptid = pid_to_ptid (pid);
1.97 + push_target (&deprecated_child_ops);
1.98 ++
1.99 ++ /* Do this first, before anything has had a chance to query the
1.100 ++ inferior's symbol table or similar. */
1.101 ++ observer_notify_inferior_created (¤t_target, from_tty);
1.102 + }
1.103 +
1.104 + #if !defined(CHILD_POST_ATTACH)
1.105 +Index: gdb-6.3/gdb/symfile-mem.c
1.106 +===================================================================
1.107 +--- gdb-6.3.orig/gdb/symfile-mem.c 2004-07-17 10:24:07.000000000 -0400
1.108 ++++ gdb-6.3/gdb/symfile-mem.c 2004-11-10 00:53:43.722610958 -0500
1.109 +@@ -52,13 +52,19 @@
1.110 + #include "target.h"
1.111 + #include "value.h"
1.112 + #include "symfile.h"
1.113 ++#include "observer.h"
1.114 ++#include "auxv.h"
1.115 ++#include "elf/common.h"
1.116 +
1.117 +
1.118 + /* Read inferior memory at ADDR to find the header of a loaded object file
1.119 + and read its in-core symbols out of inferior memory. TEMPL is a bfd
1.120 +- representing the target's format. */
1.121 ++ representing the target's format. NAME is the name to use for this
1.122 ++ symbol file in messages; it can be NULL or a malloc-allocated string
1.123 ++ which will be attached to the BFD. */
1.124 + static struct objfile *
1.125 +-symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, int from_tty)
1.126 ++symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
1.127 ++ int from_tty)
1.128 + {
1.129 + struct objfile *objf;
1.130 + struct bfd *nbfd;
1.131 +@@ -75,7 +81,10 @@ symbol_file_add_from_memory (struct bfd
1.132 + if (nbfd == NULL)
1.133 + error ("Failed to read a valid object file image from memory.");
1.134 +
1.135 +- nbfd->filename = xstrdup ("shared object read from target memory");
1.136 ++ if (name == NULL)
1.137 ++ nbfd->filename = xstrdup ("shared object read from target memory");
1.138 ++ else
1.139 ++ nbfd->filename = name;
1.140 +
1.141 + if (!bfd_check_format (nbfd, bfd_object))
1.142 + {
1.143 +@@ -129,7 +138,73 @@ add_symbol_file_from_memory_command (cha
1.144 + error ("\
1.145 + Must use symbol-file or exec-file before add-symbol-file-from-memory.");
1.146 +
1.147 +- symbol_file_add_from_memory (templ, addr, from_tty);
1.148 ++ symbol_file_add_from_memory (templ, addr, NULL, from_tty);
1.149 ++}
1.150 ++
1.151 ++/* Arguments for symbol_file_add_from_memory_wrapper. */
1.152 ++
1.153 ++struct symbol_file_add_from_memory_args
1.154 ++{
1.155 ++ struct bfd *bfd;
1.156 ++ CORE_ADDR sysinfo_ehdr;
1.157 ++ char *name;
1.158 ++ int from_tty;
1.159 ++};
1.160 ++
1.161 ++/* Wrapper function for symbol_file_add_from_memory, for
1.162 ++ catch_exceptions. */
1.163 ++
1.164 ++static int
1.165 ++symbol_file_add_from_memory_wrapper (struct ui_out *uiout, void *data)
1.166 ++{
1.167 ++ struct symbol_file_add_from_memory_args *args = data;
1.168 ++
1.169 ++ symbol_file_add_from_memory (args->bfd, args->sysinfo_ehdr, args->name,
1.170 ++ args->from_tty);
1.171 ++ return 0;
1.172 ++}
1.173 ++
1.174 ++/* Try to add the symbols for the vsyscall page, if there is one. This function
1.175 ++ is called via the inferior_created observer. */
1.176 ++
1.177 ++static void
1.178 ++add_vsyscall_page (struct target_ops *target, int from_tty)
1.179 ++{
1.180 ++ CORE_ADDR sysinfo_ehdr;
1.181 ++
1.182 ++ if (target_auxv_search (target, AT_SYSINFO_EHDR, &sysinfo_ehdr) > 0
1.183 ++ && sysinfo_ehdr != (CORE_ADDR) 0)
1.184 ++ {
1.185 ++ struct bfd *bfd;
1.186 ++ struct symbol_file_add_from_memory_args args;
1.187 ++
1.188 ++ if (core_bfd != NULL)
1.189 ++ bfd = core_bfd;
1.190 ++ else if (exec_bfd != NULL)
1.191 ++ bfd = exec_bfd;
1.192 ++ else
1.193 ++ /* FIXME: cagney/2004-05-06: Should not require an existing
1.194 ++ BFD when trying to create a run-time BFD of the VSYSCALL
1.195 ++ page in the inferior. Unfortunately that's the current
1.196 ++ interface so for the moment bail. Introducing a
1.197 ++ ``bfd_runtime'' (a BFD created using the loaded image) file
1.198 ++ format should fix this. */
1.199 ++ {
1.200 ++ warning ("could not load vsyscall page because no executable was specified");
1.201 ++ warning ("try using the \"file\" command first");
1.202 ++ return;
1.203 ++ }
1.204 ++ args.bfd = bfd;
1.205 ++ args.sysinfo_ehdr = sysinfo_ehdr;
1.206 ++ xasprintf (&args.name, "system-supplied DSO at 0x%s",
1.207 ++ paddr_nz (sysinfo_ehdr));
1.208 ++ /* Pass zero for FROM_TTY, because the action of loading the
1.209 ++ vsyscall DSO was not triggered by the user, even if the user
1.210 ++ typed "run" at the TTY. */
1.211 ++ args.from_tty = 0;
1.212 ++ catch_exceptions (uiout, symbol_file_add_from_memory_wrapper,
1.213 ++ &args, NULL, RETURN_MASK_ALL);
1.214 ++ }
1.215 + }
1.216 +
1.217 +
1.218 +@@ -143,4 +218,7 @@ Load the symbols out of memory from a dy
1.219 + Give an expression for the address of the file's shared object file header.",
1.220 + &cmdlist);
1.221 +
1.222 ++ /* Want to know of each new inferior so that its vsyscall info can
1.223 ++ be extracted. */
1.224 ++ observer_attach_inferior_created (add_vsyscall_page);
1.225 + }
1.226 +Index: gdb-6.3/gdb/Makefile.in
1.227 +===================================================================
1.228 +--- gdb-6.3.orig/gdb/Makefile.in 2004-11-10 00:29:00.000000000 -0500
1.229 ++++ gdb-6.3/gdb/Makefile.in 2004-11-10 00:54:47.728100986 -0500
1.230 +@@ -2020,7 +2020,7 @@ i386-linux-nat.o: i386-linux-nat.c $(def
1.231 + i386-linux-tdep.o: i386-linux-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
1.232 + $(value_h) $(regcache_h) $(inferior_h) $(osabi_h) $(reggroups_h) \
1.233 + $(gdb_string_h) $(i386_tdep_h) $(i386_linux_tdep_h) $(glibc_tdep_h) \
1.234 +- $(solib_svr4_h)
1.235 ++ $(solib_svr4_h) $(dwarf2_frame_h)
1.236 + i386ly-tdep.o: i386ly-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
1.237 + $(regcache_h) $(target_h) $(osabi_h) $(i386_tdep_h)
1.238 + i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h)
1.239 +@@ -2606,7 +2606,8 @@ symfile.o: symfile.c $(defs_h) $(bfdlink
1.240 + $(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \
1.241 + $(gdb_string_h) $(gdb_stat_h)
1.242 + symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \
1.243 +- $(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h)
1.244 ++ $(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h) \
1.245 ++ $(observer_h) $(auxv_h) $(elf_common_h)
1.246 + symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \
1.247 + $(symfile_h) $(objfiles_h) $(breakpoint_h) $(command_h) \
1.248 + $(gdb_obstack_h) $(language_h) $(bcache_h) $(block_h) $(gdb_regex_h) \