* [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess
@ 2004-05-19 20:40 Randolph Chung
2004-05-19 21:37 ` Joel Brobecker
2004-05-21 18:48 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney
0 siblings, 2 replies; 20+ messages in thread
From: Randolph Chung @ 2004-05-19 20:40 UTC (permalink / raw)
To: gdb-patches
This patch introduces a new event that gets triggered when a new program
is being debugged. It then uses this to fix some FIXMEs in the hppa
tdep code, and remove some #ifdef HPUXHPPA's that are scattered in
arch-indep code. There is also one unrelated HPUXHPPA cleanup in
thread.c. The old code used to do:
#ifdef HPUXHPPA
printf_filtered ("%d %s", tp->num, target_tid_to_str (tp->ptid));
#else
printf_filtered ("%d %s", tp->num, target_pid_to_str (tp->ptid));
#endif
tm-hppah.h overrode target_tid_to_str to do it's own thing. The default
target.h definition checks to see if there's a target_tid_to_str define,
and if not automatically reverts to target_pid_to_str, so the #ifdef
here is useless.
Tested on hppa-linux and hppa2.0w-hp-hpux11.11 with no regressions.
Comments?
randolph
2004-05-18 Randolph Chung <tausq@debian.org>
* Makefile.in (hppa-hpux-tdep.o, hppa-tdep.o, symfile.o): Update
dependency.
* hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline): Use dyncall
and sr4export addresses from tdep structure.
(hppa_hpux_skip_trampoline_code): Likewise.
(hp_cxx_exception_support_initialized): Make static.
(hppa_hpux_observer_program_changed): New function; reset hp compiler
flags when new file is loaded.
(_initialize_hppa_hpux_tdep): Register for program change notification.
* hppa-linux-tdep.c (hppa_linux_in_dyncall): Use dyncall address from
tdep structure.
* hppa-tdep.c: Include observer.h
(hppa_observer_program_changed): New function; listen to program
change notification and update addresses in tdep structure.
(_initialize_hppa_tdep): Register for program change notification.
* hppa-tdep.h (struct gdbarch_tdep): Add dyncall, dyncall_external
and sr4export variables.
* symfile.c: Include observer.h, remove HPUXHPPA-specific code.
(symbol_file_add_main_1): Remove HPUXHPPA-specific code; notify
observers when a new symbol file has been loaded.
(symbol_file_clear, reread_symbols): Remove HPUXHPPA-specific code.
* thread.c (info_threads_command, thread_apply_all_command)
(thread_apply_command, thread_command, do_captured_thread_select):
Remove HPUXHPPA-specific code.
* doc/observer.texi (program_changed): Document new event.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.572
diff -u -p -r1.572 Makefile.in
--- Makefile.in 17 May 2004 15:16:39 -0000 1.572
+++ Makefile.in 19 May 2004 06:22:38 -0000
@@ -1829,12 +1829,12 @@ hppah-nat.o: hppah-nat.c $(defs_h) $(inf
$(gdb_wait_h) $(regcache_h) $(gdb_string_h) $(infttrace_h) \
$(hppa_tdep_h)
hppa-hpux-tdep.o: hppa-hpux-tdep.c $(defs_h) $(arch_utils_h) $(gdbcore_h) \
- $(osabi_h) $(gdb_string_h) $(frame_h) $(hppa_tdep_h)
+ $(osabi_h) $(gdb_string_h) $(frame_h) $(hppa_tdep_h) $(observer_h)
hppa-tdep.o: hppa-tdep.c $(defs_h) $(frame_h) $(bfd_h) $(inferior_h) \
$(regcache_h) $(completer_h) $(osabi_h) $(gdb_assert_h) \
$(arch_utils_h) $(symtab_h) $(dis_asm_h) $(trad_frame_h) \
$(frame_unwind_h) $(frame_base_h) $(gdbcore_h) $(gdbcmd_h) \
- $(symfile_h) $(objfiles_h) $(hppa_tdep_h)
+ $(symfile_h) $(objfiles_h) $(hppa_tdep_h) $(observer_h)
hppa-linux-tdep.o: hppa-linux-tdep.c $(defs_h) $(gdbcore_h) $(osabi_h) \
$(target_h) $(objfiles_h) $(solib_svr4_h) $(glibc_tdep_h) \
$(frame_unwind_h) $(trad_frame_h) $(dwarf2_frame_h) $(hppa_tdep_h) \
@@ -2430,7 +2430,7 @@ symfile.o: symfile.c $(defs_h) $(bfdlink
$(complaints_h) $(demangle_h) $(inferior_h) $(filenames_h) \
$(gdb_stabs_h) $(gdb_obstack_h) $(completer_h) $(bcache_h) \
$(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \
- $(gdb_string_h) $(gdb_stat_h)
+ $(gdb_string_h) $(gdb_stat_h) $(observer_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)
Index: hppa-hpux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-hpux-tdep.c,v
retrieving revision 1.18
diff -u -p -r1.18 hppa-hpux-tdep.c
--- hppa-hpux-tdep.c 7 May 2004 05:48:48 -0000 1.18
+++ hppa-hpux-tdep.c 19 May 2004 06:22:38 -0000
@@ -174,32 +174,12 @@ hppa32_hpux_in_solib_call_trampoline (CO
{
struct minimal_symbol *minsym;
struct unwind_table_entry *u;
- static CORE_ADDR dyncall = 0;
- static CORE_ADDR sr4export = 0;
+ struct gdbarch_tdep *tdep;
- /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a
- new exec file */
+ tdep = gdbarch_tdep (current_gdbarch);
/* First see if PC is in one of the two C-library trampolines. */
- if (!dyncall)
- {
- minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL);
- if (minsym)
- dyncall = SYMBOL_VALUE_ADDRESS (minsym);
- else
- dyncall = -1;
- }
-
- if (!sr4export)
- {
- minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL);
- if (minsym)
- sr4export = SYMBOL_VALUE_ADDRESS (minsym);
- else
- sr4export = -1;
- }
-
- if (pc == dyncall || pc == sr4export)
+ if (pc == tdep->dyncall || pc == tdep->sr4export)
return 1;
minsym = lookup_minimal_symbol_by_pc (pc);
@@ -408,45 +388,15 @@ hppa_hpux_skip_trampoline_code (CORE_ADD
{
long orig_pc = pc;
long prev_inst, curr_inst, loc;
- static CORE_ADDR dyncall = 0;
- static CORE_ADDR dyncall_external = 0;
- static CORE_ADDR sr4export = 0;
struct minimal_symbol *msym;
struct unwind_table_entry *u;
+ struct gdbarch_tdep *tdep;
- /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a
- new exec file */
-
- if (!dyncall)
- {
- msym = lookup_minimal_symbol ("$$dyncall", NULL, NULL);
- if (msym)
- dyncall = SYMBOL_VALUE_ADDRESS (msym);
- else
- dyncall = -1;
- }
-
- if (!dyncall_external)
- {
- msym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL);
- if (msym)
- dyncall_external = SYMBOL_VALUE_ADDRESS (msym);
- else
- dyncall_external = -1;
- }
-
- if (!sr4export)
- {
- msym = lookup_minimal_symbol ("_sr4export", NULL, NULL);
- if (msym)
- sr4export = SYMBOL_VALUE_ADDRESS (msym);
- else
- sr4export = -1;
- }
+ tdep = gdbarch_tdep (current_gdbarch);
/* Addresses passed to dyncall may *NOT* be the actual address
of the function. So we may have to do something special. */
- if (pc == dyncall)
+ if (pc == tdep->dyncall)
{
pc = (CORE_ADDR) read_register (22);
@@ -456,12 +406,12 @@ hppa_hpux_skip_trampoline_code (CORE_ADD
if (pc & 0x2)
pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8);
}
- if (pc == dyncall_external)
+ if (pc == tdep->dyncall_external)
{
pc = (CORE_ADDR) read_register (22);
pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8);
}
- else if (pc == sr4export)
+ else if (pc == tdep->sr4export)
pc = (CORE_ADDR) (read_register (22));
/* Get the unwind descriptor corresponding to PC, return zero
@@ -701,7 +651,7 @@ __eh_notification;
/* Is exception-handling support available with this executable? */
static int hp_cxx_exception_support = 0;
/* Has the initialize function been run? */
-int hp_cxx_exception_support_initialized = 0;
+static int hp_cxx_exception_support_initialized = 0;
/* Address of __eh_notify_hook */
static CORE_ADDR eh_notify_hook_addr = 0;
/* Address of __d_eh_notify_callback */
@@ -1257,6 +1207,18 @@ hppa_hpux_elf_init_abi (struct gdbarch_i
hppa_hpux_init_abi (info, gdbarch);
}
+static void
+hppa_hpux_observer_program_changed (const char *filename)
+{
+ /* Some HP-UX related globals to clear when a new "main"
+ symbol file is loaded. HP-specific. */
+
+ /* Indicates HP-compiled code. */
+ deprecated_hp_som_som_object_present = 0;
+ /* Must reinitialize exception stuff. */
+ hp_cxx_exception_support_initialized = 0;
+}
+
void
_initialize_hppa_hpux_tdep (void)
{
@@ -1264,4 +1226,6 @@ _initialize_hppa_hpux_tdep (void)
hppa_hpux_som_init_abi);
gdbarch_register_osabi (bfd_arch_hppa, bfd_mach_hppa20w, GDB_OSABI_HPUX_ELF,
hppa_hpux_elf_init_abi);
+ observer_attach_program_changed (hppa_hpux_observer_program_changed);
+
}
Index: hppa-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v
retrieving revision 1.5
diff -u -p -r1.5 hppa-linux-tdep.c
--- hppa-linux-tdep.c 8 May 2004 03:59:34 -0000 1.5
+++ hppa-linux-tdep.c 19 May 2004 06:22:38 -0000
@@ -161,21 +161,10 @@ insns_match_pattern (CORE_ADDR pc,
static int
hppa_linux_in_dyncall (CORE_ADDR pc)
{
- static CORE_ADDR dyncall = 0;
+ struct gdbarch_tdep *tdep;
+ tdep = gdbarch_tdep (current_gdbarch);
- /* FIXME: if we switch exec files, dyncall should be reinitialized */
- if (!dyncall)
- {
- struct minimal_symbol *minsym;
-
- minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL);
- if (minsym)
- dyncall = SYMBOL_VALUE_ADDRESS (minsym);
- else
- dyncall = -1;
- }
-
- return pc == dyncall;
+ return pc == tdep->dyncall;
}
/* There are several kinds of "trampolines" that we need to deal with:
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.162
diff -u -p -r1.162 hppa-tdep.c
--- hppa-tdep.c 19 May 2004 03:07:58 -0000 1.162
+++ hppa-tdep.c 19 May 2004 06:22:39 -0000
@@ -42,6 +42,7 @@
#include "gdbcore.h"
#include "gdbcmd.h"
#include "objfiles.h"
+#include "observer.h"
#include "hppa-tdep.h"
static int hppa_debug = 0;
@@ -2336,6 +2337,34 @@ hppa_frame_prev_register_helper (struct
extract_unsigned_integer (valuep, regsize) + 4);
}
+static void
+hppa_observer_program_changed (const char *filename)
+{
+ struct gdbarch_tdep *tdep;
+ struct minimal_symbol *minsym;
+
+ tdep = gdbarch_tdep (current_gdbarch);
+
+ minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL);
+ if (minsym)
+ tdep->dyncall = SYMBOL_VALUE_ADDRESS (minsym);
+ else
+ tdep->dyncall = -1;
+
+ /* These are HPUX only. */
+ minsym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL);
+ if (minsym)
+ tdep->dyncall_external = SYMBOL_VALUE_ADDRESS (minsym);
+ else
+ tdep->dyncall_external = -1;
+
+ minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL);
+ if (minsym)
+ tdep->sr4export = SYMBOL_VALUE_ADDRESS (minsym);
+ else
+ tdep->sr4export = -1;
+}
+
/* Here is a table of C type sizes on hppa with various compiles
and options. I measured this on PA 9000/800 with HP-UX 11.11
and these compilers:
@@ -2524,6 +2553,8 @@ _initialize_hppa_tdep (void)
gdbarch_register (bfd_arch_hppa, hppa_gdbarch_init, hppa_dump_tdep);
hppa_objfile_priv_data = register_objfile_data ();
+
+ observer_attach_program_changed (hppa_observer_program_changed);
add_cmd ("unwind", class_maintenance, unwind_command,
"Print unwind table entry at given address.",
Index: hppa-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.h,v
retrieving revision 1.9
diff -u -p -r1.9 hppa-tdep.h
--- hppa-tdep.h 16 May 2004 04:33:41 -0000 1.9
+++ hppa-tdep.h 19 May 2004 06:22:39 -0000
@@ -79,6 +79,12 @@ struct gdbarch_tdep
/* Is this an ELF target? This can be 64-bit HP-UX, or a 32/64-bit GNU/Linux
system. */
int is_elf;
+
+ /* Internal symbols that are needed for handling this target; the values
+ are reinitialized if the program being debug changes. */
+ CORE_ADDR dyncall;
+ CORE_ADDR dyncall_external;
+ CORE_ADDR sr4export;
};
/*
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.129
diff -u -p -r1.129 symfile.c
--- symfile.c 2 May 2004 10:14:01 -0000 1.129
+++ symfile.c 19 May 2004 06:22:41 -0000
@@ -48,6 +48,7 @@
#include "readline/readline.h"
#include "gdb_assert.h"
#include "block.h"
+#include "observer.h"
#include <sys/types.h>
#include <fcntl.h>
@@ -60,18 +61,6 @@
#define O_BINARY 0
#endif
-#ifdef HPUXHPPA
-
-/* Some HP-UX related globals to clear when a new "main"
- symbol file is loaded. HP-specific. */
-
-extern int hp_cxx_exception_support_initialized;
-#define RESET_HP_UX_GLOBALS() do {\
- deprecated_hp_som_som_object_present = 0; /* indicates HP-compiled code */ \
- hp_cxx_exception_support_initialized = 0; /* must reinitialize exception stuff */ \
- } while (0)
-#endif
-
int (*deprecated_ui_load_progress_hook) (const char *section, unsigned long num);
void (*deprecated_show_load_progress) (const char *section,
unsigned long section_sent,
@@ -957,15 +946,13 @@ symbol_file_add_main_1 (char *args, int
{
symbol_file_add (args, from_tty, NULL, 1, flags);
-#ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
-#endif
-
/* Getting new symbols may change our opinion about
what is frameless. */
reinit_frame_cache ();
set_initial_language ();
+
+ observer_notify_program_changed (args);
}
void
@@ -989,9 +976,6 @@ symbol_file_clear (int from_tty)
symfile_objfile = NULL;
if (from_tty)
printf_unfiltered ("No symbol file now.\n");
-#ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
-#endif
}
static char *
@@ -1944,9 +1928,6 @@ reread_symbols (void)
if (objfile == symfile_objfile)
{
(*objfile->sf->sym_new_init) (objfile);
-#ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
-#endif
}
(*objfile->sf->sym_init) (objfile);
Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.36
diff -u -p -r1.36 thread.c
--- thread.c 12 May 2004 22:19:02 -0000 1.36
+++ thread.c 19 May 2004 06:22:41 -0000
@@ -424,11 +424,7 @@ info_threads_command (char *arg, int fro
else
printf_filtered (" ");
-#ifdef HPUXHPPA
printf_filtered ("%d %s", tp->num, target_tid_to_str (tp->ptid));
-#else
- printf_filtered ("%d %s", tp->num, target_pid_to_str (tp->ptid));
-#endif
extra_info = target_extra_thread_info (tp);
if (extra_info)
@@ -541,13 +537,8 @@ thread_apply_all_command (char *cmd, int
if (thread_alive (tp))
{
switch_to_thread (tp->ptid);
-#ifdef HPUXHPPA
printf_filtered ("\nThread %d (%s):\n",
tp->num, target_tid_to_str (inferior_ptid));
-#else
- printf_filtered ("\nThread %d (%s):\n", tp->num,
- target_pid_to_str (inferior_ptid));
-#endif
execute_command (cmd, from_tty);
strcpy (cmd, saved_cmd); /* Restore exact command used previously */
}
@@ -617,13 +608,8 @@ thread_apply_command (char *tidlist, int
else
{
switch_to_thread (tp->ptid);
-#ifdef HPUXHPPA
printf_filtered ("\nThread %d (%s):\n", tp->num,
target_tid_to_str (inferior_ptid));
-#else
- printf_filtered ("\nThread %d (%s):\n", tp->num,
- target_pid_to_str (inferior_ptid));
-#endif
execute_command (cmd, from_tty);
strcpy (cmd, saved_cmd); /* Restore exact command used previously */
}
@@ -646,12 +632,7 @@ thread_command (char *tidstr, int from_t
if (target_has_stack)
printf_filtered ("[Current thread is %d (%s)]\n",
pid_to_thread_id (inferior_ptid),
-#if defined(HPUXHPPA)
- target_tid_to_str (inferior_ptid)
-#else
- target_pid_to_str (inferior_ptid)
-#endif
- );
+ target_tid_to_str (inferior_ptid));
else
error ("No stack.");
return;
@@ -681,11 +662,7 @@ do_captured_thread_select (struct ui_out
ui_out_text (uiout, "[Switching to thread ");
ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid));
ui_out_text (uiout, " (");
-#if defined(HPUXHPPA)
ui_out_text (uiout, target_tid_to_str (inferior_ptid));
-#else
- ui_out_text (uiout, target_pid_to_str (inferior_ptid));
-#endif
ui_out_text (uiout, ")]");
print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC);
Index: doc/observer.texi
===================================================================
RCS file: /cvs/src/src/gdb/doc/observer.texi,v
retrieving revision 1.6
diff -u -p -r1.6 observer.texi
--- doc/observer.texi 7 May 2004 22:51:55 -0000 1.6
+++ doc/observer.texi 19 May 2004 06:22:41 -0000
@@ -82,3 +82,7 @@ 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 program_changed (const char *@var{filename})
+The program being debugged has changed.
+@end deftypefun
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-19 20:40 [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Randolph Chung @ 2004-05-19 21:37 ` Joel Brobecker 2004-05-19 21:44 ` Randolph Chung 2004-05-21 18:48 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney 1 sibling, 1 reply; 20+ messages in thread From: Joel Brobecker @ 2004-05-19 21:37 UTC (permalink / raw) To: Randolph Chung; +Cc: gdb-patches Randolph, > * symfile.c: Include observer.h, remove HPUXHPPA-specific code. > (symbol_file_add_main_1): Remove HPUXHPPA-specific code; notify > observers when a new symbol file has been loaded. > (symbol_file_clear, reread_symbols): Remove HPUXHPPA-specific code. I think I'll also be needing the program_changed event for something else. However, I was about to place that event somewhere else. As far as I understand it, the gdb command to change the executable is ``exec-file''. That means you can change the executable without reloading the symbols, and hence trigger your notification. I was going to add the event at the begining of exec.c:exec_file_attach(). Would that work for you as well? -- Joel ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-19 21:37 ` Joel Brobecker @ 2004-05-19 21:44 ` Randolph Chung 2004-05-19 22:06 ` Joel Brobecker 0 siblings, 1 reply; 20+ messages in thread From: Randolph Chung @ 2004-05-19 21:44 UTC (permalink / raw) To: Joel Brobecker; +Cc: gdb-patches > I was going to add the event at the begining of exec.c:exec_file_attach(). > Would that work for you as well? exec_file_attach () seems to be called before the symbols are read into gdb. If so the lookups that I need to do will not work. Am I right? I can change the hppa code to do lazy init if we use this approach; just need to understand the semantics :) thanks, randolph -- Randolph Chung Debian GNU/Linux Developer, hppa/ia64 ports http://www.tausq.org/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-19 21:44 ` Randolph Chung @ 2004-05-19 22:06 ` Joel Brobecker 0 siblings, 0 replies; 20+ messages in thread From: Joel Brobecker @ 2004-05-19 22:06 UTC (permalink / raw) To: Randolph Chung; +Cc: gdb-patches > > I was going to add the event at the begining of exec.c:exec_file_attach(). > > Would that work for you as well? > > exec_file_attach () seems to be called before the symbols are read into > gdb. If so the lookups that I need to do will not work. Am I right? Yes you are right. I didn't look at your patch closely enough to see that you were going to do symbol lookups during the notification. > I can change the hppa code to do lazy init if we use this approach; > just need to understand the semantics :) I don't want to force you to take any approach. A signal at symbol file update is good too. However, could you in that case use a different name for the observer, I found it confusing since the notification is not necessarily emitted when the program has been changed. Something like program_symbols_changed? We'll have two observers instead of one: One for the executable changed, and one for the program symbols changed. I don't know what the other maintainers will think about this? -- Joel ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess 2004-05-19 20:40 [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Randolph Chung 2004-05-19 21:37 ` Joel Brobecker @ 2004-05-21 18:48 ` Andrew Cagney 2004-05-21 19:02 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Randolph Chung 2004-05-24 15:45 ` Randolph Chung 1 sibling, 2 replies; 20+ messages in thread From: Andrew Cagney @ 2004-05-21 18:48 UTC (permalink / raw) To: Randolph Chung; +Cc: gdb-patches This patch introduces a new event that gets triggered when a new program is being debugged. It then uses this to fix some FIXMEs in the hppa tdep code, and remove some #ifdef HPUXHPPA's that are scattered in arch-indep code. Have a look at the new inferior_created event (it sounds similar). The code to wire it in is in my post ``Wire up vsyscall''. http://sources.redhat.com/ml/gdb-patches/2004-05/msg00169.html BTW, what's the underlying problem? There is also one unrelated HPUXHPPA cleanup in thread.c. The old code used to do: #ifdef HPUXHPPA printf_filtered ("%d %s", tp->num, target_tid_to_str (tp->ptid)); #else printf_filtered ("%d %s", tp->num, target_pid_to_str (tp->ptid)); #endif tm-hppah.h overrode target_tid_to_str to do it's own thing. The default target.h definition checks to see if there's a target_tid_to_str define, and if not automatically reverts to target_pid_to_str, so the #ifdef here is useless. Can you separate this part out (it sounds very straight forward). Tested on hppa-linux and hppa2.0w-hp-hpux11.11 with no regressions. Andrew ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-21 18:48 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney @ 2004-05-21 19:02 ` Randolph Chung [not found] ` <40AE6260.2090205@gnu.org> 2004-05-24 15:45 ` Randolph Chung 1 sibling, 1 reply; 20+ messages in thread From: Randolph Chung @ 2004-05-21 19:02 UTC (permalink / raw) To: Andrew Cagney; +Cc: gdb-patches > Have a look at the new inferior_created event (it sounds similar). The > code to wire it in is in my post ``Wire up vsyscall''. > http://sources.redhat.com/ml/gdb-patches/2004-05/msg00169.html > > BTW, what's the underlying problem? the hppa target code caches some symbolic values for some stub functions and uses those during unwinding operations (e.g. $$dyncall). So if the inferior changes, we need to update the cached values. assuming the attach case also works, this should be ok for what i need. > Can you separate this part out (it sounds very straight forward). will do. randolph -- Randolph Chung Debian GNU/Linux Developer, hppa/ia64 ports http://www.tausq.org/ ^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <40AE6260.2090205@gnu.org>]
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess [not found] ` <40AE6260.2090205@gnu.org> @ 2004-05-26 5:27 ` Randolph Chung 2004-05-26 13:25 ` Daniel Jacobowitz 0 siblings, 1 reply; 20+ messages in thread From: Randolph Chung @ 2004-05-26 5:27 UTC (permalink / raw) To: Andrew Cagney; +Cc: gdb-patches > >assuming the attach case also works, this should be ok for what i need. > > That code was added for a similar problem so it looks hopeful. seems to be ok. here's the new version, using the inferior_created event you checked in. still passes all the tests that used to pass before :) ok to checkin? randolph 2004-05-25 Randolph Chung <tausq@debian.org> * Makefile.in (hppa-hpux-tdep.o, hppa-tdep.o): Update dependency. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline): Use dyncall and sr4export addresses from tdep structure. (hppa_hpux_skip_trampoline_code): Likewise. (hp_cxx_exception_support_initialized): Make static. (hppa_hpux_observer_inferior_created): New function; reset hp compiler flags when new inferior is created. (_initialize_hppa_hpux_tdep): Register for inferior created notification. * hppa-linux-tdep.c (hppa_linux_in_dyncall): Use dyncall address from tdep structure. * hppa-tdep.c: Include observer.h (hppa_observer_inferior_created): New function; listen to inferior created notification and update addresses in tdep structure. (_initialize_hppa_tdep): Register for program change notification. * hppa-tdep.h (struct gdbarch_tdep): Add dyncall, dyncall_external and sr4export variables. * symfile.c: (RESET_HP_UX_GLOBALS) Remove HPUXHPPA-specific code. (symbol_file_add_main_1): Remove HPUXHPPA-specific code; notify observers when a new symbol file has been loaded. (symbol_file_clear, reread_symbols): Remove HPUXHPPA-specific code. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.580 diff -u -p -r1.580 Makefile.in --- Makefile.in 25 May 2004 21:55:43 -0000 1.580 +++ Makefile.in 26 May 2004 05:22:52 -0000 @@ -1833,12 +1833,12 @@ hppah-nat.o: hppah-nat.c $(defs_h) $(inf $(gdb_wait_h) $(regcache_h) $(gdb_string_h) $(infttrace_h) \ $(hppa_tdep_h) hppa-hpux-tdep.o: hppa-hpux-tdep.c $(defs_h) $(arch_utils_h) $(gdbcore_h) \ - $(osabi_h) $(gdb_string_h) $(frame_h) $(hppa_tdep_h) + $(osabi_h) $(gdb_string_h) $(frame_h) $(hppa_tdep_h) $(observer_h) hppa-tdep.o: hppa-tdep.c $(defs_h) $(frame_h) $(bfd_h) $(inferior_h) \ $(regcache_h) $(completer_h) $(osabi_h) $(gdb_assert_h) \ $(arch_utils_h) $(symtab_h) $(dis_asm_h) $(trad_frame_h) \ $(frame_unwind_h) $(frame_base_h) $(gdbcore_h) $(gdbcmd_h) \ - $(symfile_h) $(objfiles_h) $(hppa_tdep_h) + $(symfile_h) $(objfiles_h) $(hppa_tdep_h) $(observer_h) hppa-linux-tdep.o: hppa-linux-tdep.c $(defs_h) $(gdbcore_h) $(osabi_h) \ $(target_h) $(objfiles_h) $(solib_svr4_h) $(glibc_tdep_h) \ $(frame_unwind_h) $(trad_frame_h) $(dwarf2_frame_h) $(hppa_tdep_h) \ Index: hppa-hpux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-hpux-tdep.c,v retrieving revision 1.18 diff -u -p -r1.18 hppa-hpux-tdep.c --- hppa-hpux-tdep.c 7 May 2004 05:48:48 -0000 1.18 +++ hppa-hpux-tdep.c 26 May 2004 04:10:53 -0000 @@ -174,32 +174,12 @@ hppa32_hpux_in_solib_call_trampoline (CO { struct minimal_symbol *minsym; struct unwind_table_entry *u; - static CORE_ADDR dyncall = 0; - static CORE_ADDR sr4export = 0; + struct gdbarch_tdep *tdep; - /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a - new exec file */ + tdep = gdbarch_tdep (current_gdbarch); /* First see if PC is in one of the two C-library trampolines. */ - if (!dyncall) - { - minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); - if (minsym) - dyncall = SYMBOL_VALUE_ADDRESS (minsym); - else - dyncall = -1; - } - - if (!sr4export) - { - minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); - if (minsym) - sr4export = SYMBOL_VALUE_ADDRESS (minsym); - else - sr4export = -1; - } - - if (pc == dyncall || pc == sr4export) + if (pc == tdep->dyncall || pc == tdep->sr4export) return 1; minsym = lookup_minimal_symbol_by_pc (pc); @@ -408,45 +388,15 @@ hppa_hpux_skip_trampoline_code (CORE_ADD { long orig_pc = pc; long prev_inst, curr_inst, loc; - static CORE_ADDR dyncall = 0; - static CORE_ADDR dyncall_external = 0; - static CORE_ADDR sr4export = 0; struct minimal_symbol *msym; struct unwind_table_entry *u; + struct gdbarch_tdep *tdep; - /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a - new exec file */ - - if (!dyncall) - { - msym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); - if (msym) - dyncall = SYMBOL_VALUE_ADDRESS (msym); - else - dyncall = -1; - } - - if (!dyncall_external) - { - msym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); - if (msym) - dyncall_external = SYMBOL_VALUE_ADDRESS (msym); - else - dyncall_external = -1; - } - - if (!sr4export) - { - msym = lookup_minimal_symbol ("_sr4export", NULL, NULL); - if (msym) - sr4export = SYMBOL_VALUE_ADDRESS (msym); - else - sr4export = -1; - } + tdep = gdbarch_tdep (current_gdbarch); /* Addresses passed to dyncall may *NOT* be the actual address of the function. So we may have to do something special. */ - if (pc == dyncall) + if (pc == tdep->dyncall) { pc = (CORE_ADDR) read_register (22); @@ -456,12 +406,12 @@ hppa_hpux_skip_trampoline_code (CORE_ADD if (pc & 0x2) pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8); } - if (pc == dyncall_external) + if (pc == tdep->dyncall_external) { pc = (CORE_ADDR) read_register (22); pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8); } - else if (pc == sr4export) + else if (pc == tdep->sr4export) pc = (CORE_ADDR) (read_register (22)); /* Get the unwind descriptor corresponding to PC, return zero @@ -1257,6 +1207,18 @@ hppa_hpux_elf_init_abi (struct gdbarch_i hppa_hpux_init_abi (info, gdbarch); } +static void +hppa_hpux_observer_inferior_created (struct target_ops *objfile, int from_tty) +{ + /* Some HP-UX related globals to clear when a new "main" + symbol file is loaded. HP-specific. */ + + /* Indicates HP-compiled code. */ + deprecated_hp_som_som_object_present = 0; + /* Must reinitialize exception stuff. */ + hp_cxx_exception_support_initialized = 0; +} + void _initialize_hppa_hpux_tdep (void) { @@ -1264,4 +1226,6 @@ _initialize_hppa_hpux_tdep (void) hppa_hpux_som_init_abi); gdbarch_register_osabi (bfd_arch_hppa, bfd_mach_hppa20w, GDB_OSABI_HPUX_ELF, hppa_hpux_elf_init_abi); + observer_attach_inferior_created (hppa_hpux_observer_inferior_created); + } Index: hppa-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v retrieving revision 1.5 diff -u -p -r1.5 hppa-linux-tdep.c --- hppa-linux-tdep.c 8 May 2004 03:59:34 -0000 1.5 +++ hppa-linux-tdep.c 26 May 2004 04:10:54 -0000 @@ -161,21 +164,10 @@ insns_match_pattern (CORE_ADDR pc, static int hppa_linux_in_dyncall (CORE_ADDR pc) { - static CORE_ADDR dyncall = 0; - - /* FIXME: if we switch exec files, dyncall should be reinitialized */ - if (!dyncall) - { - struct minimal_symbol *minsym; + struct gdbarch_tdep *tdep; + tdep = gdbarch_tdep (current_gdbarch); - minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); - if (minsym) - dyncall = SYMBOL_VALUE_ADDRESS (minsym); - else - dyncall = -1; - } - - return pc == dyncall; + return pc == tdep->dyncall; } /* There are several kinds of "trampolines" that we need to deal with: Index: hppa-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-tdep.c,v retrieving revision 1.165 diff -u -p -r1.165 hppa-tdep.c --- hppa-tdep.c 26 May 2004 04:02:24 -0000 1.165 +++ hppa-tdep.c 26 May 2004 04:10:54 -0000 @@ -42,6 +42,7 @@ #include "gdbcore.h" #include "gdbcmd.h" #include "objfiles.h" +#include "observer.h" #include "hppa-tdep.h" static int hppa_debug = 0; @@ -2331,6 +2371,34 @@ hppa_frame_prev_register_helper (struct extract_unsigned_integer (valuep, regsize) + 4); } +static void +hppa_observer_inferior_created (struct target_ops *objfile, int from_tty) +{ + struct gdbarch_tdep *tdep; + struct minimal_symbol *minsym; + + tdep = gdbarch_tdep (current_gdbarch); + + minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); + if (minsym) + tdep->dyncall = SYMBOL_VALUE_ADDRESS (minsym); + else + tdep->dyncall = -1; + + /* These are HPUX only. */ + minsym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); + if (minsym) + tdep->dyncall_external = SYMBOL_VALUE_ADDRESS (minsym); + else + tdep->dyncall_external = -1; + + minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); + if (minsym) + tdep->sr4export = SYMBOL_VALUE_ADDRESS (minsym); + else + tdep->sr4export = -1; +} + /* Here is a table of C type sizes on hppa with various compiles and options. I measured this on PA 9000/800 with HP-UX 11.11 and these compilers: @@ -2520,6 +2592,8 @@ _initialize_hppa_tdep (void) hppa_objfile_priv_data = register_objfile_data (); + observer_attach_inferior_created (hppa_observer_inferior_created); + add_cmd ("unwind", class_maintenance, unwind_command, "Print unwind table entry at given address.", &maintenanceprintlist); Index: hppa-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/hppa-tdep.h,v retrieving revision 1.10 diff -u -p -r1.10 hppa-tdep.h --- hppa-tdep.h 25 May 2004 03:55:23 -0000 1.10 +++ hppa-tdep.h 26 May 2004 04:10:54 -0000 @@ -77,6 +78,12 @@ struct gdbarch_tdep /* Is this an ELF target? This can be 64-bit HP-UX, or a 32/64-bit GNU/Linux system. */ int is_elf; + + /* Internal symbols that are needed for handling this target; the values + are reinitialized if the program being debug changes. */ + CORE_ADDR dyncall; + CORE_ADDR dyncall_external; + CORE_ADDR sr4export; }; /* Index: symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.130 diff -u -p -r1.130 symfile.c --- symfile.c 20 May 2004 09:51:33 -0000 1.130 +++ symfile.c 26 May 2004 04:10:57 -0000 @@ -60,18 +61,6 @@ #define O_BINARY 0 #endif -#ifdef HPUXHPPA - -/* Some HP-UX related globals to clear when a new "main" - symbol file is loaded. HP-specific. */ - -extern int hp_cxx_exception_support_initialized; -#define RESET_HP_UX_GLOBALS() do {\ - deprecated_hp_som_som_object_present = 0; /* indicates HP-compiled code */ \ - hp_cxx_exception_support_initialized = 0; /* must reinitialize exception stuff */ \ - } while (0) -#endif - int (*deprecated_ui_load_progress_hook) (const char *section, unsigned long num); void (*deprecated_show_load_progress) (const char *section, unsigned long section_sent, @@ -989,9 +978,6 @@ symbol_file_clear (int from_tty) symfile_objfile = NULL; if (from_tty) printf_unfiltered ("No symbol file now.\n"); -#ifdef HPUXHPPA - RESET_HP_UX_GLOBALS (); -#endif } static char * @@ -1944,9 +1930,6 @@ reread_symbols (void) if (objfile == symfile_objfile) { (*objfile->sf->sym_new_init) (objfile); -#ifdef HPUXHPPA - RESET_HP_UX_GLOBALS (); -#endif } (*objfile->sf->sym_init) (objfile); ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-26 5:27 ` Randolph Chung @ 2004-05-26 13:25 ` Daniel Jacobowitz 2004-05-26 15:35 ` Randolph Chung 0 siblings, 1 reply; 20+ messages in thread From: Daniel Jacobowitz @ 2004-05-26 13:25 UTC (permalink / raw) To: Randolph Chung; +Cc: Andrew Cagney, gdb-patches On Tue, May 25, 2004 at 10:27:53PM -0700, Randolph Chung wrote: > > >assuming the attach case also works, this should be ok for what i need. > > > > That code was added for a similar problem so it looks hopeful. > > seems to be ok. here's the new version, using the inferior_created > event you checked in. still passes all the tests that used to pass > before :) > > ok to checkin? Almost, just one thing I'd like you to fix. > +static void > +hppa_observer_inferior_created (struct target_ops *objfile, int from_tty) > +{ > + struct gdbarch_tdep *tdep; > + struct minimal_symbol *minsym; > + > + tdep = gdbarch_tdep (current_gdbarch); > + > + minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); > + if (minsym) > + tdep->dyncall = SYMBOL_VALUE_ADDRESS (minsym); > + else > + tdep->dyncall = -1; > + > + /* These are HPUX only. */ If this comment is right, why not move these to the hppa-hpux specific observer? If the comment is wrong, just remove it, but it looks right. > + minsym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); > + if (minsym) > + tdep->dyncall_external = SYMBOL_VALUE_ADDRESS (minsym); > + else > + tdep->dyncall_external = -1; > + > + minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); > + if (minsym) > + tdep->sr4export = SYMBOL_VALUE_ADDRESS (minsym); > + else > + tdep->sr4export = -1; > +} -- Daniel Jacobowitz ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-26 13:25 ` Daniel Jacobowitz @ 2004-05-26 15:35 ` Randolph Chung 2004-05-26 16:48 ` Daniel Jacobowitz 2004-05-26 17:54 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney 0 siblings, 2 replies; 20+ messages in thread From: Randolph Chung @ 2004-05-26 15:35 UTC (permalink / raw) To: Andrew Cagney, gdb-patches > If this comment is right, why not move these to the hppa-hpux specific > observer? If the comment is wrong, just remove it, but it looks right. ok. like this? randolph 2004-05-26 Randolph Chung <tausq@debian.org> * Makefile.in (hppa-hpux-tdep.o, hppa-tdep.o): Update dependency. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline): Use dyncall and sr4export addresses from tdep structure. (hppa_hpux_skip_trampoline_code): Likewise. (hp_cxx_exception_support_initialized): Make static. (hppa_hpux_observer_inferior_created): New function; reset hp compiler flags and cached symbols when new inferior is created. (_initialize_hppa_hpux_tdep): Register for inferior created notification. * hppa-linux-tdep.c (hppa_linux_in_dyncall): Use dyncall address from tdep structure. * hppa-tdep.c: Include observer.h (hppa_observer_inferior_created): New function; listen to inferior created notification and update addresses in tdep structure. (_initialize_hppa_tdep): Register for program change notification. * hppa-tdep.h (struct gdbarch_tdep): Add dyncall, dyncall_external and sr4export variables. * symfile.c: (RESET_HP_UX_GLOBALS) Remove HPUXHPPA-specific code. (symbol_file_add_main_1, symbol_file_clear, reread_symbols): Remove HPUXHPPA-specific code. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.581 diff -u -p -r1.581 Makefile.in --- Makefile.in 26 May 2004 05:31:39 -0000 1.581 +++ Makefile.in 26 May 2004 15:24:08 -0000 @@ -1835,12 +1835,12 @@ hppah-nat.o: hppah-nat.c $(defs_h) $(inf hppa-hpux-tdep.o: hppa-hpux-tdep.c $(defs_h) $(arch_utils_h) $(gdbcore_h) \ $(osabi_h) $(gdb_string_h) $(frame_h) $(frame_unwind_h) \ $(trad_frame_h) $(symtab_h) $(objfiles_h) $(inferior_h) $(infcall_h) \ - $(hppa_tdep_h) + $(hppa_tdep_h) $(observer_h) hppa-tdep.o: hppa-tdep.c $(defs_h) $(frame_h) $(bfd_h) $(inferior_h) \ $(regcache_h) $(completer_h) $(osabi_h) $(gdb_assert_h) \ $(arch_utils_h) $(symtab_h) $(dis_asm_h) $(trad_frame_h) \ $(frame_unwind_h) $(frame_base_h) $(gdbcore_h) $(gdbcmd_h) \ - $(symfile_h) $(objfiles_h) $(hppa_tdep_h) + $(symfile_h) $(objfiles_h) $(hppa_tdep_h) $(observer_h) hppa-linux-tdep.o: hppa-linux-tdep.c $(defs_h) $(gdbcore_h) $(osabi_h) \ $(target_h) $(objfiles_h) $(solib_svr4_h) $(glibc_tdep_h) \ $(frame_unwind_h) $(trad_frame_h) $(dwarf2_frame_h) $(hppa_tdep_h) \ Index: hppa-hpux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-hpux-tdep.c,v retrieving revision 1.19 diff -u -p -r1.19 hppa-hpux-tdep.c --- hppa-hpux-tdep.c 26 May 2004 05:31:39 -0000 1.19 +++ hppa-hpux-tdep.c 26 May 2004 15:24:10 -0000 @@ -61,32 +61,12 @@ hppa32_hpux_in_solib_call_trampoline (CO { struct minimal_symbol *minsym; struct unwind_table_entry *u; - static CORE_ADDR dyncall = 0; - static CORE_ADDR sr4export = 0; + struct gdbarch_tdep *tdep; - /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a - new exec file */ + tdep = gdbarch_tdep (current_gdbarch); /* First see if PC is in one of the two C-library trampolines. */ - if (!dyncall) - { - minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); - if (minsym) - dyncall = SYMBOL_VALUE_ADDRESS (minsym); - else - dyncall = -1; - } - - if (!sr4export) - { - minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); - if (minsym) - sr4export = SYMBOL_VALUE_ADDRESS (minsym); - else - sr4export = -1; - } - - if (pc == dyncall || pc == sr4export) + if (pc == tdep->dyncall || pc == tdep->sr4export) return 1; minsym = lookup_minimal_symbol_by_pc (pc); @@ -295,45 +275,15 @@ hppa_hpux_skip_trampoline_code (CORE_ADD { long orig_pc = pc; long prev_inst, curr_inst, loc; - static CORE_ADDR dyncall = 0; - static CORE_ADDR dyncall_external = 0; - static CORE_ADDR sr4export = 0; struct minimal_symbol *msym; struct unwind_table_entry *u; + struct gdbarch_tdep *tdep; - /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a - new exec file */ - - if (!dyncall) - { - msym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); - if (msym) - dyncall = SYMBOL_VALUE_ADDRESS (msym); - else - dyncall = -1; - } - - if (!dyncall_external) - { - msym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); - if (msym) - dyncall_external = SYMBOL_VALUE_ADDRESS (msym); - else - dyncall_external = -1; - } - - if (!sr4export) - { - msym = lookup_minimal_symbol ("_sr4export", NULL, NULL); - if (msym) - sr4export = SYMBOL_VALUE_ADDRESS (msym); - else - sr4export = -1; - } + tdep = gdbarch_tdep (current_gdbarch); /* Addresses passed to dyncall may *NOT* be the actual address of the function. So we may have to do something special. */ - if (pc == dyncall) + if (pc == tdep->dyncall) { pc = (CORE_ADDR) read_register (22); @@ -343,12 +293,12 @@ hppa_hpux_skip_trampoline_code (CORE_ADD if (pc & 0x2) pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8); } - if (pc == dyncall_external) + if (pc == tdep->dyncall_external) { pc = (CORE_ADDR) read_register (22); pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8); } - else if (pc == sr4export) + else if (pc == tdep->sr4export) pc = (CORE_ADDR) (read_register (22)); /* Get the unwind descriptor corresponding to PC, return zero @@ -1295,6 +1245,35 @@ hppa_hpux_elf_init_abi (struct gdbarch_i hppa_hpux_init_abi (info, gdbarch); } +static void +hppa_hpux_observer_inferior_created (struct target_ops *objfile, int from_tty) +{ + struct gdbarch_tdep *tdep; + struct minimal_symbol *minsym; + + tdep = gdbarch_tdep (current_gdbarch); + + /* Some HP-UX related globals to clear when a new "main" + symbol file is loaded. HP-specific. */ + + /* Indicates HP-compiled code. */ + deprecated_hp_som_som_object_present = 0; + /* Must reinitialize exception stuff. */ + hp_cxx_exception_support_initialized = 0; + + minsym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); + if (minsym) + tdep->dyncall_external = SYMBOL_VALUE_ADDRESS (minsym); + else + tdep->dyncall_external = -1; + + minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); + if (minsym) + tdep->sr4export = SYMBOL_VALUE_ADDRESS (minsym); + else + tdep->sr4export = -1; +} + void _initialize_hppa_hpux_tdep (void) { @@ -1302,4 +1281,5 @@ _initialize_hppa_hpux_tdep (void) hppa_hpux_som_init_abi); gdbarch_register_osabi (bfd_arch_hppa, bfd_mach_hppa20w, GDB_OSABI_HPUX_ELF, hppa_hpux_elf_init_abi); + observer_attach_inferior_created (hppa_hpux_observer_inferior_created); } Index: hppa-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v retrieving revision 1.5 diff -u -p -r1.5 hppa-linux-tdep.c --- hppa-linux-tdep.c 8 May 2004 03:59:34 -0000 1.5 +++ hppa-linux-tdep.c 26 May 2004 15:24:10 -0000 @@ -161,21 +164,10 @@ insns_match_pattern (CORE_ADDR pc, static int hppa_linux_in_dyncall (CORE_ADDR pc) { - static CORE_ADDR dyncall = 0; - - /* FIXME: if we switch exec files, dyncall should be reinitialized */ - if (!dyncall) - { - struct minimal_symbol *minsym; + struct gdbarch_tdep *tdep; + tdep = gdbarch_tdep (current_gdbarch); - minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); - if (minsym) - dyncall = SYMBOL_VALUE_ADDRESS (minsym); - else - dyncall = -1; - } - - return pc == dyncall; + return pc == tdep->dyncall; } /* There are several kinds of "trampolines" that we need to deal with: Index: hppa-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-tdep.c,v retrieving revision 1.165 diff -u -p -r1.165 hppa-tdep.c --- hppa-tdep.c 26 May 2004 04:02:24 -0000 1.165 +++ hppa-tdep.c 26 May 2004 15:24:12 -0000 @@ -42,6 +42,7 @@ #include "gdbcore.h" #include "gdbcmd.h" #include "objfiles.h" +#include "observer.h" #include "hppa-tdep.h" static int hppa_debug = 0; @@ -2331,6 +2371,21 @@ hppa_frame_prev_register_helper (struct extract_unsigned_integer (valuep, regsize) + 4); } +static void +hppa_observer_inferior_created (struct target_ops *objfile, int from_tty) +{ + struct gdbarch_tdep *tdep; + struct minimal_symbol *minsym; + + tdep = gdbarch_tdep (current_gdbarch); + + minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); + if (minsym) + tdep->dyncall = SYMBOL_VALUE_ADDRESS (minsym); + else + tdep->dyncall = -1; +} + /* Here is a table of C type sizes on hppa with various compiles and options. I measured this on PA 9000/800 with HP-UX 11.11 and these compilers: @@ -2520,6 +2579,8 @@ _initialize_hppa_tdep (void) hppa_objfile_priv_data = register_objfile_data (); + observer_attach_inferior_created (hppa_observer_inferior_created); + add_cmd ("unwind", class_maintenance, unwind_command, "Print unwind table entry at given address.", &maintenanceprintlist); Index: hppa-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/hppa-tdep.h,v retrieving revision 1.10 diff -u -p -r1.10 hppa-tdep.h --- hppa-tdep.h 25 May 2004 03:55:23 -0000 1.10 +++ hppa-tdep.h 26 May 2004 15:24:12 -0000 @@ -77,6 +78,12 @@ struct gdbarch_tdep /* Is this an ELF target? This can be 64-bit HP-UX, or a 32/64-bit GNU/Linux system. */ int is_elf; + + /* Internal symbols that are needed for handling this target; the values + are reinitialized if the program being debug changes. */ + CORE_ADDR dyncall; + CORE_ADDR dyncall_external; + CORE_ADDR sr4export; }; /* Index: symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.130 diff -u -p -r1.130 symfile.c --- symfile.c 20 May 2004 09:51:33 -0000 1.130 +++ symfile.c 26 May 2004 15:24:13 -0000 @@ -60,18 +60,6 @@ #define O_BINARY 0 #endif -#ifdef HPUXHPPA - -/* Some HP-UX related globals to clear when a new "main" - symbol file is loaded. HP-specific. */ - -extern int hp_cxx_exception_support_initialized; -#define RESET_HP_UX_GLOBALS() do {\ - deprecated_hp_som_som_object_present = 0; /* indicates HP-compiled code */ \ - hp_cxx_exception_support_initialized = 0; /* must reinitialize exception stuff */ \ - } while (0) -#endif - int (*deprecated_ui_load_progress_hook) (const char *section, unsigned long num); void (*deprecated_show_load_progress) (const char *section, unsigned long section_sent, @@ -957,10 +945,6 @@ symbol_file_add_main_1 (char *args, int { symbol_file_add (args, from_tty, NULL, 1, flags); -#ifdef HPUXHPPA - RESET_HP_UX_GLOBALS (); -#endif - /* Getting new symbols may change our opinion about what is frameless. */ reinit_frame_cache (); @@ -989,9 +973,6 @@ symbol_file_clear (int from_tty) symfile_objfile = NULL; if (from_tty) printf_unfiltered ("No symbol file now.\n"); -#ifdef HPUXHPPA - RESET_HP_UX_GLOBALS (); -#endif } static char * @@ -1944,9 +1925,6 @@ reread_symbols (void) if (objfile == symfile_objfile) { (*objfile->sf->sym_new_init) (objfile); -#ifdef HPUXHPPA - RESET_HP_UX_GLOBALS (); -#endif } (*objfile->sf->sym_init) (objfile); -- Randolph Chung Debian GNU/Linux Developer, hppa/ia64 ports http://www.tausq.org/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-26 15:35 ` Randolph Chung @ 2004-05-26 16:48 ` Daniel Jacobowitz 2004-05-26 17:54 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney 1 sibling, 0 replies; 20+ messages in thread From: Daniel Jacobowitz @ 2004-05-26 16:48 UTC (permalink / raw) To: Randolph Chung; +Cc: Andrew Cagney, gdb-patches On Wed, May 26, 2004 at 08:35:30AM -0700, Randolph Chung wrote: > > If this comment is right, why not move these to the hppa-hpux specific > > observer? If the comment is wrong, just remove it, but it looks right. > > ok. like this? Yeah, this is OK. Thanks. > > randolph > > 2004-05-26 Randolph Chung <tausq@debian.org> > > * Makefile.in (hppa-hpux-tdep.o, hppa-tdep.o): Update dependency. > * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline): Use dyncall > and sr4export addresses from tdep structure. > (hppa_hpux_skip_trampoline_code): Likewise. > (hp_cxx_exception_support_initialized): Make static. > (hppa_hpux_observer_inferior_created): New function; reset hp compiler > flags and cached symbols when new inferior is created. > (_initialize_hppa_hpux_tdep): Register for inferior created > notification. > * hppa-linux-tdep.c (hppa_linux_in_dyncall): Use dyncall address from > tdep structure. > * hppa-tdep.c: Include observer.h > (hppa_observer_inferior_created): New function; listen to inferior > created notification and update addresses in tdep structure. > (_initialize_hppa_tdep): Register for program change notification. > * hppa-tdep.h (struct gdbarch_tdep): Add dyncall, dyncall_external > and sr4export variables. > * symfile.c: (RESET_HP_UX_GLOBALS) Remove HPUXHPPA-specific code. > (symbol_file_add_main_1, symbol_file_clear, reread_symbols): Remove > HPUXHPPA-specific code. -- Daniel Jacobowitz ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess 2004-05-26 15:35 ` Randolph Chung 2004-05-26 16:48 ` Daniel Jacobowitz @ 2004-05-26 17:54 ` Andrew Cagney 2004-05-28 23:43 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Daniel Jacobowitz 1 sibling, 1 reply; 20+ messages in thread From: Andrew Cagney @ 2004-05-26 17:54 UTC (permalink / raw) To: Randolph Chung; +Cc: gdb-patches +static void +hppa_hpux_observer_inferior_created (struct target_ops *objfile, int from_tty) +{ + struct gdbarch_tdep *tdep; + struct minimal_symbol *minsym; + + tdep = gdbarch_tdep (current_gdbarch); + + /* Some HP-UX related globals to clear when a new "main" + symbol file is loaded. HP-specific. */ + + /* Indicates HP-compiled code. */ + deprecated_hp_som_som_object_present = 0; + /* Must reinitialize exception stuff. */ + hp_cxx_exception_support_initialized = 0; + + minsym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); + if (minsym) + tdep->dyncall_external = SYMBOL_VALUE_ADDRESS (minsym); + else + tdep->dyncall_external = -1; + + minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); + if (minsym) + tdep->sr4export = SYMBOL_VALUE_ADDRESS (minsym); + else + tdep->sr4export = -1; +} Unfortunatly, not really but as you've noticed, it does ``work'', sigh. At least we can now see what the code is doing. The above values are dependant on the inferior (and make change between inferior invocations) and not the architecture so their lifetime should be bound to the inferior. This patch binds them to the current ``global'' architecture :-( Can, for the immediate term, hppa_hpux_skip_trampoline_code be simplified so that it doesn't even try to cache these values? This will put a real strain on the symtab but I think its the symtab that is the place that needs the fix. Andrew ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-26 17:54 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney @ 2004-05-28 23:43 ` Daniel Jacobowitz 2004-05-31 19:43 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney 0 siblings, 1 reply; 20+ messages in thread From: Daniel Jacobowitz @ 2004-05-28 23:43 UTC (permalink / raw) To: Andrew Cagney; +Cc: Randolph Chung, gdb-patches On Wed, May 26, 2004 at 01:54:30PM -0400, Andrew Cagney wrote: > >+static void > >+hppa_hpux_observer_inferior_created (struct target_ops *objfile, int > >from_tty) > >+{ > >+ struct gdbarch_tdep *tdep; > >+ struct minimal_symbol *minsym; > >+ > >+ tdep = gdbarch_tdep (current_gdbarch); > >+ > >+ /* Some HP-UX related globals to clear when a new "main" > >+ symbol file is loaded. HP-specific. */ > >+ > >+ /* Indicates HP-compiled code. */ > >+ deprecated_hp_som_som_object_present = 0; > >+ /* Must reinitialize exception stuff. */ > >+ hp_cxx_exception_support_initialized = 0; > >+ > >+ minsym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); > >+ if (minsym) > >+ tdep->dyncall_external = SYMBOL_VALUE_ADDRESS (minsym); > >+ else > >+ tdep->dyncall_external = -1; > >+ > >+ minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); > >+ if (minsym) > >+ tdep->sr4export = SYMBOL_VALUE_ADDRESS (minsym); > >+ else > >+ tdep->sr4export = -1; > >+} > > Unfortunatly, not really but as you've noticed, it does ``work'', sigh. > At least we can now see what the code is doing. > > The above values are dependant on the inferior (and make change between > inferior invocations) and not the architecture so their lifetime should > be bound to the inferior. This patch binds them to the current > ``global'' architecture :-( ... but forces them to update every time the inferior restarts. Yes, if we have multiple inferiors sharing an architecture this won't work. I think that's true of many mutable fields in various targets' tdep. They need to migrate to a per-inferior data object someday. > Can, for the immediate term, hppa_hpux_skip_trampoline_code be > simplified so that it doesn't even try to cache these values? This will > put a real strain on the symtab but I think its the symtab that is the > place that needs the fix. What's wrong with the symtab here? -- Daniel Jacobowitz ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess 2004-05-28 23:43 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Daniel Jacobowitz @ 2004-05-31 19:43 ` Andrew Cagney 2004-05-31 20:43 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Daniel Jacobowitz 0 siblings, 1 reply; 20+ messages in thread From: Andrew Cagney @ 2004-05-31 19:43 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Randolph Chung, gdb-patches On Wed, May 26, 2004 at 01:54:30PM -0400, Andrew Cagney wrote: >+static void >+hppa_hpux_observer_inferior_created (struct target_ops *objfile, int >from_tty) >+{ >+ struct gdbarch_tdep *tdep; >+ struct minimal_symbol *minsym; >+ >+ tdep = gdbarch_tdep (current_gdbarch); >+ >+ /* Some HP-UX related globals to clear when a new "main" >+ symbol file is loaded. HP-specific. */ >+ >+ /* Indicates HP-compiled code. */ >+ deprecated_hp_som_som_object_present = 0; >+ /* Must reinitialize exception stuff. */ >+ hp_cxx_exception_support_initialized = 0; >+ >+ minsym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); >+ if (minsym) >+ tdep->dyncall_external = SYMBOL_VALUE_ADDRESS (minsym); >+ else >+ tdep->dyncall_external = -1; >+ >+ minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); >+ if (minsym) >+ tdep->sr4export = SYMBOL_VALUE_ADDRESS (minsym); >+ else >+ tdep->sr4export = -1; >+} Unfortunatly, not really but as you've noticed, it does ``work'', sigh. At least we can now see what the code is doing. The above values are dependant on the inferior (and make change between inferior invocations) and not the architecture so their lifetime should be bound to the inferior. This patch binds them to the current ``global'' architecture :-( ... but forces them to update every time the inferior restarts. The information needs to be determined for each new inferior, yes. Yes, if we have multiple inferiors sharing an architecture this won't work. I think that's true of many mutable fields in various targets' tdep. They need to migrate to a per-inferior data object someday. Can, for the immediate term, hppa_hpux_skip_trampoline_code be simplified so that it doesn't even try to cache these values? This will put a real strain on the symtab but I think its the symtab that is the place that needs the fix. What's wrong with the symtab here? We'll find out - the change will put the additional lookups will put the symtab under extra strain. Andrew ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-31 19:43 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney @ 2004-05-31 20:43 ` Daniel Jacobowitz 2004-06-01 1:31 ` Andrew Cagney 0 siblings, 1 reply; 20+ messages in thread From: Daniel Jacobowitz @ 2004-05-31 20:43 UTC (permalink / raw) To: Andrew Cagney; +Cc: Randolph Chung, gdb-patches On Mon, May 31, 2004 at 03:43:17PM -0400, Andrew Cagney wrote: > We'll find out - the change will put the additional lookups will put the > symtab under extra strain. I have trouble thinking anything will break. Both minimal and full symbol lookups are O(1) already and have been for at least two years. I still don't see why it is preferable not to cache this information in the tdep, pending creation of a per-inferior home to cache it. -- Daniel Jacobowitz ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-31 20:43 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Daniel Jacobowitz @ 2004-06-01 1:31 ` Andrew Cagney 2004-06-01 1:40 ` Daniel Jacobowitz 2004-06-03 17:41 ` Randolph Chung 0 siblings, 2 replies; 20+ messages in thread From: Andrew Cagney @ 2004-06-01 1:31 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Randolph Chung, gdb-patches > On Mon, May 31, 2004 at 03:43:17PM -0400, Andrew Cagney wrote: > >>> We'll find out - the change will put the additional lookups will put the >>> symtab under extra strain. > > > I have trouble thinking anything will break. Both minimal and full > symbol lookups are O(1) already and have been for at least two years. In that case, since the cache was originally added to work around what was a >>O(1) lookup, it should no longer be needed. Of course, if that isn't the case, we'll find out. When it comes to fixing the problem, we can extend/tighten the symtab interface so that other code can also benefit. That is where the cache mechanism belongs - not in hp specific code. Andrew ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-06-01 1:31 ` Andrew Cagney @ 2004-06-01 1:40 ` Daniel Jacobowitz 2004-06-03 17:41 ` Randolph Chung 1 sibling, 0 replies; 20+ messages in thread From: Daniel Jacobowitz @ 2004-06-01 1:40 UTC (permalink / raw) To: gdb-patches On Mon, May 31, 2004 at 09:30:58PM -0400, Andrew Cagney wrote: > >On Mon, May 31, 2004 at 03:43:17PM -0400, Andrew Cagney wrote: > > > >>>We'll find out - the change will put the additional lookups will put the > >>>symtab under extra strain. > > > > > >I have trouble thinking anything will break. Both minimal and full > >symbol lookups are O(1) already and have been for at least two years. > > In that case, since the cache was originally added to work around what > was a >>O(1) lookup, it should no longer be needed. > > Of course, if that isn't the case, we'll find out. > > When it comes to fixing the problem, we can extend/tighten the symtab > interface so that other code can also benefit. That is where the cache > mechanism belongs - not in hp specific code. OK, I understand now. Thanks. -- Daniel Jacobowitz ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-06-01 1:31 ` Andrew Cagney 2004-06-01 1:40 ` Daniel Jacobowitz @ 2004-06-03 17:41 ` Randolph Chung 2004-06-04 18:26 ` Andrew Cagney 1 sibling, 1 reply; 20+ messages in thread From: Randolph Chung @ 2004-06-03 17:41 UTC (permalink / raw) To: Andrew Cagney; +Cc: Daniel Jacobowitz, gdb-patches > In that case, since the cache was originally added to work around what > was a >>O(1) lookup, it should no longer be needed. There were two parts to this actually, the first part was the symbol caching, but there is also some stuff related to how the hp cxx abi support worked that required some cleaning up when a new symbol table gets loaded. Here's a new patch for getting rid of the symbol caching. I'll see how best to handle the hp c++ abi support... ok to apply? randolph 2004-06-03 Randolph Chung <tausq@debian.org> * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline) (hppa_hpux_skip_trampoline_code): Don't cache symbol values. * hppa-linux-tdep.c (hppa_linux_in_dyncall): Likewise. * hppa-tdep.c (hppa_symbol_address): New function definition. * hppa-tdep.h (hppa_symbol_address): New function declaration. Index: hppa-hpux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-hpux-tdep.c,v retrieving revision 1.19 diff -u -p -r1.19 hppa-hpux-tdep.c --- hppa-hpux-tdep.c 26 May 2004 05:31:39 -0000 1.19 +++ hppa-hpux-tdep.c 3 Jun 2004 17:32:47 -0000 @@ -61,32 +61,10 @@ hppa32_hpux_in_solib_call_trampoline (CO { struct minimal_symbol *minsym; struct unwind_table_entry *u; - static CORE_ADDR dyncall = 0; - static CORE_ADDR sr4export = 0; - - /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a - new exec file */ /* First see if PC is in one of the two C-library trampolines. */ - if (!dyncall) - { - minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); - if (minsym) - dyncall = SYMBOL_VALUE_ADDRESS (minsym); - else - dyncall = -1; - } - - if (!sr4export) - { - minsym = lookup_minimal_symbol ("_sr4export", NULL, NULL); - if (minsym) - sr4export = SYMBOL_VALUE_ADDRESS (minsym); - else - sr4export = -1; - } - - if (pc == dyncall || pc == sr4export) + if (pc == hppa_symbol_address("$$dyncall") + || pc == hppa_symbol_address("_sr4export")) return 1; minsym = lookup_minimal_symbol_by_pc (pc); @@ -295,45 +273,12 @@ hppa_hpux_skip_trampoline_code (CORE_ADD { long orig_pc = pc; long prev_inst, curr_inst, loc; - static CORE_ADDR dyncall = 0; - static CORE_ADDR dyncall_external = 0; - static CORE_ADDR sr4export = 0; struct minimal_symbol *msym; struct unwind_table_entry *u; - /* FIXME XXX - dyncall and sr4export must be initialized whenever we get a - new exec file */ - - if (!dyncall) - { - msym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); - if (msym) - dyncall = SYMBOL_VALUE_ADDRESS (msym); - else - dyncall = -1; - } - - if (!dyncall_external) - { - msym = lookup_minimal_symbol ("$$dyncall_external", NULL, NULL); - if (msym) - dyncall_external = SYMBOL_VALUE_ADDRESS (msym); - else - dyncall_external = -1; - } - - if (!sr4export) - { - msym = lookup_minimal_symbol ("_sr4export", NULL, NULL); - if (msym) - sr4export = SYMBOL_VALUE_ADDRESS (msym); - else - sr4export = -1; - } - /* Addresses passed to dyncall may *NOT* be the actual address of the function. So we may have to do something special. */ - if (pc == dyncall) + if (pc == hppa_symbol_address("$$dyncall")) { pc = (CORE_ADDR) read_register (22); @@ -343,12 +288,12 @@ hppa_hpux_skip_trampoline_code (CORE_ADD if (pc & 0x2) pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8); } - if (pc == dyncall_external) + if (pc == hppa_symbol_address("$$dyncall_external")) { pc = (CORE_ADDR) read_register (22); pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, TARGET_PTR_BIT / 8); } - else if (pc == sr4export) + else if (pc == hppa_symbol_address("_sr4export")) pc = (CORE_ADDR) (read_register (22)); /* Get the unwind descriptor corresponding to PC, return zero Index: hppa-linux-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-linux-tdep.c,v retrieving revision 1.6 diff -u -p -r1.6 hppa-linux-tdep.c --- hppa-linux-tdep.c 26 May 2004 05:51:39 -0000 1.6 +++ hppa-linux-tdep.c 3 Jun 2004 17:32:47 -0000 @@ -161,21 +164,7 @@ insns_match_pattern (CORE_ADDR pc, static int hppa_linux_in_dyncall (CORE_ADDR pc) { - static CORE_ADDR dyncall = 0; - - /* FIXME: if we switch exec files, dyncall should be reinitialized */ - if (!dyncall) - { - struct minimal_symbol *minsym; - - minsym = lookup_minimal_symbol ("$$dyncall", NULL, NULL); - if (minsym) - dyncall = SYMBOL_VALUE_ADDRESS (minsym); - else - dyncall = -1; - } - - return pc == dyncall; + return pc == hppa_symbol_address("$$dyncall"); } /* There are several kinds of "trampolines" that we need to deal with: Index: hppa-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-tdep.c,v retrieving revision 1.166 diff -u -p -r1.166 hppa-tdep.c --- hppa-tdep.c 30 May 2004 14:11:00 -0000 1.166 +++ hppa-tdep.c 3 Jun 2004 17:32:48 -0000 @@ -262,6 +262,18 @@ hppa_extract_17 (unsigned word) hppa_get_field (word, 11, 15) << 11 | (word & 0x1) << 16, 17) << 2; } + +CORE_ADDR +hppa_symbol_address(const char *sym) +{ + struct minimal_symbol *minsym; + + minsym = lookup_minimal_symbol (sym, NULL, NULL); + if (minsym) + return SYMBOL_VALUE_ADDRESS (minsym); + else + return (CORE_ADDR)-1; +} \f /* Compare the start address for two unwind entries returning 1 if Index: hppa-tdep.h =================================================================== RCS file: /cvs/src/src/gdb/hppa-tdep.h,v retrieving revision 1.11 diff -u -p -r1.11 hppa-tdep.h --- hppa-tdep.h 30 May 2004 14:31:29 -0000 1.11 +++ hppa-tdep.h 3 Jun 2004 17:32:48 -0000 @@ -190,6 +195,7 @@ int hppa_extract_21 (unsigned); int hppa_extract_14 (unsigned); int hppa_low_sign_extend (unsigned int, unsigned int); int hppa_sign_extend (unsigned int, unsigned int); +CORE_ADDR hppa_symbol_address(const char *sym); void hppa_frame_prev_register_helper (struct frame_info *next_frame, ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-06-03 17:41 ` Randolph Chung @ 2004-06-04 18:26 ` Andrew Cagney 0 siblings, 0 replies; 20+ messages in thread From: Andrew Cagney @ 2004-06-04 18:26 UTC (permalink / raw) To: Randolph Chung; +Cc: Daniel Jacobowitz, gdb-patches >>In that case, since the cache was originally added to work around what >>> was a >>O(1) lookup, it should no longer be needed. > > > There were two parts to this actually, the first part was the symbol > caching, but there is also some stuff related to how the hp cxx abi > support worked that required some cleaning up when a new symbol table > gets loaded. > > Here's a new patch for getting rid of the symbol caching. I'll see how > best to handle the hp c++ abi support... Ok. > ok to apply? Yep! Thanks. Andrew > randolph > > 2004-06-03 Randolph Chung <tausq@debian.org> > > * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline) > (hppa_hpux_skip_trampoline_code): Don't cache symbol values. > * hppa-linux-tdep.c (hppa_linux_in_dyncall): Likewise. > * hppa-tdep.c (hppa_symbol_address): New function definition. > * hppa-tdep.h (hppa_symbol_address): New function declaration. > ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess 2004-05-21 18:48 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney 2004-05-21 19:02 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Randolph Chung @ 2004-05-24 15:45 ` Randolph Chung 2004-05-24 18:55 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney 1 sibling, 1 reply; 20+ messages in thread From: Randolph Chung @ 2004-05-24 15:45 UTC (permalink / raw) To: Andrew Cagney; +Cc: gdb-patches > >tm-hppah.h overrode target_tid_to_str to do it's own thing. The default > >target.h definition checks to see if there's a target_tid_to_str define, > >and if not automatically reverts to target_pid_to_str, so the #ifdef > >here is useless. > > Can you separate this part out (it sounds very straight forward). > > >Tested on hppa-linux and hppa2.0w-hp-hpux11.11 with no regressions. Here's a patch with just the thread.c cleanup. ok? 2004-05-24 Randolph Chung <tausq@debian.org> * thread.c (info_threads_command, thread_apply_all_command) (thread_apply_command, thread_command, do_captured_thread_select): Remove HPUXHPPA-specific code. Index: thread.c =================================================================== RCS file: /cvs/src/src/gdb/thread.c,v retrieving revision 1.36 diff -u -p -r1.36 thread.c --- thread.c 12 May 2004 22:19:02 -0000 1.36 +++ thread.c 24 May 2004 15:41:25 -0000 @@ -424,11 +424,7 @@ info_threads_command (char *arg, int fro else printf_filtered (" "); -#ifdef HPUXHPPA printf_filtered ("%d %s", tp->num, target_tid_to_str (tp->ptid)); -#else - printf_filtered ("%d %s", tp->num, target_pid_to_str (tp->ptid)); -#endif extra_info = target_extra_thread_info (tp); if (extra_info) @@ -541,13 +537,8 @@ thread_apply_all_command (char *cmd, int if (thread_alive (tp)) { switch_to_thread (tp->ptid); -#ifdef HPUXHPPA printf_filtered ("\nThread %d (%s):\n", tp->num, target_tid_to_str (inferior_ptid)); -#else - printf_filtered ("\nThread %d (%s):\n", tp->num, - target_pid_to_str (inferior_ptid)); -#endif execute_command (cmd, from_tty); strcpy (cmd, saved_cmd); /* Restore exact command used previously */ } @@ -617,13 +608,8 @@ thread_apply_command (char *tidlist, int else { switch_to_thread (tp->ptid); -#ifdef HPUXHPPA printf_filtered ("\nThread %d (%s):\n", tp->num, target_tid_to_str (inferior_ptid)); -#else - printf_filtered ("\nThread %d (%s):\n", tp->num, - target_pid_to_str (inferior_ptid)); -#endif execute_command (cmd, from_tty); strcpy (cmd, saved_cmd); /* Restore exact command used previously */ } @@ -646,12 +632,7 @@ thread_command (char *tidstr, int from_t if (target_has_stack) printf_filtered ("[Current thread is %d (%s)]\n", pid_to_thread_id (inferior_ptid), -#if defined(HPUXHPPA) - target_tid_to_str (inferior_ptid) -#else - target_pid_to_str (inferior_ptid) -#endif - ); + target_tid_to_str (inferior_ptid)); else error ("No stack."); return; @@ -681,11 +662,7 @@ do_captured_thread_select (struct ui_out ui_out_text (uiout, "[Switching to thread "); ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid)); ui_out_text (uiout, " ("); -#if defined(HPUXHPPA) ui_out_text (uiout, target_tid_to_str (inferior_ptid)); -#else - ui_out_text (uiout, target_pid_to_str (inferior_ptid)); -#endif ui_out_text (uiout, ")]"); print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC); -- Randolph Chung Debian GNU/Linux Developer, hppa/ia64 ports http://www.tausq.org/ ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess 2004-05-24 15:45 ` Randolph Chung @ 2004-05-24 18:55 ` Andrew Cagney 0 siblings, 0 replies; 20+ messages in thread From: Andrew Cagney @ 2004-05-24 18:55 UTC (permalink / raw) To: Randolph Chung; +Cc: gdb-patches 2004-05-24 Randolph Chung <tausq@debian.org> * thread.c (info_threads_command, thread_apply_all_command) (thread_apply_command, thread_command, do_captured_thread_select): Remove HPUXHPPA-specific code. Ah, yes `obvious', thanks. Andrew ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2004-06-04 18:26 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-19 20:40 [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Randolph Chung
2004-05-19 21:37 ` Joel Brobecker
2004-05-19 21:44 ` Randolph Chung
2004-05-19 22:06 ` Joel Brobecker
2004-05-21 18:48 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney
2004-05-21 19:02 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Randolph Chung
[not found] ` <40AE6260.2090205@gnu.org>
2004-05-26 5:27 ` Randolph Chung
2004-05-26 13:25 ` Daniel Jacobowitz
2004-05-26 15:35 ` Randolph Chung
2004-05-26 16:48 ` Daniel Jacobowitz
2004-05-26 17:54 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney
2004-05-28 23:43 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Daniel Jacobowitz
2004-05-31 19:43 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney
2004-05-31 20:43 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPA mess Daniel Jacobowitz
2004-06-01 1:31 ` Andrew Cagney
2004-06-01 1:40 ` Daniel Jacobowitz
2004-06-03 17:41 ` Randolph Chung
2004-06-04 18:26 ` Andrew Cagney
2004-05-24 15:45 ` Randolph Chung
2004-05-24 18:55 ` [patch/rfc] New program_changed event, cleanup some HPUXHPPAmess Andrew Cagney
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox