This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[commit] Fix HP/UX 10.20 -Werrors
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 29 Mar 2003 18:31:57 -0500
- Subject: [commit] Fix HP/UX 10.20 -Werrors
Hello,
This patch fixes -Werror warnings being reported when building GDB,
using GCC, on HP/UX 10.20. Some edited highlights:
+ /* 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);
+ /* 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);
+ /* 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. */
It builds on HP/UX, tested on d10v, ppc and i386.
committed,
Andrew
2003-03-29 Andrew Cagney <cagney at redhat dot com>
* 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.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.352
diff -u -r1.352 Makefile.in
--- Makefile.in 29 Mar 2003 01:40:00 -0000 1.352
+++ Makefile.in 29 Mar 2003 23:22:27 -0000
@@ -722,6 +722,7 @@
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 @@
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 @@
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 @@
$(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) \
Index: hppa-hpux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-hpux-tdep.c,v
retrieving revision 1.3
diff -u -r1.3 hppa-hpux-tdep.c
--- hppa-hpux-tdep.c 26 Dec 2002 09:36:41 -0000 1.3
+++ hppa-hpux-tdep.c 29 Mar 2003 23:22:28 -0000
@@ -21,6 +21,7 @@
#include "arch-utils.h"
#include "gdbcore.h"
#include "osabi.h"
+#include "gdb_string.h"
/* Forward declarations. */
extern void _initialize_hppa_hpux_tdep (void);
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.63
diff -u -r1.63 hppa-tdep.c
--- hppa-tdep.c 26 Mar 2003 22:39:52 -0000 1.63
+++ hppa-tdep.c 29 Mar 2003 23:22:33 -0000
@@ -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 @@
{
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;
Index: hppah-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/hppah-nat.c,v
retrieving revision 1.22
diff -u -r1.22 hppah-nat.c
--- hppah-nat.c 2 Feb 2003 05:46:14 -0000 1.22
+++ hppah-nat.c 29 Mar 2003 23:22:35 -0000
@@ -31,6 +31,7 @@
#include "gdbcore.h"
#include "gdb_wait.h"
#include "regcache.h"
+#include "gdb_string.h"
#include <signal.h>
extern CORE_ADDR text_end;
@@ -785,8 +786,6 @@
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 @@
}
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;
}
Index: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.33
diff -u -r1.33 hpread.c
--- hpread.c 25 Feb 2003 21:36:18 -0000 1.33
+++ hpread.c 29 Mar 2003 23:22:38 -0000
@@ -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 @@
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 @@
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 @@
&& 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 @@
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 @@
}
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 */
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.100
diff -u -r1.100 infrun.c
--- infrun.c 26 Mar 2003 03:39:43 -0000 1.100
+++ infrun.c 29 Mar 2003 23:22:40 -0000
@@ -1153,6 +1153,11 @@
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 @@
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 @@
break;
case infwait_nullified_state:
+ stepped_after_stopped_by_watchpoint = 0;
break;
case infwait_nonstep_watch_state:
@@ -1189,6 +1203,9 @@
in combination correctly? */
stepped_after_stopped_by_watchpoint = 1;
break;
+
+ default:
+ internal_error (__FILE__, __LINE__, "bad switch");
}
ecs->infwait_state = infwait_normal_state;
Index: infttrace.c
===================================================================
RCS file: /cvs/src/src/gdb/infttrace.c,v
retrieving revision 1.25
diff -u -r1.25 infttrace.c
--- infttrace.c 6 Feb 2003 17:58:01 -0000 1.25
+++ infttrace.c 29 Mar 2003 23:22:42 -0000
@@ -5378,8 +5378,7 @@
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 @@
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);
}
Index: somread.c
===================================================================
RCS file: /cvs/src/src/gdb/somread.c,v
retrieving revision 1.17
diff -u -r1.17 somread.c
--- somread.c 20 Feb 2003 18:31:14 -0000 1.17
+++ somread.c 29 Mar 2003 23:22:42 -0000
@@ -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 @@
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;
Index: somsolib.h
===================================================================
RCS file: /cvs/src/src/gdb/somsolib.h,v
retrieving revision 1.6
diff -u -r1.6 somsolib.h
--- somsolib.h 14 Jan 2003 00:49:04 -0000 1.6
+++ somsolib.h 29 Mar 2003 23:22:42 -0000
@@ -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 @@
/* 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
Index: config/pa/nm-hppah.h
===================================================================
RCS file: /cvs/src/src/gdb/config/pa/nm-hppah.h,v
retrieving revision 1.11
diff -u -r1.11 nm-hppah.h
--- config/pa/nm-hppah.h 23 Dec 2002 17:07:28 -0000 1.11
+++ config/pa/nm-hppah.h 29 Mar 2003 23:22:43 -0000
@@ -117,6 +117,7 @@
/* 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_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 @@
#define MAY_FOLLOW_EXEC (1)
#define USE_THREAD_STEP_NEEDED (1)
+
+#include "infttrace.h" /* For parent_attach_all. */