This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[rfa] Change line to long


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.

Index: buildsym.c
===================================================================
RCS file: /cvs/src/src/gdb/buildsym.c,v
retrieving revision 1.7
diff -p -r1.7 buildsym.c
*** buildsym.c	2000/12/15 01:01:45	1.7
--- buildsym.c	2001/02/01 19:01:51
*************** pop_subfile (void)
*** 692,698 ****
     line vector for SUBFILE.  */
  
  void
! record_line (register struct subfile *subfile, int line, CORE_ADDR pc)
  {
    struct linetable_entry *e;
    /* Ignore the dummy line number in libg.o */
--- 692,698 ----
     line vector for SUBFILE.  */
  
  void
! record_line (register struct subfile *subfile, long line, CORE_ADDR pc)
  {
    struct linetable_entry *e;
    /* Ignore the dummy line number in libg.o */
Index: buildsym.h
===================================================================
RCS file: /cvs/src/src/gdb/buildsym.h,v
retrieving revision 1.2
diff -p -r1.2 buildsym.h
*** buildsym.h	2000/02/18 22:15:16	1.2
--- buildsym.h	2001/02/01 19:01:51
*************** extern void buildsym_init (void);
*** 268,274 ****
  
  extern struct context_stack *push_context (int desc, CORE_ADDR valu);
  
! extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
  
  extern void start_symtab (char *name, char *dirname, CORE_ADDR start_addr);
  
--- 268,274 ----
  
  extern struct context_stack *push_context (int desc, CORE_ADDR valu);
  
! extern void record_line (struct subfile *subfile, long line, CORE_ADDR pc);
  
  extern void start_symtab (char *name, char *dirname, CORE_ADDR start_addr);
  
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/02/01 19:01:51
***************
*** 60,65 ****
--- 60,66 ----
  #include "complaints.h"
  #include "os9k.h"
  #include "stabsread.h"
+ #include "gdb_assert.h"
  
  extern void _initialize_os9kread (void);
  
*************** os9k_process_one_symbol (int type, int d
*** 1508,1515 ****
           Enter it in the line list for this symbol table. */
        /* 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) */
!       record_line (current_subfile, (int) name, valu);
        break;
  
        /* The following symbol types need to have the appropriate offset added
--- 1509,1520 ----
           Enter it in the line list for this symbol table. */
        /* Relocate for dynamic loading and for ELF acc fn-relative syms.  */
        valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
!       /* FIXME: cagney/2001-02-01: The following cast is to convert
! 	 NAME into a long (the parameter expected by record_line).
! 	 Name ends up containing the line number because other code
! 	 has overloaded this parameters use :-( */
!       gdb_assert (sizeof (long) >= sizeof (name));
!       record_line (current_subfile, (long) name, valu);
        break;
  
        /* The following symbol types need to have the appropriate offset added
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.16
diff -p -r1.16 symtab.h
*** symtab.h	2000/11/10 23:02:56	1.16
--- symtab.h	2001/02/01 19:01:51
*************** struct sourcevector
*** 776,782 ****
  
  struct linetable_entry
    {
!     int line;
      CORE_ADDR pc;
    };
  
--- 776,782 ----
  
  struct linetable_entry
    {
!     long line;
      CORE_ADDR pc;
    };
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]