650-debian_vsyscall-gdb-support.patch 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. Status: Checked in to HEAD after 6.3.
  2. 2004-11-07 Andrew Cagney <cagney@redhat.com>
  3. Daniel Jacobowitz <dan@debian.org>
  4. Roland McGrath <roland@redhat.com>
  5. * Makefile.in (symfile-mem.o): Update dependencies.
  6. * i386-linux-tdep.c (i386_linux_dwarf_signal_frame_p): New.
  7. (i386_linux_init_abi): Call dwarf2_frame_set_signal_frame_p.
  8. * inf-ptrace.c (inf_ptrace_attach): Call
  9. observer_notify_inferior_created.
  10. * inftarg.c (child_attach): Likewise.
  11. * symfile-mem.c: Include "observer.h", "auxv.h", and "elf/common.h".
  12. (symbol_file_add_from_memory): Take NAME argument. Use it for
  13. the new BFD's filename.
  14. (add_symbol_file_from_memory_command): Update call to
  15. symbol_file_add_from_memory.
  16. (struct symbol_file_add_from_memory_args, add_vsyscall_page)
  17. (symbol_file_add_from_memory_wrapper): New.
  18. (_initialize_symfile_mem): Register add_vsyscall_page as an
  19. inferior_created observer.
  20. Index: gdb-6.3/gdb/i386-linux-tdep.c
  21. ===================================================================
  22. --- gdb-6.3.orig/gdb/i386-linux-tdep.c 2004-08-06 16:58:28.000000000 -0400
  23. +++ gdb-6.3/gdb/i386-linux-tdep.c 2004-11-10 00:55:06.669398770 -0500
  24. @@ -27,6 +27,7 @@
  25. #include "inferior.h"
  26. #include "osabi.h"
  27. #include "reggroups.h"
  28. +#include "dwarf2-frame.h"
  29. #include "gdb_string.h"
  30. @@ -244,6 +245,27 @@ i386_linux_sigtramp_p (struct frame_info
  31. || strcmp ("__restore_rt", name) == 0);
  32. }
  33. +/* Return one if the unwound PC from NEXT_FRAME is in a signal trampoline
  34. + which may have DWARF-2 CFI. */
  35. +
  36. +static int
  37. +i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
  38. + struct frame_info *next_frame)
  39. +{
  40. + CORE_ADDR pc = frame_pc_unwind (next_frame);
  41. + char *name;
  42. +
  43. + find_pc_partial_function (pc, &name, NULL, NULL);
  44. +
  45. + /* If a vsyscall DSO is in use, the signal trampolines may have these
  46. + names. */
  47. + if (name && (strcmp (name, "__kernel_sigreturn") == 0
  48. + || strcmp (name, "__kernel_rt_sigreturn") == 0))
  49. + return 1;
  50. +
  51. + return 0;
  52. +}
  53. +
  54. /* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>. */
  55. #define I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 20
  56. @@ -414,6 +436,8 @@ i386_linux_init_abi (struct gdbarch_info
  57. /* GNU/Linux uses the dynamic linker included in the GNU C Library. */
  58. set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
  59. +
  60. + dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p);
  61. }
  62. /* Provide a prototype to silence -Wmissing-prototypes. */
  63. Index: gdb-6.3/gdb/inf-ptrace.c
  64. ===================================================================
  65. --- gdb-6.3.orig/gdb/inf-ptrace.c 2004-10-15 09:29:33.000000000 -0400
  66. +++ gdb-6.3/gdb/inf-ptrace.c 2004-11-10 00:53:43.697615843 -0500
  67. @@ -220,6 +220,10 @@ inf_ptrace_attach (char *args, int from_
  68. inferior_ptid = pid_to_ptid (pid);
  69. push_target (ptrace_ops_hack);
  70. +
  71. + /* Do this first, before anything has had a chance to query the
  72. + inferior's symbol table or similar. */
  73. + observer_notify_inferior_created (&current_target, from_tty);
  74. }
  75. static void
  76. Index: gdb-6.3/gdb/inftarg.c
  77. ===================================================================
  78. --- gdb-6.3.orig/gdb/inftarg.c 2004-10-08 16:29:47.000000000 -0400
  79. +++ gdb-6.3/gdb/inftarg.c 2004-11-10 00:53:43.711613107 -0500
  80. @@ -211,6 +211,10 @@ child_attach (char *args, int from_tty)
  81. inferior_ptid = pid_to_ptid (pid);
  82. push_target (&deprecated_child_ops);
  83. +
  84. + /* Do this first, before anything has had a chance to query the
  85. + inferior's symbol table or similar. */
  86. + observer_notify_inferior_created (&current_target, from_tty);
  87. }
  88. #if !defined(CHILD_POST_ATTACH)
  89. Index: gdb-6.3/gdb/symfile-mem.c
  90. ===================================================================
  91. --- gdb-6.3.orig/gdb/symfile-mem.c 2004-07-17 10:24:07.000000000 -0400
  92. +++ gdb-6.3/gdb/symfile-mem.c 2004-11-10 00:53:43.722610958 -0500
  93. @@ -52,13 +52,19 @@
  94. #include "target.h"
  95. #include "value.h"
  96. #include "symfile.h"
  97. +#include "observer.h"
  98. +#include "auxv.h"
  99. +#include "elf/common.h"
  100. /* Read inferior memory at ADDR to find the header of a loaded object file
  101. and read its in-core symbols out of inferior memory. TEMPL is a bfd
  102. - representing the target's format. */
  103. + representing the target's format. NAME is the name to use for this
  104. + symbol file in messages; it can be NULL or a malloc-allocated string
  105. + which will be attached to the BFD. */
  106. static struct objfile *
  107. -symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, int from_tty)
  108. +symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
  109. + int from_tty)
  110. {
  111. struct objfile *objf;
  112. struct bfd *nbfd;
  113. @@ -75,7 +81,10 @@ symbol_file_add_from_memory (struct bfd
  114. if (nbfd == NULL)
  115. error ("Failed to read a valid object file image from memory.");
  116. - nbfd->filename = xstrdup ("shared object read from target memory");
  117. + if (name == NULL)
  118. + nbfd->filename = xstrdup ("shared object read from target memory");
  119. + else
  120. + nbfd->filename = name;
  121. if (!bfd_check_format (nbfd, bfd_object))
  122. {
  123. @@ -129,7 +138,73 @@ add_symbol_file_from_memory_command (cha
  124. error ("\
  125. Must use symbol-file or exec-file before add-symbol-file-from-memory.");
  126. - symbol_file_add_from_memory (templ, addr, from_tty);
  127. + symbol_file_add_from_memory (templ, addr, NULL, from_tty);
  128. +}
  129. +
  130. +/* Arguments for symbol_file_add_from_memory_wrapper. */
  131. +
  132. +struct symbol_file_add_from_memory_args
  133. +{
  134. + struct bfd *bfd;
  135. + CORE_ADDR sysinfo_ehdr;
  136. + char *name;
  137. + int from_tty;
  138. +};
  139. +
  140. +/* Wrapper function for symbol_file_add_from_memory, for
  141. + catch_exceptions. */
  142. +
  143. +static int
  144. +symbol_file_add_from_memory_wrapper (struct ui_out *uiout, void *data)
  145. +{
  146. + struct symbol_file_add_from_memory_args *args = data;
  147. +
  148. + symbol_file_add_from_memory (args->bfd, args->sysinfo_ehdr, args->name,
  149. + args->from_tty);
  150. + return 0;
  151. +}
  152. +
  153. +/* Try to add the symbols for the vsyscall page, if there is one. This function
  154. + is called via the inferior_created observer. */
  155. +
  156. +static void
  157. +add_vsyscall_page (struct target_ops *target, int from_tty)
  158. +{
  159. + CORE_ADDR sysinfo_ehdr;
  160. +
  161. + if (target_auxv_search (target, AT_SYSINFO_EHDR, &sysinfo_ehdr) > 0
  162. + && sysinfo_ehdr != (CORE_ADDR) 0)
  163. + {
  164. + struct bfd *bfd;
  165. + struct symbol_file_add_from_memory_args args;
  166. +
  167. + if (core_bfd != NULL)
  168. + bfd = core_bfd;
  169. + else if (exec_bfd != NULL)
  170. + bfd = exec_bfd;
  171. + else
  172. + /* FIXME: cagney/2004-05-06: Should not require an existing
  173. + BFD when trying to create a run-time BFD of the VSYSCALL
  174. + page in the inferior. Unfortunately that's the current
  175. + interface so for the moment bail. Introducing a
  176. + ``bfd_runtime'' (a BFD created using the loaded image) file
  177. + format should fix this. */
  178. + {
  179. + warning ("could not load vsyscall page because no executable was specified");
  180. + warning ("try using the \"file\" command first");
  181. + return;
  182. + }
  183. + args.bfd = bfd;
  184. + args.sysinfo_ehdr = sysinfo_ehdr;
  185. + xasprintf (&args.name, "system-supplied DSO at 0x%s",
  186. + paddr_nz (sysinfo_ehdr));
  187. + /* Pass zero for FROM_TTY, because the action of loading the
  188. + vsyscall DSO was not triggered by the user, even if the user
  189. + typed "run" at the TTY. */
  190. + args.from_tty = 0;
  191. + catch_exceptions (uiout, symbol_file_add_from_memory_wrapper,
  192. + &args, NULL, RETURN_MASK_ALL);
  193. + }
  194. }
  195. @@ -143,4 +218,7 @@ Load the symbols out of memory from a dy
  196. Give an expression for the address of the file's shared object file header.",
  197. &cmdlist);
  198. + /* Want to know of each new inferior so that its vsyscall info can
  199. + be extracted. */
  200. + observer_attach_inferior_created (add_vsyscall_page);
  201. }
  202. Index: gdb-6.3/gdb/Makefile.in
  203. ===================================================================
  204. --- gdb-6.3.orig/gdb/Makefile.in 2004-11-10 00:29:00.000000000 -0500
  205. +++ gdb-6.3/gdb/Makefile.in 2004-11-10 00:54:47.728100986 -0500
  206. @@ -2020,7 +2020,7 @@ i386-linux-nat.o: i386-linux-nat.c $(def
  207. i386-linux-tdep.o: i386-linux-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
  208. $(value_h) $(regcache_h) $(inferior_h) $(osabi_h) $(reggroups_h) \
  209. $(gdb_string_h) $(i386_tdep_h) $(i386_linux_tdep_h) $(glibc_tdep_h) \
  210. - $(solib_svr4_h)
  211. + $(solib_svr4_h) $(dwarf2_frame_h)
  212. i386ly-tdep.o: i386ly-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
  213. $(regcache_h) $(target_h) $(osabi_h) $(i386_tdep_h)
  214. i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h)
  215. @@ -2606,7 +2606,8 @@ symfile.o: symfile.c $(defs_h) $(bfdlink
  216. $(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \
  217. $(gdb_string_h) $(gdb_stat_h)
  218. symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \
  219. - $(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h)
  220. + $(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h) \
  221. + $(observer_h) $(auxv_h) $(elf_common_h)
  222. symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \
  223. $(symfile_h) $(objfiles_h) $(breakpoint_h) $(command_h) \
  224. $(gdb_obstack_h) $(language_h) $(bcache_h) $(block_h) $(gdb_regex_h) \