From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18411 invoked by alias); 7 May 2004 01:19:43 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 18324 invoked from network); 7 May 2004 01:19:39 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 7 May 2004 01:19:39 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i471Jc0o021417 for ; Thu, 6 May 2004 21:19:38 -0400 Received: from localhost.redhat.com (to-dhcp51.toronto.redhat.com [172.16.14.151]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i46J4Av03266; Thu, 6 May 2004 15:04:10 -0400 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id F1D122B9D; Thu, 6 May 2004 15:04:10 -0400 (EDT) Message-ID: <409A8C2A.2010605@gnu.org> Date: Fri, 07 May 2004 01:19:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Cc: Roland McGrath Subject: [obish?sym;rfa:doc] Wire up vsyscall Content-Type: multipart/mixed; boundary="------------040702070207020300030609" X-SW-Source: 2004-05/txt/msg00169.txt.bz2 This is a multi-part message in MIME format. --------------040702070207020300030609 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 918 Hello, The attached patch adds a new observable event ``inferior created'' and then uses that to load up the vsyscall page (if its available). At present I know of the following problems: 1. The code assumes ELF support in BFD Per recent BFD posts, I'm fixing this. 2. bfd_elf_bfd_from_remote_memory requires an existing bfd For the case: $ ./gdb (gdb) attach that isn't necessarially so. 1. will fix this. 3. inferior recycle VS inferior create Because GDB currently fudges things by recycling the inferior at each run (instead of creating a new fresh inferior) symfile tries to reload the vsyscall page. Doesn't do any harm fortunatly. Having a proper inferior will fix this. Observer doco ok? The symtab tweak is relatively obvious (I stole it from Roland's post) but still, comments? As for tests, I'm thinking something to check for the absence of: 0x1234 in ????? in a backtrace. Andrew --------------040702070207020300030609 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 8314 2004-05-06 Andrew Cagney Roland McGrath * inftarg.c: Include "observer.h". (child_attach, child_create_inferior): Notify inferior_created. * corelow.c: Include "observer.h". (core_open): Notify inferior_created. * symfile-mem.c: Include "observer.h", "auxv.h", and "elf/common.h". (struct symbol_file_add_from_memory_args) (symbol_file_add_from_memory_wrapper, add_vsyscall_page) (_initialize_symfile_mem): Add an inferior_created observer, use to load the vsyscall page. * Makefile.in (symfile-mem.o, inftarg.o, corelow.o): Update dependencies. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.560 diff -p -u -r1.560 Makefile.in --- Makefile.in 4 May 2004 23:47:15 -0000 1.560 +++ Makefile.in 6 May 2004 18:46:39 -0000 @@ -1651,7 +1651,7 @@ corefile.o: corefile.c $(defs_h) $(gdb_s corelow.o: corelow.c $(defs_h) $(arch_utils_h) $(gdb_string_h) $(frame_h) \ $(inferior_h) $(symtab_h) $(command_h) $(bfd_h) $(target_h) \ $(gdbcore_h) $(gdbthread_h) $(regcache_h) $(regset_h) $(symfile_h) \ - $(exec_h) $(readline_h) $(gdb_assert_h) + $(exec_h) $(readline_h) $(gdb_assert_h) $(observer_h) core-regset.o: core-regset.c $(defs_h) $(command_h) $(gdbcore_h) \ $(inferior_h) $(target_h) $(gdb_string_h) $(gregset_h) cp-abi.o: cp-abi.c $(defs_h) $(value_h) $(cp_abi_h) $(command_h) $(gdbcmd_h) \ @@ -1934,7 +1934,8 @@ infrun.o: infrun.c $(defs_h) $(gdb_strin $(symfile_h) $(top_h) $(inf_loop_h) $(regcache_h) $(value_h) \ $(observer_h) $(language_h) $(gdb_assert_h) inftarg.o: inftarg.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \ - $(gdbcore_h) $(command_h) $(gdb_stat_h) $(gdb_wait_h) $(inflow_h) + $(gdbcore_h) $(command_h) $(gdb_stat_h) $(gdb_wait_h) $(inflow_h) \ + $(observer_h) infttrace.o: infttrace.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \ $(gdb_string_h) $(gdb_wait_h) $(command_h) $(gdbthread_h) \ $(gdbcore_h) $(infttrace_h) @@ -2427,7 +2428,7 @@ symfile.o: symfile.c $(defs_h) $(bfdlink $(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) \ - $(symfile_mem_h) + $(symfile_mem_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) \ Index: corelow.c =================================================================== RCS file: /cvs/src/src/gdb/corelow.c,v retrieving revision 1.39 diff -p -u -r1.39 corelow.c --- corelow.c 28 Apr 2004 16:36:25 -0000 1.39 +++ corelow.c 6 May 2004 18:46:40 -0000 @@ -43,7 +43,7 @@ #include "symfile.h" #include "exec.h" #include "readline/readline.h" - +#include "observer.h" #include "gdb_assert.h" #ifndef O_BINARY @@ -354,6 +354,10 @@ core_open (char *filename, int from_tty) ontop = !push_target (&core_ops); discard_cleanups (old_chain); + + /* This is done first, before anything has a chance to query the + inferior for information such as symbols. */ + observer_notify_inferior_created (&core_ops); p = bfd_core_file_failing_command (core_bfd); if (p) Index: inftarg.c =================================================================== RCS file: /cvs/src/src/gdb/inftarg.c,v retrieving revision 1.23 diff -p -u -r1.23 inftarg.c --- inftarg.c 4 Feb 2004 21:49:55 -0000 1.23 +++ inftarg.c 6 May 2004 18:46:41 -0000 @@ -34,7 +34,7 @@ #include #include #include - +#include "observer.h" #include "gdb_wait.h" #include "inflow.h" @@ -232,6 +232,10 @@ child_attach (char *args, int from_tty) inferior_ptid = pid_to_ptid (pid); push_target (&child_ops); + + /* Do this first, before anything has had a chance to query the + inferiors symbol table or similar. */ + observer_notify_inferior_created (¤t_target); } #endif /* ATTACH_DETACH */ } @@ -364,6 +368,7 @@ child_create_inferior (char *exec_file, fork_inferior (exec_file, allargs, env, ptrace_me, ptrace_him, NULL, NULL); #endif /* We are at the first instruction we care about. */ + observer_notify_inferior_created (¤t_target); /* Pedal to the metal... */ proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0); } Index: symfile-mem.c =================================================================== RCS file: /cvs/src/src/gdb/symfile-mem.c,v retrieving revision 1.1 diff -p -u -r1.1 symfile-mem.c --- symfile-mem.c 2 May 2004 10:14:01 -0000 1.1 +++ symfile-mem.c 6 May 2004 18:46:41 -0000 @@ -53,6 +53,9 @@ #include "value.h" #include "symfile.h" #include "symfile-mem.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 @@ -137,6 +140,57 @@ Must use symbol-file or exec-file before symbol_file_add_from_memory (templ, addr, from_tty); } +/* When ever a new inferior is created, try to load its vsyscall + page. */ + +struct symbol_file_add_from_memory_args +{ + struct bfd *bfd; + CORE_ADDR sysinfo_ehdr; + int from_tty; +}; + +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->from_tty); + return 0; +} + +static void +add_vsyscall_page (struct target_ops *target) +{ + 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. Unfortunatly 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. */ + return; + args.bfd = bfd; + args.sysinfo_ehdr = sysinfo_ehdr; + args.from_tty = 0; + if (catch_exceptions (uiout, symbol_file_add_from_memory_wrapper, + &args, NULL, RETURN_MASK_ALL) >= 0) + printf_unfiltered ("Loaded system supplied DSO at 0x%s\n", + paddr_nz (sysinfo_ehdr)); + } +} void _initialize_symfile_mem () @@ -148,4 +202,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 it's vsyscall info can + be extracted. */ + observer_attach_inferior_created (add_vsyscall_page); } Index: doc/ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/doc/ChangeLog,v retrieving revision 1.409 diff -p -u -r1.409 ChangeLog --- doc/ChangeLog 1 May 2004 16:52:30 -0000 1.409 +++ doc/ChangeLog 6 May 2004 18:46:44 -0000 @@ -1,3 +1,7 @@ +2004-05-06 Andrew Cagney + + * observer.texi (GDB Observers): Document "inferior_created". + 2004-05-01 Andrew Cagney * gdbint.texinfo (Target Architecture Definition): Delete Index: doc/observer.texi =================================================================== RCS file: /cvs/src/src/gdb/doc/observer.texi,v retrieving revision 1.5 diff -p -u -r1.5 observer.texi --- doc/observer.texi 30 Apr 2004 07:38:50 -0000 1.5 +++ doc/observer.texi 6 May 2004 18:46:45 -0000 @@ -77,3 +77,11 @@ The inferior has stopped for real. @deftypefun void target_changed (struct target_ops *@var{target}) The target's register contents have changed. @end deftypefun + +@deftypefun void inferior_created (struct target_ops *@var{objfile}) +@var{GDBN} has just created to a new inferior. For @samp{run}, it is +called while the inferior is still stopped at the entry-point +instruction. For @samp{attach} and @samp{core}, it is called +immediatly after opening the inferior (and before any information on +the inferior has been printed). +@end deftypefun --------------040702070207020300030609--