This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa] Change line to long
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: Re: [rfa] Change line to long
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Thu, 01 Mar 2001 13:05:45 -0500
- References: <3A79B3DF.AADED074@cygnus.com>
Andrew Cagney wrote:
>
> Hello,
>
> (more sparc64 -Werror fallout)
>
> This was triggered by some realy nasty code in os9kread.c. It was
> casting a pointer down to an integer (sizeof(long) == sizeof(void*) ==
> 32 and sizeof(int) == 16 right? :-).
>
> The patch changes the type of symtab's line to long (from int) and then
> propogates that through the most obvious places. The os9k read then
> casts that pointer across to slightly less non-portable long. Given the
> os9k is probably on its last legs I can't see a good reason to try and
> clean up that chunk code.
>
> The alternative quick hack is to cast (void*) -> (long) -> (int) and
> change the assert to check that sizeof(void*) <= sizeof(int) ...
>
> Look ok? Comments?
>
> Andrew
>
> ------------------------------------------------------------------------
> Thu Feb 1 00:29:42 2001 Andrew Cagney <cagney@redhat.com>
>
> * symtab.h (struct linetable_entry): Change ``line'' to a long.
> * buildsym.h (record_line): Change ``line'' to a long.
> * buildsym.c (record_line): Ditto
> * os9kread.c: Include "gdb_assert.h".
> (os9k_process_one_symbol): Cast the pointer ``name'' to a long.
Just FYI,
I'm dropping this patch.
Instead, I'm going to commit the attatched. It does to things:
os9kread is changed so that when sizeof(int)<sizeof(char*) ``they
loose'' with an assert failure rather than a possibly corrupt symbol
table.
os9kread is taken of the list of files that must compile with -Werror.
I think the addition of the assertion check goes under the obvious fix
rule.
Andrew
2001-03-01 Andrew Cagney <ac131313@redhat.com>
* Makefile.in (os9kread.o): Do not compile with WERROR_CFLAGS.
* os9kread.c (os9k_process_one_symbol): Add assert to detect
``loses if sizeof (char *) > sizeof (int)''.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.65
diff -p -r1.65 Makefile.in
*** Makefile.in 2001/03/01 16:13:18 1.65
--- Makefile.in 2001/03/01 17:55:12
*************** mdebugread.o: mdebugread.c buildsym.h co
*** 1635,1644 ****
mipsm3-nat.o: mipsm3-nat.c $(defs_h) $(inferior_h) $(regcache_h)
os9kread.o: os9kread.c buildsym.h complaints.h $(bfd_h) $(defs_h) \
! $(expression_h) gdb-stabs.h $(gdbcore_h) $(gdbtypes_h) language.h \
! objfiles.h stabsread.h symfile.h $(symtab_h) \
! target.h gdb_string.h
mem-break.o: mem-break.c $(defs_h)
--- 1635,1647 ----
mipsm3-nat.o: mipsm3-nat.c $(defs_h) $(inferior_h) $(regcache_h)
+ # os9kread assumes that sizeof(char*) <= sizeof(int). This looses on
+ # 64 bit targets where often, sizeof(int)=4 but sizeof(char*)=9.
os9kread.o: os9kread.c buildsym.h complaints.h $(bfd_h) $(defs_h) \
! $(expression_h) gdb-stabs.h $(gdbcore_h) $(gdbtypes_h) \
! language.h objfiles.h stabsread.h symfile.h $(symtab_h) \
! target.h gdb_string.h
! $(CC) -c $(INTERNAL_WARN_CFLAGS) $(NO_WERROR_CFLAGS) $<
mem-break.o: mem-break.c $(defs_h)
Index: os9kread.c
===================================================================
RCS file: /cvs/src/src/gdb/os9kread.c,v
retrieving revision 1.6
diff -p -r1.6 os9kread.c
*** os9kread.c 2000/09/27 17:43:07 1.6
--- os9kread.c 2001/03/01 17:55:13
***************
*** 35,40 ****
--- 35,41 ----
#include "defs.h"
#include "gdb_string.h"
+ #include "gdb_assert.h"
#include <stdio.h>
#if defined(USG) || defined(__CYGNUSCLIB__)
*************** os9k_process_one_symbol (int type, int d
*** 1509,1514 ****
--- 1510,1516 ----
/* Relocate for dynamic loading and for ELF acc fn-relative syms. */
valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
/* FIXME: loses if sizeof (char *) > sizeof (int) */
+ gdb_assert (sizeof (name) <= sizeof (int));
record_line (current_subfile, (int) name, valu);
break;