2006-12-18 23:16:31 +00:00
|
|
|
--- gdb/Makefile.in
|
|
|
|
+++ gdb/Makefile.in
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -2426,7 +2426,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
$(objfiles_h) $(gdb_stabs_h) $(target_h) $(bcache_h) $(mdebugread_h) \
|
|
|
|
$(gdb_assert_h) $(gdb_stat_h) $(gdb_obstack_h) $(gdb_string_h) \
|
|
|
|
$(hashtab_h) $(breakpoint_h) $(block_h) $(dictionary_h) $(source_h) \
|
|
|
|
- $(parser_defs_h) $(expression_h)
|
|
|
|
+ $(parser_defs_h) $(expression_h) $(auxv_h) $(elf_common_h)
|
|
|
|
observer.o: observer.c $(defs_h) $(observer_h) $(command_h) $(gdbcmd_h) \
|
|
|
|
$(observer_inc)
|
|
|
|
obsd-tdep.o: obsd-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(obsd_tdep_h)
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -2612,9 +2612,9 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
$(bcache_h) $(regcache_h)
|
|
|
|
solib-svr4.o: solib-svr4.c $(defs_h) $(elf_external_h) $(elf_common_h) \
|
|
|
|
$(elf_mips_h) $(symtab_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
|
|
|
|
- $(gdbcore_h) $(target_h) $(inferior_h) $(gdb_assert_h) \
|
|
|
|
+ $(gdbcore_h) $(target_h) $(inferior_h) $(command_h) $(gdb_assert_h) \
|
|
|
|
$(solist_h) $(solib_h) $(solib_svr4_h) $(bfd_target_h) $(elf_bfd_h) \
|
|
|
|
- $(exec_h)
|
|
|
|
+ $(exec_h) $(auxv_h)
|
|
|
|
sol-thread.o: sol-thread.c $(defs_h) $(gdbthread_h) $(target_h) \
|
|
|
|
$(inferior_h) $(gdb_stat_h) $(gdbcmd_h) $(gdbcore_h) $(regcache_h) \
|
2007-06-08 15:35:24 +00:00
|
|
|
$(solib_h) $(symfile_h) $(observer_h) $(gdb_string_h) $(gregset_h)
|
2006-12-18 23:16:31 +00:00
|
|
|
--- gdb/breakpoint.c
|
|
|
|
+++ gdb/breakpoint.c
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -3900,6 +3900,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
printf_filtered ("%s%s ",
|
|
|
|
((b->enable_state == bp_disabled ||
|
|
|
|
b->enable_state == bp_shlib_disabled ||
|
|
|
|
+ b->enable_state == bp_startup_disabled ||
|
|
|
|
b->enable_state == bp_call_disabled)
|
|
|
|
? " (disabled)"
|
|
|
|
: b->enable_state == bp_permanent
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -4586,6 +4587,60 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+void
|
|
|
|
+disable_breakpoints_at_startup (int silent)
|
|
|
|
+{
|
|
|
|
+ struct breakpoint *b;
|
|
|
|
+ int disabled_startup_breaks = 0;
|
|
|
|
+
|
|
|
|
+ if (bfd_get_start_address (exec_bfd) != entry_point_address ())
|
|
|
|
+ {
|
|
|
|
+ ALL_BREAKPOINTS (b)
|
|
|
|
+ {
|
|
|
|
+ if ((b->type == bp_breakpoint
|
|
|
|
+ || b->type == bp_hardware_breakpoint)
|
|
|
|
+ && b->enable_state == bp_enabled
|
|
|
|
+ && !b->loc->duplicate)
|
|
|
|
+ {
|
|
|
|
+ b->enable_state = bp_startup_disabled;
|
|
|
|
+ if (!silent)
|
|
|
|
+ {
|
|
|
|
+ if (!disabled_startup_breaks)
|
|
|
|
+ {
|
|
|
|
+ target_terminal_ours_for_output ();
|
|
|
|
+ warning ("Temporarily disabling breakpoints:");
|
|
|
|
+ }
|
|
|
|
+ disabled_startup_breaks = 1;
|
|
|
|
+ warning ("breakpoint #%d addr 0x%s",
|
|
|
|
+ b->number, paddr_nz (b->loc->address));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* Try to reenable any breakpoints after startup. */
|
|
|
|
+void
|
|
|
|
+re_enable_breakpoints_at_startup (void)
|
|
|
|
+{
|
|
|
|
+ struct breakpoint *b;
|
|
|
|
+
|
|
|
|
+ if (bfd_get_start_address (exec_bfd) != entry_point_address ())
|
|
|
|
+ {
|
|
|
|
+ ALL_BREAKPOINTS (b)
|
|
|
|
+ if (b->enable_state == bp_startup_disabled)
|
|
|
|
+ {
|
|
|
|
+ gdb_byte buf[1];
|
|
|
|
+
|
|
|
|
+ /* Do not reenable the breakpoint if the shared library
|
|
|
|
+ is still not mapped in. */
|
|
|
|
+ if (target_read_memory (b->loc->address, buf, 1) == 0)
|
|
|
|
+ b->enable_state = bp_enabled;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
static void
|
|
|
|
solib_load_unload_1 (char *hookname, int tempflag, char *dll_pathname,
|
|
|
|
char *cond_string, enum bptype bp_kind)
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -7023,6 +7078,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
&& !b->loc->duplicate
|
|
|
|
&& b->enable_state != bp_disabled
|
|
|
|
&& b->enable_state != bp_shlib_disabled
|
|
|
|
+ && b->enable_state != bp_startup_disabled
|
|
|
|
&& !b->pending
|
|
|
|
&& b->enable_state != bp_call_disabled)
|
|
|
|
{
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -7241,7 +7297,8 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
save_enable = b->enable_state;
|
|
|
|
- if (b->enable_state != bp_shlib_disabled)
|
|
|
|
+ if (b->enable_state != bp_shlib_disabled
|
|
|
|
+ && b->enable_state != bp_startup_disabled)
|
|
|
|
b->enable_state = bp_disabled;
|
|
|
|
else
|
|
|
|
/* If resetting a shlib-disabled breakpoint, we don't want to
|
|
|
|
--- gdb/breakpoint.h
|
|
|
|
+++ gdb/breakpoint.h
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -155,6 +155,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
automatically enabled and reset when the call
|
|
|
|
"lands" (either completes, or stops at another
|
|
|
|
eventpoint). */
|
|
|
|
+ bp_startup_disabled,
|
|
|
|
bp_permanent /* There is a breakpoint instruction hard-wired into
|
|
|
|
the target's code. Don't try to write another
|
|
|
|
breakpoint instruction on top of it, or restore
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -793,8 +794,12 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
|
|
|
|
extern void disable_breakpoints_in_shlibs (int silent);
|
|
|
|
|
|
|
|
+extern void disable_breakpoints_at_startup (int silent);
|
|
|
|
+
|
|
|
|
extern void re_enable_breakpoints_in_shlibs (void);
|
|
|
|
|
|
|
|
+extern void re_enable_breakpoints_at_startup (void);
|
|
|
|
+
|
|
|
|
extern void create_solib_load_event_breakpoint (char *, int, char *, char *);
|
|
|
|
|
|
|
|
extern void create_solib_unload_event_breakpoint (char *, int,
|
|
|
|
--- gdb/dwarf2read.c
|
|
|
|
+++ gdb/dwarf2read.c
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -1237,7 +1237,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
else
|
|
|
|
dwarf2_per_objfile->loc_buffer = NULL;
|
|
|
|
|
|
|
|
- if (mainline
|
|
|
|
+ if (mainline == 1
|
|
|
|
|| (objfile->global_psymbols.size == 0
|
|
|
|
&& objfile->static_psymbols.size == 0))
|
|
|
|
{
|
|
|
|
--- gdb/elfread.c
|
|
|
|
+++ gdb/elfread.c
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -541,7 +541,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
/* If we are reinitializing, or if we have never loaded syms yet,
|
|
|
|
set table to empty. MAINLINE is cleared so that *_read_psymtab
|
|
|
|
functions do not all also re-initialize the psymbol table. */
|
|
|
|
- if (mainline)
|
|
|
|
+ if (mainline == 1)
|
|
|
|
{
|
|
|
|
init_psymbol_list (objfile, 0);
|
|
|
|
mainline = 0;
|
|
|
|
--- gdb/infrun.c
|
|
|
|
+++ gdb/infrun.c
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -2223,6 +2223,11 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
code segments in shared libraries might be mapped in now. */
|
|
|
|
re_enable_breakpoints_in_shlibs ();
|
|
|
|
|
|
|
|
+ /* For PIE executables, we dont really know where the
|
|
|
|
+ breakpoints are going to be until we start up the
|
|
|
|
+ inferior. */
|
|
|
|
+ re_enable_breakpoints_at_startup ();
|
|
|
|
+
|
|
|
|
/* If requested, stop when the dynamic linker notifies
|
|
|
|
gdb of events. This allows the user to get control
|
|
|
|
and place breakpoints in initializer routines for
|
|
|
|
--- gdb/objfiles.c
|
|
|
|
+++ gdb/objfiles.c
|
|
|
|
@@ -49,6 +49,8 @@
|
|
|
|
#include "block.h"
|
|
|
|
#include "dictionary.h"
|
|
|
|
#include "source.h"
|
|
|
|
+#include "auxv.h"
|
|
|
|
+#include "elf/common.h"
|
|
|
|
|
|
|
|
/* Prototypes for local functions */
|
|
|
|
|
|
|
|
@@ -261,7 +263,16 @@
|
|
|
|
CORE_ADDR
|
|
|
|
entry_point_address (void)
|
|
|
|
{
|
|
|
|
- return symfile_objfile ? symfile_objfile->ei.entry_point : 0;
|
|
|
|
+ int ret;
|
|
|
|
+ CORE_ADDR entry_addr;
|
|
|
|
+
|
|
|
|
+ /* Find the address of the entry point of the program from the
|
|
|
|
+ auxv vector. */
|
|
|
|
+ ret = target_auxv_search (¤t_target, AT_ENTRY, &entry_addr);
|
|
|
|
+ if (ret > 0)
|
|
|
|
+ return entry_addr;
|
|
|
|
+ else
|
|
|
|
+ return symfile_objfile ? symfile_objfile->ei.entry_point : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the terminating entry of OBJFILE's minimal symbol table.
|
|
|
|
--- gdb/solib-svr4.c
|
|
|
|
+++ gdb/solib-svr4.c
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -33,6 +33,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
#include "gdbcore.h"
|
|
|
|
#include "target.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
+#include "command.h"
|
|
|
|
|
|
|
|
#include "gdb_assert.h"
|
|
|
|
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -43,6 +44,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
#include "bfd-target.h"
|
|
|
|
#include "elf-bfd.h"
|
|
|
|
#include "exec.h"
|
|
|
|
+#include "auxv.h"
|
|
|
|
|
|
|
|
static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
|
|
|
|
static int svr4_have_link_map_offsets (void);
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -261,8 +263,6 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
|
|
|
|
/* Local function prototypes */
|
|
|
|
|
|
|
|
-static int match_main (char *);
|
|
|
|
-
|
|
|
|
static CORE_ADDR bfd_lookup_symbol (bfd *, char *, flagword);
|
|
|
|
|
|
|
|
/*
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -387,6 +387,16 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
gdb_byte *buf;
|
|
|
|
gdb_byte *bufend;
|
|
|
|
int arch_size;
|
|
|
|
+ CORE_ADDR relocated_dyninfo_addr, entry_addr;
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ /* Find the address of the entry point of the program from the
|
|
|
|
+ auxv vector. */
|
|
|
|
+ ret = target_auxv_search (¤t_target, AT_ENTRY, &entry_addr);
|
|
|
|
+
|
|
|
|
+ if (ret <= 0)
|
|
|
|
+ /* No auxv info, maybe an older kernel. Fake our way through. */
|
|
|
|
+ entry_addr = bfd_get_start_address (exec_bfd);
|
|
|
|
|
|
|
|
/* Find the start address of the .dynamic section. */
|
|
|
|
dyninfo_sect = bfd_get_section_by_name (exec_bfd, ".dynamic");
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -404,11 +414,13 @@
|
|
|
|
}
|
|
|
|
|
2006-12-18 23:16:31 +00:00
|
|
|
dyninfo_addr = bfd_section_vma (exec_bfd, dyninfo_sect);
|
|
|
|
+ relocated_dyninfo_addr
|
|
|
|
+ = dyninfo_addr + entry_addr - bfd_get_start_address (exec_bfd);
|
|
|
|
|
|
|
|
/* Read in .dynamic section, silently ignore errors. */
|
|
|
|
dyninfo_sect_size = bfd_section_size (exec_bfd, dyninfo_sect);
|
|
|
|
buf = alloca (dyninfo_sect_size);
|
|
|
|
- if (target_read_memory (dyninfo_addr, buf, dyninfo_sect_size))
|
|
|
|
+ if (target_read_memory (relocated_dyninfo_addr, buf, dyninfo_sect_size))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Find the DT_DEBUG entry in the the .dynamic section.
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -757,9 +769,55 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
does have a name, so we can no longer use a missing name to
|
|
|
|
decide when to ignore it. */
|
|
|
|
if (IGNORE_FIRST_LINK_MAP_ENTRY (new) && ldsomap == 0)
|
|
|
|
- free_so (new);
|
|
|
|
+ {
|
|
|
|
+ /* It is the first link map entry, i.e. it is the main
|
|
|
|
+ executable. */
|
|
|
|
+ if (bfd_get_start_address (exec_bfd) == entry_point_address ())
|
|
|
|
+ {
|
|
|
|
+ /* Non-pie case, main executable has not been relocated. */
|
|
|
|
+ free_so (new);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ /* Pie case, main executable has been relocated. */
|
|
|
|
+ struct so_list *gdb_solib;
|
|
|
|
+
|
|
|
|
+ strncpy (new->so_name, exec_bfd->filename,
|
|
|
|
+ SO_NAME_MAX_PATH_SIZE - 1);
|
|
|
|
+ new->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
|
|
|
|
+ strcpy (new->so_original_name, new->so_name);
|
|
|
|
+ new->main_relocated = 0;
|
|
|
|
+
|
|
|
|
+ for (gdb_solib = master_so_list ();
|
|
|
|
+ gdb_solib != NULL;
|
|
|
|
+ gdb_solib = gdb_solib->next)
|
|
|
|
+ if (strcmp (gdb_solib->so_name, new->so_name) == 0
|
|
|
|
+ && gdb_solib->main_relocated)
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ if (gdb_solib == NULL)
|
|
|
|
+ {
|
|
|
|
+ add_to_target_sections (0 /*from_tty*/, ¤t_target, new);
|
|
|
|
+ new->main_p = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* We need this in the list of shared libs we return because
|
|
|
|
+ solib_add_stub will loop through it and add the symbol
|
|
|
|
+ file. */
|
|
|
|
+ new->next = 0;
|
|
|
|
+ *link_ptr = new;
|
|
|
|
+ link_ptr = &new->next;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
+ /* This is not the first link map entry, i.e. is not the main
|
|
|
|
+ executable. Note however that it could be the DSO supplied on
|
|
|
|
+ certain systems (i.e. Linux 2.6) containing information about
|
|
|
|
+ the vsyscall page. We must ignore such entry. This entry is
|
|
|
|
+ nameless (just like the one for the main executable,
|
|
|
|
+ sigh). */
|
|
|
|
+
|
|
|
|
int errcode;
|
|
|
|
char *buffer;
|
|
|
|
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -777,10 +835,8 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
strcpy (new->so_original_name, new->so_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
- /* If this entry has no name, or its name matches the name
|
|
|
|
- for the main executable, don't include it in the list. */
|
|
|
|
- if (! new->so_name[0]
|
|
|
|
- || match_main (new->so_name))
|
|
|
|
+ /* If this entry has no name, don't include it in the list. */
|
|
|
|
+ if (! new->so_name[0])
|
|
|
|
free_so (new);
|
|
|
|
else
|
|
|
|
{
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -876,24 +932,6 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-/* On some systems, the only way to recognize the link map entry for
|
|
|
|
- the main executable file is by looking at its name. Return
|
|
|
|
- non-zero iff SONAME matches one of the known main executable names. */
|
|
|
|
-
|
|
|
|
-static int
|
|
|
|
-match_main (char *soname)
|
|
|
|
-{
|
|
|
|
- char **mainp;
|
|
|
|
-
|
|
|
|
- for (mainp = main_name_list; *mainp != NULL; mainp++)
|
|
|
|
- {
|
|
|
|
- if (strcmp (soname, *mainp) == 0)
|
|
|
|
- return (1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return (0);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/* Return 1 if PC lies in the dynamic symbol resolution code of the
|
|
|
|
SVR4 run time loader. */
|
|
|
|
static CORE_ADDR interp_text_sect_low;
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -1374,6 +1412,8 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
while (stop_signal != TARGET_SIGNAL_TRAP);
|
|
|
|
stop_soon = NO_STOP_QUIETLY;
|
|
|
|
#endif /* defined(_SCO_DS) */
|
|
|
|
+
|
|
|
|
+ disable_breakpoints_at_startup (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
--- gdb/solib.c
|
|
|
|
+++ gdb/solib.c
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -394,15 +394,37 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
/* Have we already loaded this shared object? */
|
|
|
|
ALL_OBJFILES (so->objfile)
|
|
|
|
{
|
|
|
|
- if (strcmp (so->objfile->name, so->so_name) == 0)
|
|
|
|
+ /* Found an already loaded shared library. */
|
|
|
|
+ if (strcmp (so->objfile->name, so->so_name) == 0
|
|
|
|
+ && !so->main_p)
|
|
|
|
return 1;
|
|
|
|
+ /* Found an already loaded main executable. This could happen in
|
|
|
|
+ two circumstances.
|
|
|
|
+ First case: the main file has already been read in as the first
|
|
|
|
+ thing that gdb does at startup, and the file hasn't been
|
|
|
|
+ relocated properly yet. Therefore we need to read it in with the
|
|
|
|
+ proper section info.
|
|
|
|
+ Second case: it has been read in with the correct relocation, and
|
|
|
|
+ therefore we need to skip it. */
|
|
|
|
+ if (strcmp (so->objfile->name, so->so_name) == 0
|
|
|
|
+ && so->main_p
|
|
|
|
+ && so->main_relocated)
|
|
|
|
+ return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sap = build_section_addr_info_from_section_table (so->sections,
|
|
|
|
so->sections_end);
|
|
|
|
|
|
|
|
- so->objfile = symbol_file_add (so->so_name, so->from_tty,
|
|
|
|
- sap, 0, OBJF_SHARED);
|
|
|
|
+ if (so->main_p)
|
|
|
|
+ {
|
|
|
|
+ so->objfile = symbol_file_add (so->so_name, /*so->from_tty*/ 0,
|
|
|
|
+ sap, 1, 0);
|
|
|
|
+ so->main_relocated = 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ so->objfile = symbol_file_add (so->so_name, so->from_tty,
|
|
|
|
+ sap, 0, OBJF_SHARED);
|
|
|
|
+
|
|
|
|
free_section_addr_info (sap);
|
|
|
|
|
|
|
|
return (1);
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -583,28 +605,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
/* Fill in the rest of each of the `struct so_list' nodes. */
|
|
|
|
for (i = inferior; i; i = i->next)
|
|
|
|
{
|
|
|
|
- i->from_tty = from_tty;
|
|
|
|
-
|
|
|
|
- /* Fill in the rest of the `struct so_list' node. */
|
|
|
|
- catch_errors (solib_map_sections, i,
|
|
|
|
- "Error while mapping shared library sections:\n",
|
|
|
|
- RETURN_MASK_ALL);
|
|
|
|
-
|
|
|
|
- /* If requested, add the shared object's sections to the TARGET's
|
|
|
|
- section table. Do this immediately after mapping the object so
|
|
|
|
- that later nodes in the list can query this object, as is needed
|
|
|
|
- in solib-osf.c. */
|
|
|
|
- if (target)
|
|
|
|
- {
|
|
|
|
- int count = (i->sections_end - i->sections);
|
|
|
|
- if (count > 0)
|
|
|
|
- {
|
|
|
|
- int space = target_resize_to_sections (target, count);
|
|
|
|
- memcpy (target->to_sections + space,
|
|
|
|
- i->sections,
|
|
|
|
- count * sizeof (i->sections[0]));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
+ add_to_target_sections (from_tty, target, i);
|
|
|
|
|
|
|
|
/* Notify any observer that the shared object has been
|
|
|
|
loaded now that we've added it to GDB's tables. */
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -700,6 +701,39 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+void
|
|
|
|
+add_to_target_sections (int from_tty, struct target_ops *target,
|
|
|
|
+ struct so_list *solib)
|
|
|
|
+{
|
|
|
|
+ /* If this is set, then the sections have been already added to the
|
|
|
|
+ target list. */
|
|
|
|
+ if (solib->main_p)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ solib->from_tty = from_tty;
|
|
|
|
+
|
|
|
|
+ /* Fill in the rest of the `struct so_list' node. */
|
|
|
|
+ catch_errors (solib_map_sections, solib,
|
|
|
|
+ "Error while mapping shared library sections:\n",
|
|
|
|
+ RETURN_MASK_ALL);
|
|
|
|
+
|
|
|
|
+ /* If requested, add the shared object's sections to the TARGET's
|
|
|
|
+ section table. Do this immediately after mapping the object so
|
|
|
|
+ that later nodes in the list can query this object, as is needed
|
|
|
|
+ in solib-osf.c. */
|
|
|
|
+ if (target)
|
|
|
|
+ {
|
|
|
|
+ int count = solib->sections_end - solib->sections;
|
|
|
|
+ if (count > 0)
|
|
|
|
+ {
|
|
|
|
+ int space = target_resize_to_sections (target, count);
|
|
|
|
+ memcpy (target->to_sections + space,
|
|
|
|
+ solib->sections,
|
|
|
|
+ count * sizeof (solib->sections[0]));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
--- gdb/solist.h
|
|
|
|
+++ gdb/solist.h
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -61,6 +61,8 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
bfd *abfd;
|
|
|
|
char symbols_loaded; /* flag: symbols read in yet? */
|
|
|
|
char from_tty; /* flag: print msgs? */
|
|
|
|
+ char main_p; /* flag: is this the main executable? */
|
|
|
|
+ char main_relocated; /* flag: has it been relocated yet? */
|
|
|
|
struct objfile *objfile; /* objfile for loaded lib */
|
|
|
|
struct section_table *sections;
|
|
|
|
struct section_table *sections_end;
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -115,6 +117,10 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
/* Find solib binary file and open it. */
|
|
|
|
extern int solib_open (char *in_pathname, char **found_pathname);
|
|
|
|
|
|
|
|
+/* Add the list of sections in so_list to the target to_sections. */
|
|
|
|
+extern void add_to_target_sections (int, struct target_ops *,
|
|
|
|
+ struct so_list *);
|
|
|
|
+
|
|
|
|
/* FIXME: gdbarch needs to control this variable */
|
|
|
|
extern struct target_so_ops *current_target_so_ops;
|
|
|
|
|
|
|
|
--- gdb/symfile-mem.c
|
|
|
|
+++ gdb/symfile-mem.c
|
|
|
|
@@ -110,7 +110,7 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
objf = symbol_file_add_from_bfd (nbfd, from_tty,
|
|
|
|
- sai, 0, OBJF_SHARED);
|
|
|
|
+ sai, 2, OBJF_SHARED);
|
|
|
|
|
|
|
|
/* This might change our ideas about frames already looked at. */
|
|
|
|
reinit_frame_cache ();
|
|
|
|
--- gdb/symfile.c
|
|
|
|
+++ gdb/symfile.c
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -708,7 +708,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
|
|
|
|
/* Now either addrs or offsets is non-zero. */
|
|
|
|
|
|
|
|
- if (mainline)
|
|
|
|
+ if (mainline == 1)
|
|
|
|
{
|
|
|
|
/* We will modify the main symbol table, make sure that all its users
|
|
|
|
will be cleaned up if an error occurs during symbol reading. */
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -736,7 +736,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
|
|
|
|
We no longer warn if the lowest section is not a text segment (as
|
|
|
|
happens for the PA64 port. */
|
|
|
|
- if (!mainline && addrs && addrs->other[0].name)
|
|
|
|
+ if (addrs && addrs->other[0].name)
|
|
|
|
{
|
|
|
|
asection *lower_sect;
|
|
|
|
asection *sect;
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -905,14 +905,14 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
/* If this is the main symbol file we have to clean up all users of the
|
|
|
|
old main symbol file. Otherwise it is sufficient to fixup all the
|
|
|
|
breakpoints that may have been redefined by this symbol file. */
|
|
|
|
- if (mainline)
|
|
|
|
+ if (mainline == 1)
|
|
|
|
{
|
|
|
|
/* OK, make it the "real" symbol file. */
|
|
|
|
symfile_objfile = objfile;
|
|
|
|
|
|
|
|
clear_symtab_users ();
|
|
|
|
}
|
|
|
|
- else
|
|
|
|
+ else if (mainline == 0)
|
|
|
|
{
|
|
|
|
breakpoint_re_set ();
|
|
|
|
}
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -958,7 +958,7 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
interactively wiping out any existing symbols. */
|
|
|
|
|
|
|
|
if ((have_full_symbols () || have_partial_symbols ())
|
|
|
|
- && mainline
|
|
|
|
+ && mainline == 1
|
|
|
|
&& from_tty
|
|
|
|
&& !query ("Load new symbol table from \"%s\"? ", name))
|
|
|
|
error (_("Not confirmed."));
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -1138,6 +1138,11 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
symfile_objfile->name)
|
|
|
|
: !query (_("Discard symbol table? "))))
|
|
|
|
error (_("Not confirmed."));
|
|
|
|
+
|
|
|
|
+#ifdef CLEAR_SOLIB
|
|
|
|
+ CLEAR_SOLIB ();
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
free_all_objfiles ();
|
|
|
|
|
|
|
|
/* solib descriptors may have handles to objfiles. Since their
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -2277,6 +2282,8 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
/* Discard cleanups as symbol reading was successful. */
|
|
|
|
discard_cleanups (old_cleanups);
|
|
|
|
|
|
|
|
+ init_entry_point_info (objfile);
|
|
|
|
+
|
|
|
|
/* If the mtime has changed between the time we set new_modtime
|
|
|
|
and now, we *want* this to be out of date, so don't call stat
|
|
|
|
again now. */
|
2007-06-08 15:35:24 +00:00
|
|
|
@@ -2643,6 +2650,7 @@
|
|
|
|
set_default_breakpoint (0, 0, 0, 0);
|
2006-12-18 23:16:31 +00:00
|
|
|
clear_pc_function_cache ();
|
2007-06-08 15:35:24 +00:00
|
|
|
observer_notify_new_objfile (NULL);
|
2006-12-18 23:16:31 +00:00
|
|
|
+ varobj_refresh ();
|
|
|
|
|
|
|
|
/* Clear globals which might have pointed into a removed objfile.
|
|
|
|
FIXME: It's not clear which of these are supposed to persist
|
|
|
|
--- gdb/varobj.c
|
|
|
|
+++ gdb/varobj.c
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -1077,6 +1077,58 @@
|
|
|
|
return changed;
|
2006-12-18 23:16:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+void
|
|
|
|
+varobj_refresh (void)
|
|
|
|
+{
|
|
|
|
+ struct varobj *var;
|
|
|
|
+ struct varobj_root *croot;
|
|
|
|
+ int mycount = rootcount;
|
|
|
|
+ char * name;
|
|
|
|
+
|
|
|
|
+ croot = rootlist;
|
|
|
|
+ while (croot != NULL && mycount > 0)
|
|
|
|
+ {
|
|
|
|
+ var = croot->rootvar;
|
|
|
|
+
|
|
|
|
+ /* Get rid of the memory for the old expression. This also leaves
|
|
|
|
+ var->root->exp == NULL, which is ok for the parsing below. */
|
|
|
|
+ free_current_contents (&var->root->exp);
|
|
|
|
+
|
|
|
|
+ value_free (var->value);
|
|
|
|
+ var->type = NULL;
|
|
|
|
+
|
|
|
|
+ name = xstrdup (var->name);
|
|
|
|
+
|
|
|
|
+ /* Reparse the expression. Wrap the call to parse expression, so we
|
|
|
|
+ can return a sensible error. */
|
|
|
|
+ if (!gdb_parse_exp_1 (&name, var->root->valid_block, 0, &var->root->exp))
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ /* We definitively need to catch errors here. If
|
|
|
|
+ evaluate_expression succeeds we got the value we wanted. But if
|
|
|
|
+ it fails, we still go on with a call to evaluate_type. */
|
|
|
|
+ if (gdb_evaluate_expression (var->root->exp, &var->value))
|
|
|
|
+ {
|
|
|
|
+ /* no error */
|
|
|
|
+ release_value (var->value);
|
|
|
|
+ if (value_lazy (var->value))
|
|
|
|
+ gdb_value_fetch_lazy (var->value);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ var->value = evaluate_type (var->root->exp);
|
|
|
|
+
|
|
|
|
+ var->type = value_type (var->value);
|
|
|
|
+
|
|
|
|
+ mycount--;
|
|
|
|
+ croot = croot->next;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (mycount || croot != NULL)
|
|
|
|
+ warning
|
|
|
|
+ ("varobj_refresh: assertion failed - wrong tally of root vars (%d:%d)",
|
|
|
|
+ rootcount, mycount);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* Update the values for a variable and its children. This is a
|
|
|
|
two-pronged attack. First, re-parse the value for the root's
|
|
|
|
expression to see if it's changed. Then go all the way
|
|
|
|
--- gdb/varobj.h
|
|
|
|
+++ gdb/varobj.h
|
2007-05-11 14:39:13 +00:00
|
|
|
@@ -114,4 +114,6 @@
|
2006-12-18 23:16:31 +00:00
|
|
|
|
2007-05-11 14:39:13 +00:00
|
|
|
extern void varobj_invalidate (void);
|
2006-12-18 23:16:31 +00:00
|
|
|
|
|
|
|
+extern void varobj_refresh (void);
|
|
|
|
+
|
|
|
|
#endif /* VAROBJ_H */
|