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