summaryrefslogtreecommitdiffstats
path: root/openwrt/toolchain/gdb/patches/650-debian_vsyscall-gdb-support.patch
blob: e725f9c549c216b5c0c3ad2372a239aa685cc177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
Status: Checked in to HEAD after 6.3.

2004-11-07  Andrew Cagney  <cagney@redhat.com>
	    Daniel Jacobowitz  <dan@debian.org>
	    Roland McGrath  <roland@redhat.com>

	* Makefile.in (symfile-mem.o): Update dependencies.
	* i386-linux-tdep.c (i386_linux_dwarf_signal_frame_p): New.
	(i386_linux_init_abi): Call dwarf2_frame_set_signal_frame_p.
	* inf-ptrace.c (inf_ptrace_attach): Call
	observer_notify_inferior_created.
	* inftarg.c (child_attach): Likewise.
	* symfile-mem.c: Include "observer.h", "auxv.h", and "elf/common.h".
	(symbol_file_add_from_memory): Take NAME argument.  Use it for
	the new BFD's filename.
	(add_symbol_file_from_memory_command): Update call to
	symbol_file_add_from_memory.
	(struct symbol_file_add_from_memory_args, add_vsyscall_page)
	(symbol_file_add_from_memory_wrapper): New.
	(_initialize_symfile_mem): Register add_vsyscall_page as an
	inferior_created observer.

Index: gdb-6.3/gdb/i386-linux-tdep.c
===================================================================
--- gdb-6.3.orig/gdb/i386-linux-tdep.c	2004-08-06 16:58:28.000000000 -0400
+++ gdb-6.3/gdb/i386-linux-tdep.c	2004-11-10 00:55:06.669398770 -0500
@@ -27,6 +27,7 @@
 #include "inferior.h"
 #include "osabi.h"
 #include "reggroups.h"
+#include "dwarf2-frame.h"
 
 #include "gdb_string.h"
 
@@ -244,6 +245,27 @@ i386_linux_sigtramp_p (struct frame_info
 	  || strcmp ("__restore_rt", name) == 0);
 }
 
+/* Return one if the unwound PC from NEXT_FRAME is in a signal trampoline
+   which may have DWARF-2 CFI.  */
+
+static int
+i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
+				 struct frame_info *next_frame)
+{
+  CORE_ADDR pc = frame_pc_unwind (next_frame);
+  char *name;
+
+  find_pc_partial_function (pc, &name, NULL, NULL);
+
+  /* If a vsyscall DSO is in use, the signal trampolines may have these
+     names.  */
+  if (name && (strcmp (name, "__kernel_sigreturn") == 0
+	       || strcmp (name, "__kernel_rt_sigreturn") == 0))
+    return 1;
+
+  return 0;
+}
+
 /* Offset to struct sigcontext in ucontext, from <asm/ucontext.h>.  */
 #define I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET 20
 
@@ -414,6 +436,8 @@ i386_linux_init_abi (struct gdbarch_info
 
   /* GNU/Linux uses the dynamic linker included in the GNU C Library.  */
   set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
+
+  dwarf2_frame_set_signal_frame_p (gdbarch, i386_linux_dwarf_signal_frame_p);
 }
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
Index: gdb-6.3/gdb/inf-ptrace.c
===================================================================
--- gdb-6.3.orig/gdb/inf-ptrace.c	2004-10-15 09:29:33.000000000 -0400
+++ gdb-6.3/gdb/inf-ptrace.c	2004-11-10 00:53:43.697615843 -0500
@@ -220,6 +220,10 @@ inf_ptrace_attach (char *args, int from_
 
   inferior_ptid = pid_to_ptid (pid);
   push_target (ptrace_ops_hack);
+
+  /* Do this first, before anything has had a chance to query the
+     inferior's symbol table or similar.  */
+  observer_notify_inferior_created (&current_target, from_tty);
 }
 
 static void
Index: gdb-6.3/gdb/inftarg.c
===================================================================
--- gdb-6.3.orig/gdb/inftarg.c	2004-10-08 16:29:47.000000000 -0400
+++ gdb-6.3/gdb/inftarg.c	2004-11-10 00:53:43.711613107 -0500
@@ -211,6 +211,10 @@ child_attach (char *args, int from_tty)
   
   inferior_ptid = pid_to_ptid (pid);
   push_target (&deprecated_child_ops);
+
+  /* Do this first, before anything has had a chance to query the
+     inferior's symbol table or similar.  */
+  observer_notify_inferior_created (&current_target, from_tty);
 }
 
 #if !defined(CHILD_POST_ATTACH)
Index: gdb-6.3/gdb/symfile-mem.c
===================================================================
--- gdb-6.3.orig/gdb/symfile-mem.c	2004-07-17 10:24:07.000000000 -0400
+++ gdb-6.3/gdb/symfile-mem.c	2004-11-10 00:53:43.722610958 -0500
@@ -52,13 +52,19 @@
 #include "target.h"
 #include "value.h"
 #include "symfile.h"
+#include "observer.h"
+#include "auxv.h"
+#include "elf/common.h"
 
 
 /* Read inferior memory at ADDR to find the header of a loaded object file
    and read its in-core symbols out of inferior memory.  TEMPL is a bfd
-   representing the target's format.  */
+   representing the target's format.  NAME is the name to use for this
+   symbol file in messages; it can be NULL or a malloc-allocated string
+   which will be attached to the BFD.  */
 static struct objfile *
-symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, int from_tty)
+symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
+			     int from_tty)
 {
   struct objfile *objf;
   struct bfd *nbfd;
@@ -75,7 +81,10 @@ symbol_file_add_from_memory (struct bfd 
   if (nbfd == NULL)
     error ("Failed to read a valid object file image from memory.");
 
-  nbfd->filename = xstrdup ("shared object read from target memory");
+  if (name == NULL)
+    nbfd->filename = xstrdup ("shared object read from target memory");
+  else
+    nbfd->filename = name;
 
   if (!bfd_check_format (nbfd, bfd_object))
     {
@@ -129,7 +138,73 @@ add_symbol_file_from_memory_command (cha
     error ("\
 Must use symbol-file or exec-file before add-symbol-file-from-memory.");
 
-  symbol_file_add_from_memory (templ, addr, from_tty);
+  symbol_file_add_from_memory (templ, addr, NULL, from_tty);
+}
+
+/* Arguments for symbol_file_add_from_memory_wrapper.  */
+
+struct symbol_file_add_from_memory_args
+{
+  struct bfd *bfd;
+  CORE_ADDR sysinfo_ehdr;
+  char *name;
+  int from_tty;
+};
+
+/* Wrapper function for symbol_file_add_from_memory, for
+   catch_exceptions.  */
+
+static int
+symbol_file_add_from_memory_wrapper (struct ui_out *uiout, void *data)
+{
+  struct symbol_file_add_from_memory_args *args = data;
+
+  symbol_file_add_from_memory (args->bfd, args->sysinfo_ehdr, args->name,
+			       args->from_tty);
+  return 0;
+}
+
+/* Try to add the symbols for the vsyscall page, if there is one.  This function
+   is called via the inferior_created observer.  */
+
+static void
+add_vsyscall_page (struct target_ops *target, int from_tty)
+{
+  CORE_ADDR sysinfo_ehdr;
+
+  if (target_auxv_search (target, AT_SYSINFO_EHDR, &sysinfo_ehdr) > 0
+      && sysinfo_ehdr != (CORE_ADDR) 0)
+    {
+      struct bfd *bfd;
+      struct symbol_file_add_from_memory_args args;
+
+      if (core_bfd != NULL)
+	bfd = core_bfd;
+      else if (exec_bfd != NULL)
+	bfd = exec_bfd;
+      else
+       /* FIXME: cagney/2004-05-06: Should not require an existing
+	  BFD when trying to create a run-time BFD of the VSYSCALL
+	  page in the inferior.  Unfortunately that's the current
+	  interface so for the moment bail.  Introducing a
+	  ``bfd_runtime'' (a BFD created using the loaded image) file
+	  format should fix this.  */
+	{
+	  warning ("could not load vsyscall page because no executable was specified");
+	  warning ("try using the \"file\" command first");
+	  return;
+	}
+      args.bfd = bfd;
+      args.sysinfo_ehdr = sysinfo_ehdr;
+      xasprintf (&args.name, "system-supplied DSO at 0x%s",
+		 paddr_nz (sysinfo_ehdr));
+      /* Pass zero for FROM_TTY, because the action of loading the
+	 vsyscall DSO was not triggered by the user, even if the user
+	 typed "run" at the TTY.  */
+      args.from_tty = 0;
+      catch_exceptions (uiout, symbol_file_add_from_memory_wrapper,
+			&args, NULL, RETURN_MASK_ALL);
+    }
 }
 
 
@@ -143,4 +218,7 @@ Load the symbols out of memory from a dy
 Give an expression for the address of the file's shared object file header.",
            &cmdlist);
 
+  /* Want to know of each new inferior so that its vsyscall info can
+     be extracted.  */
+  observer_attach_inferior_created (add_vsyscall_page);
 }
Index: gdb-6.3/gdb/Makefile.in
===================================================================
--- gdb-6.3.orig/gdb/Makefile.in	2004-11-10 00:29:00.000000000 -0500
+++ gdb-6.3/gdb/Makefile.in	2004-11-10 00:54:47.728100986 -0500
@@ -2020,7 +2020,7 @@ i386-linux-nat.o: i386-linux-nat.c $(def
 i386-linux-tdep.o: i386-linux-tdep.c $(defs_h) $(gdbcore_h) $(frame_h) \
 	$(value_h) $(regcache_h) $(inferior_h) $(osabi_h) $(reggroups_h) \
 	$(gdb_string_h) $(i386_tdep_h) $(i386_linux_tdep_h) $(glibc_tdep_h) \
-	$(solib_svr4_h)
+	$(solib_svr4_h) $(dwarf2_frame_h)
 i386ly-tdep.o: i386ly-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
 	$(regcache_h) $(target_h) $(osabi_h) $(i386_tdep_h)
 i386-nat.o: i386-nat.c $(defs_h) $(breakpoint_h) $(command_h) $(gdbcmd_h)
@@ -2606,7 +2606,8 @@ symfile.o: symfile.c $(defs_h) $(bfdlink
 	$(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \
 	$(gdb_string_h) $(gdb_stat_h)
 symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \
-	$(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h)
+	$(objfiles_h) $(gdbcmd_h) $(target_h) $(value_h) $(symfile_h) \
+	$(observer_h) $(auxv_h) $(elf_common_h)
 symmisc.o: symmisc.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(bfd_h) \
 	$(symfile_h) $(objfiles_h) $(breakpoint_h) $(command_h) \
 	$(gdb_obstack_h) $(language_h) $(bcache_h) $(block_h) $(gdb_regex_h) \