From 65e82032f23f19b38aaf89a1eaddfeec68b8c076 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Sat, 29 Mar 2003 23:29:47 +0000 Subject: [PATCH] 2003-03-29 Andrew Cagney * infttrace.h: New file. * hpread.c: Include "gdb_assert.h" and "somsolib.h". (hpread_get_textlow): Detect an uninitialized dn_bufp. (hpread_read_doc_function_type): Detect an initialized type1. (hpread_quick_traverse): Initialize mod_name_string. * somsolib.h: Add #ifdef SOMSOLIB_H wrapper. (som_solib_get_solib_by_pc): Declare. (so_lib_thread_start_addr): Declare. (no_shared_libraries): Declare. * somread.c (init_import_symbols): Make static. Add forward declaration. * config/pa/nm-hppah.h: Include "infttrace.h" for parent_attach_all. (hppa_insert_hw_watchpoint): Declare. (hppa_can_use_hw_watchpoint, hppa_remove_hw_watchpoint): Declare. * hppah-nat.c: Include "gdb_string.h". (parent_attach_all): Delete extern declaration, moved to "infttrace.h". (hppa_can_use_hw_watchpoint): Change type of "type" parameter to int. (hppa_remove_hw_watchpoint, hppa_insert_hw_watchpoint): Ditto. * Makefile.in (infttrace_h): Define. (hpread.o): Update dependencies. (hppah-nat.o, hppa-hpux-tdep.o, hppa-tdep.o): Ditto. * hppa-hpux-tdep.c: Include "gdb_string.h". * hppa-tdep.c (hppa_frame_saved_pc): Initialize "old_pc". * infrun.c (handle_inferior_event): Always initialize stepped_after_stopped_by_watchpoint. Add default and remove fallthrough in switch statement. * infttrace.c (hppa_can_use_hw_watchpoint): Change type of "type" parameter to int. (hppa_remove_hw_watchpoint): Ditto. --- gdb/ChangeLog | 35 +++++++++++++++++++++++++++++++++++ gdb/Makefile.in | 12 +++++++----- gdb/config/pa/nm-hppah.h | 7 +++++++ gdb/hppa-hpux-tdep.c | 1 + gdb/hppa-tdep.c | 4 ++-- gdb/hppah-nat.c | 8 +++----- gdb/hpread.c | 19 ++++++++++++++++--- gdb/infrun.c | 19 ++++++++++++++++++- gdb/infttrace.c | 5 ++--- gdb/infttrace.h | 28 ++++++++++++++++++++++++++++ gdb/somread.c | 4 +++- gdb/somsolib.h | 12 ++++++++++++ 12 files changed, 134 insertions(+), 20 deletions(-) create mode 100644 gdb/infttrace.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 085fe7f6b92..0709fe0014d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,38 @@ +2003-03-29 Andrew Cagney + + * infttrace.h: New file. + * hpread.c: Include "gdb_assert.h" and "somsolib.h". + (hpread_get_textlow): Detect an uninitialized dn_bufp. + (hpread_read_doc_function_type): Detect an initialized type1. + (hpread_quick_traverse): Initialize mod_name_string. + * somsolib.h: Add #ifdef SOMSOLIB_H wrapper. + (som_solib_get_solib_by_pc): Declare. + (so_lib_thread_start_addr): Declare. + (no_shared_libraries): Declare. + * somread.c (init_import_symbols): Make static. Add forward + declaration. + * config/pa/nm-hppah.h: Include "infttrace.h" for + parent_attach_all. + (hppa_insert_hw_watchpoint): Declare. + (hppa_can_use_hw_watchpoint, hppa_remove_hw_watchpoint): Declare. + * hppah-nat.c: Include "gdb_string.h". + (parent_attach_all): Delete extern declaration, moved to + "infttrace.h". + (hppa_can_use_hw_watchpoint): Change type of "type" parameter to + int. + (hppa_remove_hw_watchpoint, hppa_insert_hw_watchpoint): Ditto. + * Makefile.in (infttrace_h): Define. + (hpread.o): Update dependencies. + (hppah-nat.o, hppa-hpux-tdep.o, hppa-tdep.o): Ditto. + * hppa-hpux-tdep.c: Include "gdb_string.h". + * hppa-tdep.c (hppa_frame_saved_pc): Initialize "old_pc". + * infrun.c (handle_inferior_event): Always initialize + stepped_after_stopped_by_watchpoint. Add default and remove + fallthrough in switch statement. + * infttrace.c (hppa_can_use_hw_watchpoint): Change type of "type" + parameter to int. + (hppa_remove_hw_watchpoint): Ditto. + 2003-03-29 Andrew Cagney * ns32k-tdep.c (ns32k_gdbarch_init): Set the call dummy breakpoint diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 20fd6cfedbf..cc0792ea844 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -722,6 +722,7 @@ symtab_h = symtab.h target_h = target.h $(bfd_h) $(symtab_h) $(dcache_h) $(memattr_h) terminal_h = terminal.h top_h = top.h +infttrace_h = infttrace.h tracepoint_h = tracepoint.h typeprint_h = typeprint.h ui_file_h = ui-file.h @@ -1743,11 +1744,12 @@ h8500-tdep.o: h8500-tdep.c $(defs_h) $(frame_h) $(symtab_h) $(gdbtypes_h) \ hpacc-abi.o: hpacc-abi.c $(defs_h) $(value_h) $(gdb_regex_h) $(gdb_string_h) \ $(gdbtypes_h) $(gdbcore_h) $(cp_abi_h) hppa-tdep.o: hppa-tdep.c $(defs_h) $(frame_h) $(bfd_h) $(inferior_h) \ - $(value_h) $(regcache_h) $(completer_h) $(symtab_h) $(a_out_encap_h) \ + $(value_h) $(regcache_h) $(completer_h) $(language_h) $(osabi_h) \ + $(gdb_assert_h) $(infttrace_h) $(symtab_h) $(a_out_encap_h) \ $(gdb_stat_h) $(gdb_wait_h) $(gdbcore_h) $(gdbcmd_h) $(target_h) \ - $(symfile_h) $(objfiles_h) $(language_h) $(osabi_h) $(gdb_assert_h) + $(symfile_h) $(objfiles_h) hppa-hpux-tdep.o: hppa-hpux-tdep.c $(defs_h) $(arch_utils_h) $(gdbcore_h) \ - $(osabi_h) + $(osabi_h) $(gdb_string_h) hppab-nat.o: hppab-nat.c $(defs_h) $(inferior_h) $(target_h) $(regcache_h) hppah-nat.o: hppah-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdbcore_h) \ $(gdb_wait_h) $(regcache_h) @@ -1756,7 +1758,7 @@ hppam3-nat.o: hppam3-nat.c $(defs_h) $(inferior_h) $(floatformat_h) \ hpread.o: hpread.c $(defs_h) $(bfd_h) $(gdb_string_h) $(hp_symtab_h) \ $(syms_h) $(symtab_h) $(symfile_h) $(objfiles_h) $(buildsym_h) \ $(complaints_h) $(gdb_stabs_h) $(gdbtypes_h) $(demangle_h) \ - $(gdb_string_h) + $(somsolib_h) $(gdb_assert_h) $(gdb_string_h) hpux-thread.o: hpux-thread.c $(defs_h) $(gdbthread_h) $(target_h) \ $(inferior_h) $(regcache_h) $(gdb_stat_h) $(gdbcore_h) i386-linux-nat.o: i386-linux-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) \ @@ -2112,7 +2114,7 @@ remote.o: remote.c $(defs_h) $(gdb_string_h) $(inferior_h) $(bfd_h) \ $(symfile_h) $(target_h) $(gdbcmd_h) $(objfiles_h) $(gdb_stabs_h) \ $(gdbthread_h) $(remote_h) $(regcache_h) $(value_h) $(gdb_assert_h) \ $(event_loop_h) $(event_top_h) $(inf_loop_h) $(serial_h) \ - $(gdbcore_h) + $(gdbcore_h) $(solib_h) rom68k-rom.o: rom68k-rom.c $(defs_h) $(gdbcore_h) $(target_h) $(monitor_h) \ $(serial_h) $(regcache_h) $(value_h) $(m68k_tdep_h) rs6000-nat.o: rs6000-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdbcore_h) \ diff --git a/gdb/config/pa/nm-hppah.h b/gdb/config/pa/nm-hppah.h index 83871158d35..2cc1e300365 100644 --- a/gdb/config/pa/nm-hppah.h +++ b/gdb/config/pa/nm-hppah.h @@ -117,6 +117,7 @@ extern int hppa_require_detach (int, int); /* The PA can watch any number of locations (generic routines already check that all intermediates are in watchable memory locations). */ +extern int hppa_can_use_hw_watchpoint (int type, int cnt, int ot); #define TARGET_CAN_USE_HARDWARE_WATCHPOINT(type, cnt, ot) \ hppa_can_use_hw_watchpoint(type, cnt, ot) @@ -198,9 +199,13 @@ extern void hppa_enable_page_protection_events (int); extern void hppa_disable_page_protection_events (int); /* Use these macros for watchpoint insertion/deletion. */ +extern int hppa_insert_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, + int type); #define target_insert_watchpoint(addr, len, type) \ hppa_insert_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type) +extern int hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, + int type); #define target_remove_watchpoint(addr, len, type) \ hppa_remove_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type) @@ -265,3 +270,5 @@ extern int hppa_resume_execd_vforking_child_to_get_parent_vfork (void); #define MAY_FOLLOW_EXEC (1) #define USE_THREAD_STEP_NEEDED (1) + +#include "infttrace.h" /* For parent_attach_all. */ diff --git a/gdb/hppa-hpux-tdep.c b/gdb/hppa-hpux-tdep.c index 66b7b611e61..3d1ca88ce50 100644 --- a/gdb/hppa-hpux-tdep.c +++ b/gdb/hppa-hpux-tdep.c @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "arch-utils.h" #include "gdbcore.h" #include "osabi.h" +#include "gdb_string.h" /* Forward declarations. */ extern void _initialize_hppa_hpux_tdep (void); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 38676935b6c..b9d3d55abb8 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -33,7 +33,7 @@ #include "language.h" #include "osabi.h" #include "gdb_assert.h" - +#include "infttrace.h" /* For argument passing to the inferior */ #include "symtab.h" @@ -886,7 +886,7 @@ hppa_frame_saved_pc (struct frame_info *frame) { CORE_ADDR pc = get_frame_pc (frame); struct unwind_table_entry *u; - CORE_ADDR old_pc; + CORE_ADDR old_pc = 0; int spun_around_loop = 0; int rp_offset = 0; diff --git a/gdb/hppah-nat.c b/gdb/hppah-nat.c index 51b74fc7ba0..b953d2546f6 100644 --- a/gdb/hppah-nat.c +++ b/gdb/hppah-nat.c @@ -31,6 +31,7 @@ #include "gdbcore.h" #include "gdb_wait.h" #include "regcache.h" +#include "gdb_string.h" #include extern CORE_ADDR text_end; @@ -785,8 +786,6 @@ startup_semaphore_t; static startup_semaphore_t startup_semaphore; -extern int parent_attach_all (int, PTRACE_ARG3_TYPE, int); - #ifdef PT_SETTRC /* This function causes the caller's process to be traced by its parent. This is intended to be called after GDB forks itself, @@ -907,14 +906,13 @@ hppa_insert_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type) } int -hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, - enum bptype type) +hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type) { error ("Hardware watchpoints not implemented on this platform."); } int -hppa_can_use_hw_watchpoint (enum bptype type, int cnt, enum bptype ot) +hppa_can_use_hw_watchpoint (int type, int cnt, int ot) { return 0; } diff --git a/gdb/hpread.c b/gdb/hpread.c index 6acf5760364..606ccfeba7c 100644 --- a/gdb/hpread.c +++ b/gdb/hpread.c @@ -35,6 +35,8 @@ #include "gdb-stabs.h" #include "gdbtypes.h" #include "demangle.h" +#include "somsolib.h" +#include "gdb_assert.h" /* Private information attached to an objfile which we use to find and internalize the HP C debug symbols within that objfile. */ @@ -1024,7 +1026,7 @@ hpread_quick_traverse (struct objfile *objfile, char *gntt_bits, while (VALID_CURR_FILE || VALID_CURR_MODULE) { - char *mod_name_string; + char *mod_name_string = NULL; char *full_name_string; /* First check for modules like "version.c", which have no code @@ -2321,7 +2323,7 @@ static unsigned long hpread_get_textlow (int global, int index, struct objfile *objfile, int symcount) { - union dnttentry *dn_bufp; + union dnttentry *dn_bufp = NULL; struct minimal_symbol *msymbol; /* Look for a DNTT_TYPE_FUNCTION symbol. */ @@ -2340,6 +2342,11 @@ hpread_get_textlow (int global, int index, struct objfile *objfile, && index < symcount); } + /* NOTE: cagney/2003-03-29: If !(index < symcount), dn_bufp is left + undefined and that means that the test below is using a garbage + pointer from the stack. */ + gdb_assert (dn_bufp != NULL); + /* Avoid going past a DNTT_TYPE_END when looking for a DNTT_TYPE_FUNCTION. This might happen when a sourcefile has no functions. */ if (dn_bufp->dblock.kind == DNTT_TYPE_END) @@ -3359,10 +3366,10 @@ static struct type * hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp, struct objfile *objfile, int newblock) { - struct type *type, *type1; struct pending *syms; struct pending *local_list = NULL; int nsyms = 0; + struct type *type; dnttpointer param; union dnttentry *paramp; char *name; @@ -3378,11 +3385,17 @@ hpread_read_doc_function_type (dnttpointer hp_type, union dnttentry *dn_bufp, } else { + struct type *type1 = NULL; /* Nope, so read it in and store it away. */ if (dn_bufp->dblock.kind == DNTT_TYPE_DOC_FUNCTION || dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) type1 = lookup_function_type (hpread_type_lookup (dn_bufp->ddocfunc.retval, objfile)); + /* NOTE: cagney/2003-03-29: Oh, no not again. TYPE1 is + potentially left undefined here. Assert it isn't and hope + the assert never fails ... */ + gdb_assert (type1 != NULL); + replace_type (type, type1); /* Mark it -- in the middle of processing */ diff --git a/gdb/infrun.c b/gdb/infrun.c index 6da33946ec1..7066a52de2b 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1153,6 +1153,11 @@ void handle_inferior_event (struct execution_control_state *ecs) { CORE_ADDR real_stop_pc; + /* NOTE: cagney/2003-03-28: If you're looking at this code and + thinking that the variable stepped_after_stopped_by_watchpoint + isn't used, then you're wrong! The macro STOPPED_BY_WATCHPOINT, + defined in the file "config/pa/nm-hppah.h", accesses the variable + indirectly. Mutter something rude about the HP merge. */ int stepped_after_stopped_by_watchpoint; int sw_single_step_trap_p = 0; @@ -1165,7 +1170,15 @@ handle_inferior_event (struct execution_control_state *ecs) case infwait_thread_hop_state: /* Cancel the waiton_ptid. */ ecs->waiton_ptid = pid_to_ptid (-1); - /* Fall thru to the normal_state case. */ + /* See comments where a TARGET_WAITKIND_SYSCALL_RETURN event + is serviced in this loop, below. */ + if (ecs->enable_hw_watchpoints_after_wait) + { + TARGET_ENABLE_HW_WATCHPOINTS (PIDGET (inferior_ptid)); + ecs->enable_hw_watchpoints_after_wait = 0; + } + stepped_after_stopped_by_watchpoint = 0; + break; case infwait_normal_state: /* See comments where a TARGET_WAITKIND_SYSCALL_RETURN event @@ -1179,6 +1192,7 @@ handle_inferior_event (struct execution_control_state *ecs) break; case infwait_nullified_state: + stepped_after_stopped_by_watchpoint = 0; break; case infwait_nonstep_watch_state: @@ -1189,6 +1203,9 @@ handle_inferior_event (struct execution_control_state *ecs) in combination correctly? */ stepped_after_stopped_by_watchpoint = 1; break; + + default: + internal_error (__FILE__, __LINE__, "bad switch"); } ecs->infwait_state = infwait_normal_state; diff --git a/gdb/infttrace.c b/gdb/infttrace.c index 02a55762cd9..c5b2119e281 100644 --- a/gdb/infttrace.c +++ b/gdb/infttrace.c @@ -5378,8 +5378,7 @@ hppa_insert_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type) watchpoints. */ int -hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, - enum bptype type) +hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, int type) { CORE_ADDR page_start; int dictionary_is_empty; @@ -5439,7 +5438,7 @@ hppa_remove_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len, hardware support. */ int -hppa_can_use_hw_watchpoint (enum bptype type, int cnt, enum bptype ot) +hppa_can_use_hw_watchpoint (int type, int cnt, int ot) { return (type == bp_hardware_watchpoint); } diff --git a/gdb/infttrace.h b/gdb/infttrace.h new file mode 100644 index 00000000000..d3330e3b85a --- /dev/null +++ b/gdb/infttrace.h @@ -0,0 +1,28 @@ +/* Low level Unix child interface to ttrace, for GDB when running under HP-UX. + + Copyright 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef INFTTRACE_H +#define INFTTRACE_H + +extern int parent_attach_all (int, PTRACE_ARG3_TYPE, int); +extern pid_t hppa_switched_threads (pid_t gdb_pid); + +#endif diff --git a/gdb/somread.c b/gdb/somread.c index 85d4f0a537c..654ae067f75 100644 --- a/gdb/somread.c +++ b/gdb/somread.c @@ -37,6 +37,8 @@ /* Various things we might complain about... */ +static int init_import_symbols (struct objfile *objfile); + static void som_symfile_init (struct objfile *); static void som_new_init (struct objfile *); @@ -466,7 +468,7 @@ som_symfile_offsets (struct objfile *objfile, struct section_addr_info *addrs) not defined there. (Variables that are imported are dealt with as "loc_indirect" vars.) Return value = number of import symbols read in. */ -int +static int init_import_symbols (struct objfile *objfile) { unsigned int import_list; diff --git a/gdb/somsolib.h b/gdb/somsolib.h index 0840067d997..c2414118843 100644 --- a/gdb/somsolib.h +++ b/gdb/somsolib.h @@ -23,6 +23,9 @@ Written by the Center for Software Science at the Univerity of Utah and by Cygnus Support. */ +#ifndef SOMSOLIB_H +#define SOMSOLIB_H + /* Forward decl's for prototypes */ struct target_ops; struct objfile; @@ -164,3 +167,12 @@ extern char *som_solib_address (CORE_ADDR); /* somsolib.c */ /* If ADDR lies in a shared library, return its name. */ #define PC_SOLIB(addr) som_solib_address (addr) + +extern CORE_ADDR som_solib_get_solib_by_pc (CORE_ADDR addr); + +struct so_list; +extern CORE_ADDR so_lib_thread_start_addr (struct so_list *so); + +extern void no_shared_libraries (char *ignored, int from_tty); + +#endif -- 2.30.2