Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Replace SET_NAMESTRING macro by function in hpread.c
@ 2003-01-11  9:32 Joel Brobecker
  2003-01-11 17:48 ` Daniel Jacobowitz
  2003-01-11 18:31 ` Andrew Cagney
  0 siblings, 2 replies; 4+ messages in thread
From: Joel Brobecker @ 2003-01-11  9:32 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

In the name of macros-are-evil, as suggested by AndrewC, I replaced
the SET_NAMESTRING macro by a function...

2003-01-10  J. Brobecker  <brobecker@gnat.com>

        * hpread.c (set_namestring): New procedure replacing the
        SET_NAMESTRING macro.
        (hpread_build_psymtabs): Replace calls to SET_NAMESTRING
        by calls to set_namestring.

Ok to apply?
-- 
Joel

[-- Attachment #2: hpread.c.diff --]
[-- Type: text/plain, Size: 7140 bytes --]

Index: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.30
diff -c -3 -p -r1.30 hpread.c
*** hpread.c	11 Jan 2003 02:13:22 -0000	1.30
--- hpread.c	11 Jan 2003 09:23:48 -0000
*************** struct hpread_symfile_info
*** 87,109 ****
  #define WITHIN_FUNCTION(o)      (HPUX_SYMFILE_INFO(o)->within_function)
  #define CURRENT_FUNCTION_VALUE(o) (HPUX_SYMFILE_INFO(o)->current_function_value)
  
- /* Given the native debug symbol SYM, set NAMEP to the name associated
-    with the debug symbol.  Note we may be called with a debug symbol which
-    has no associated name, in that case we return an empty string.
- 
-    Also note we "know" that the name for any symbol is always in the
-    same place.  Hence we don't have to conditionalize on the symbol type.  */
- #define SET_NAMESTRING(SYM, NAMEP, OBJFILE) \
-   if (! hpread_has_name ((SYM)->dblock.kind)) \
-     *NAMEP = ""; \
-   else if (((unsigned)(SYM)->dsfile.name) >= VT_SIZE (OBJFILE)) \
-     { \
-       complaint (&symfile_complaints, "bad string table offset in symbol %d", \
- 		 symnum); \
-       *NAMEP = ""; \
-     } \
-   else \
-     *NAMEP = (SYM)->dsfile.name + VT (OBJFILE)
  \f
  /* We put a pointer to this structure in the read_symtab_private field
     of the psymtab.  */
--- 87,92 ----
*************** lbrac_mismatch_complaint (int arg1)
*** 155,160 ****
--- 138,146 ----
  
  /* Forward procedure declarations */
  
+ static void set_namestring (union dnttentry *sym, char **namep,
+                             struct objfile *objfile);
+ 
  void hpread_symfile_init (struct objfile *);
  
  void do_pxdb (bfd *);
*************** trans_lang (enum hp_language in_lang)
*** 302,307 ****
--- 288,315 ----
  
  static char main_string[] = "main";
  \f
+ 
+ /* Given the native debug symbol SYM, set NAMEP to the name associated
+    with the debug symbol.  Note we may be called with a debug symbol which
+    has no associated name, in that case we return an empty string.  */
+ 
+ static void
+ set_namestring (union dnttentry *sym, char **namep, struct objfile *objfile)
+ {
+   /* Note that we "know" that the name for any symbol is always in the same
+      place.  Hence we don't have to conditionalize on the symbol type.  */
+   if (! hpread_has_name ((sym)->dblock.kind))
+     *namep = "";
+   else if (((unsigned)(sym)->dsfile.name) >= VT_SIZE (objfile))
+     {
+       complaint (&symfile_complaints, "bad string table offset in symbol %d",
+ 		 symnum);
+       *namep = "";
+     }
+   else
+     *namep = (sym)->dsfile.name + VT (objfile);
+ }
+ 
  /* Call PXDB to process our file.
  
     Approach copied from DDE's "dbgk_run_pxdb".  Note: we
*************** hpread_build_psymtabs (struct objfile *o
*** 1917,1923 ****
  
  		/* A source file of some kind.  Note this may simply
  		   be an included file.  */
! 		SET_NAMESTRING (dn_bufp, &namestring, objfile);
  
  		/* Check if this is the source file we are already working
  		   with.  */
--- 1925,1931 ----
  
  		/* A source file of some kind.  Note this may simply
  		   be an included file.  */
! 		set_namestring (dn_bufp, &namestring, objfile);
  
  		/* Check if this is the source file we are already working
  		   with.  */
*************** hpread_build_psymtabs (struct objfile *o
*** 2022,2028 ****
  		}
  
  	      /* Now begin a new module and a new psymtab for it */
! 	      SET_NAMESTRING (dn_bufp, &namestring, objfile);
  	      valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
  	      valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
  	      if (!pst)
--- 2030,2036 ----
  		}
  
  	      /* Now begin a new module and a new psymtab for it */
! 	      set_namestring (dn_bufp, &namestring, objfile);
  	      valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
  	      valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
  	      if (!pst)
*************** hpread_build_psymtabs (struct objfile *o
*** 2048,2054 ****
  		texthigh = valu;
  	      valu = dn_bufp->dfunc.lowaddr +
  		ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
! 	      SET_NAMESTRING (dn_bufp, &namestring, objfile);
  	      if (dn_bufp->dfunc.global)
  		add_psymbol_to_list (namestring, strlen (namestring),
  				     VAR_NAMESPACE, LOC_BLOCK,
--- 2056,2062 ----
  		texthigh = valu;
  	      valu = dn_bufp->dfunc.lowaddr +
  		ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
! 	      set_namestring (dn_bufp, &namestring, objfile);
  	      if (dn_bufp->dfunc.global)
  		add_psymbol_to_list (namestring, strlen (namestring),
  				     VAR_NAMESPACE, LOC_BLOCK,
*************** hpread_build_psymtabs (struct objfile *o
*** 2069,2075 ****
  		texthigh = valu;
  	      valu = dn_bufp->ddocfunc.lowaddr +
  		ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
! 	      SET_NAMESTRING (dn_bufp, &namestring, objfile);
  	      if (dn_bufp->ddocfunc.global)
  		add_psymbol_to_list (namestring, strlen (namestring),
  				     VAR_NAMESPACE, LOC_BLOCK,
--- 2077,2083 ----
  		texthigh = valu;
  	      valu = dn_bufp->ddocfunc.lowaddr +
  		ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
! 	      set_namestring (dn_bufp, &namestring, objfile);
  	      if (dn_bufp->ddocfunc.global)
  		add_psymbol_to_list (namestring, strlen (namestring),
  				     VAR_NAMESPACE, LOC_BLOCK,
*************** hpread_build_psymtabs (struct objfile *o
*** 2143,2149 ****
  		else
  		  storage = LOC_UNDEF;
  
! 		SET_NAMESTRING (dn_bufp, &namestring, objfile);
  		if (!pst)
  		  {
  		    pst = hpread_start_psymtab (objfile,
--- 2151,2157 ----
  		else
  		  storage = LOC_UNDEF;
  
! 		set_namestring (dn_bufp, &namestring, objfile);
  		if (!pst)
  		  {
  		    pst = hpread_start_psymtab (objfile,
*************** hpread_build_psymtabs (struct objfile *o
*** 2227,2233 ****
  	    case DNTT_TYPE_MEMENUM:
  	    case DNTT_TYPE_CONST:
  	      /* Constants and members of enumerated types.  */
! 	      SET_NAMESTRING (dn_bufp, &namestring, objfile);
  	      if (!pst)
  		{
  		  pst = hpread_start_psymtab (objfile,
--- 2235,2241 ----
  	    case DNTT_TYPE_MEMENUM:
  	    case DNTT_TYPE_CONST:
  	      /* Constants and members of enumerated types.  */
! 	      set_namestring (dn_bufp, &namestring, objfile);
  	      if (!pst)
  		{
  		  pst = hpread_start_psymtab (objfile,
*************** hpread_expand_symtab (struct objfile *ob
*** 2827,2834 ****
        if (dn_bufp->dblock.extension)
  	continue;
  
!       /* Yow!  We call SET_NAMESTRING on things without names!  */
!       SET_NAMESTRING (dn_bufp, &namestring, objfile);
  
        hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets,
  				       objfile, text_offset, text_size,
--- 2835,2842 ----
        if (dn_bufp->dblock.extension)
  	continue;
  
!       /* Yow!  We call set_namestring on things without names!  */
!       set_namestring (dn_bufp, &namestring, objfile);
  
        hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets,
  				       objfile, text_offset, text_size,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] Replace SET_NAMESTRING macro by function in hpread.c
  2003-01-11  9:32 [RFA] Replace SET_NAMESTRING macro by function in hpread.c Joel Brobecker
@ 2003-01-11 17:48 ` Daniel Jacobowitz
  2003-01-12 11:51   ` Joel Brobecker
  2003-01-11 18:31 ` Andrew Cagney
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-01-11 17:48 UTC (permalink / raw)
  To: gdb-patches

On Sat, Jan 11, 2003 at 01:31:46PM +0400, Joel Brobecker wrote:
> In the name of macros-are-evil, as suggested by AndrewC, I replaced
> the SET_NAMESTRING macro by a function...
> 
> 2003-01-10  J. Brobecker  <brobecker@gnat.com>
> 
>         * hpread.c (set_namestring): New procedure replacing the
>         SET_NAMESTRING macro.
>         (hpread_build_psymtabs): Replace calls to SET_NAMESTRING
>         by calls to set_namestring.
> 
> Ok to apply?

Yes, if...
> +   if (! hpread_has_name ((sym)->dblock.kind))

Please lose all the extra parentheses from the macro definition.


-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] Replace SET_NAMESTRING macro by function in hpread.c
  2003-01-11  9:32 [RFA] Replace SET_NAMESTRING macro by function in hpread.c Joel Brobecker
  2003-01-11 17:48 ` Daniel Jacobowitz
@ 2003-01-11 18:31 ` Andrew Cagney
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2003-01-11 18:31 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, Daniel Jacobowitz

> In the name of macros-are-evil, as suggested by AndrewC, I replaced
> the SET_NAMESTRING macro by a function...
> 
> 2003-01-10  J. Brobecker  <brobecker@gnat.com>
> 
>         * hpread.c (set_namestring): New procedure replacing the
>         SET_NAMESTRING macro.
>         (hpread_build_psymtabs): Replace calls to SET_NAMESTRING
>         by calls to set_namestring.
> 
> Ok to apply?

It's obvious.  With or with out the suggested stray paren cleanup.

(Macro's are bad m'kay).

Andrew



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] Replace SET_NAMESTRING macro by function in hpread.c
  2003-01-11 17:48 ` Daniel Jacobowitz
@ 2003-01-12 11:51   ` Joel Brobecker
  0 siblings, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2003-01-12 11:51 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 501 bytes --]

> > 2003-01-10  J. Brobecker  <brobecker@gnat.com>
> > 
> >         * hpread.c (set_namestring): New procedure replacing the
> >         SET_NAMESTRING macro.
> >         (hpread_build_psymtabs): Replace calls to SET_NAMESTRING
> >         by calls to set_namestring.
> > 
> > Ok to apply?
> 
> Yes, if...
> > +   if (! hpread_has_name ((sym)->dblock.kind))
> 
> Please lose all the extra parentheses from the macro definition.

Thanks. Attached is the actual change that I just checked in.

-- 
Joel

[-- Attachment #2: hpread.c.diff --]
[-- Type: text/plain, Size: 7133 bytes --]

Index: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.30
diff -c -3 -p -r1.30 hpread.c
*** hpread.c	11 Jan 2003 02:13:22 -0000	1.30
--- hpread.c	12 Jan 2003 11:46:03 -0000
*************** struct hpread_symfile_info
*** 87,109 ****
  #define WITHIN_FUNCTION(o)      (HPUX_SYMFILE_INFO(o)->within_function)
  #define CURRENT_FUNCTION_VALUE(o) (HPUX_SYMFILE_INFO(o)->current_function_value)
  
- /* Given the native debug symbol SYM, set NAMEP to the name associated
-    with the debug symbol.  Note we may be called with a debug symbol which
-    has no associated name, in that case we return an empty string.
- 
-    Also note we "know" that the name for any symbol is always in the
-    same place.  Hence we don't have to conditionalize on the symbol type.  */
- #define SET_NAMESTRING(SYM, NAMEP, OBJFILE) \
-   if (! hpread_has_name ((SYM)->dblock.kind)) \
-     *NAMEP = ""; \
-   else if (((unsigned)(SYM)->dsfile.name) >= VT_SIZE (OBJFILE)) \
-     { \
-       complaint (&symfile_complaints, "bad string table offset in symbol %d", \
- 		 symnum); \
-       *NAMEP = ""; \
-     } \
-   else \
-     *NAMEP = (SYM)->dsfile.name + VT (OBJFILE)
  \f
  /* We put a pointer to this structure in the read_symtab_private field
     of the psymtab.  */
--- 87,92 ----
*************** lbrac_mismatch_complaint (int arg1)
*** 155,160 ****
--- 138,146 ----
  
  /* Forward procedure declarations */
  
+ static void set_namestring (union dnttentry *sym, char **namep,
+                             struct objfile *objfile);
+ 
  void hpread_symfile_init (struct objfile *);
  
  void do_pxdb (bfd *);
*************** trans_lang (enum hp_language in_lang)
*** 302,307 ****
--- 288,315 ----
  
  static char main_string[] = "main";
  \f
+ 
+ /* Given the native debug symbol SYM, set NAMEP to the name associated
+    with the debug symbol.  Note we may be called with a debug symbol which
+    has no associated name, in that case we return an empty string.  */
+ 
+ static void
+ set_namestring (union dnttentry *sym, char **namep, struct objfile *objfile)
+ {
+   /* Note that we "know" that the name for any symbol is always in the same
+      place.  Hence we don't have to conditionalize on the symbol type.  */
+   if (! hpread_has_name (sym->dblock.kind))
+     *namep = "";
+   else if ((unsigned) sym->dsfile.name >= VT_SIZE (objfile))
+     {
+       complaint (&symfile_complaints, "bad string table offset in symbol %d",
+ 		 symnum);
+       *namep = "";
+     }
+   else
+     *namep = sym->dsfile.name + VT (objfile);
+ }
+ 
  /* Call PXDB to process our file.
  
     Approach copied from DDE's "dbgk_run_pxdb".  Note: we
*************** hpread_build_psymtabs (struct objfile *o
*** 1917,1923 ****
  
  		/* A source file of some kind.  Note this may simply
  		   be an included file.  */
! 		SET_NAMESTRING (dn_bufp, &namestring, objfile);
  
  		/* Check if this is the source file we are already working
  		   with.  */
--- 1925,1931 ----
  
  		/* A source file of some kind.  Note this may simply
  		   be an included file.  */
! 		set_namestring (dn_bufp, &namestring, objfile);
  
  		/* Check if this is the source file we are already working
  		   with.  */
*************** hpread_build_psymtabs (struct objfile *o
*** 2022,2028 ****
  		}
  
  	      /* Now begin a new module and a new psymtab for it */
! 	      SET_NAMESTRING (dn_bufp, &namestring, objfile);
  	      valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
  	      valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
  	      if (!pst)
--- 2030,2036 ----
  		}
  
  	      /* Now begin a new module and a new psymtab for it */
! 	      set_namestring (dn_bufp, &namestring, objfile);
  	      valu = hpread_get_textlow (i, hp_symnum, objfile, symcount);
  	      valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
  	      if (!pst)
*************** hpread_build_psymtabs (struct objfile *o
*** 2048,2054 ****
  		texthigh = valu;
  	      valu = dn_bufp->dfunc.lowaddr +
  		ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
! 	      SET_NAMESTRING (dn_bufp, &namestring, objfile);
  	      if (dn_bufp->dfunc.global)
  		add_psymbol_to_list (namestring, strlen (namestring),
  				     VAR_NAMESPACE, LOC_BLOCK,
--- 2056,2062 ----
  		texthigh = valu;
  	      valu = dn_bufp->dfunc.lowaddr +
  		ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
! 	      set_namestring (dn_bufp, &namestring, objfile);
  	      if (dn_bufp->dfunc.global)
  		add_psymbol_to_list (namestring, strlen (namestring),
  				     VAR_NAMESPACE, LOC_BLOCK,
*************** hpread_build_psymtabs (struct objfile *o
*** 2069,2075 ****
  		texthigh = valu;
  	      valu = dn_bufp->ddocfunc.lowaddr +
  		ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
! 	      SET_NAMESTRING (dn_bufp, &namestring, objfile);
  	      if (dn_bufp->ddocfunc.global)
  		add_psymbol_to_list (namestring, strlen (namestring),
  				     VAR_NAMESPACE, LOC_BLOCK,
--- 2077,2083 ----
  		texthigh = valu;
  	      valu = dn_bufp->ddocfunc.lowaddr +
  		ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
! 	      set_namestring (dn_bufp, &namestring, objfile);
  	      if (dn_bufp->ddocfunc.global)
  		add_psymbol_to_list (namestring, strlen (namestring),
  				     VAR_NAMESPACE, LOC_BLOCK,
*************** hpread_build_psymtabs (struct objfile *o
*** 2143,2149 ****
  		else
  		  storage = LOC_UNDEF;
  
! 		SET_NAMESTRING (dn_bufp, &namestring, objfile);
  		if (!pst)
  		  {
  		    pst = hpread_start_psymtab (objfile,
--- 2151,2157 ----
  		else
  		  storage = LOC_UNDEF;
  
! 		set_namestring (dn_bufp, &namestring, objfile);
  		if (!pst)
  		  {
  		    pst = hpread_start_psymtab (objfile,
*************** hpread_build_psymtabs (struct objfile *o
*** 2227,2233 ****
  	    case DNTT_TYPE_MEMENUM:
  	    case DNTT_TYPE_CONST:
  	      /* Constants and members of enumerated types.  */
! 	      SET_NAMESTRING (dn_bufp, &namestring, objfile);
  	      if (!pst)
  		{
  		  pst = hpread_start_psymtab (objfile,
--- 2235,2241 ----
  	    case DNTT_TYPE_MEMENUM:
  	    case DNTT_TYPE_CONST:
  	      /* Constants and members of enumerated types.  */
! 	      set_namestring (dn_bufp, &namestring, objfile);
  	      if (!pst)
  		{
  		  pst = hpread_start_psymtab (objfile,
*************** hpread_expand_symtab (struct objfile *ob
*** 2827,2834 ****
        if (dn_bufp->dblock.extension)
  	continue;
  
!       /* Yow!  We call SET_NAMESTRING on things without names!  */
!       SET_NAMESTRING (dn_bufp, &namestring, objfile);
  
        hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets,
  				       objfile, text_offset, text_size,
--- 2835,2842 ----
        if (dn_bufp->dblock.extension)
  	continue;
  
!       /* Yow!  We call set_namestring on things without names!  */
!       set_namestring (dn_bufp, &namestring, objfile);
  
        hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets,
  				       objfile, text_offset, text_size,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-12 11:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-11  9:32 [RFA] Replace SET_NAMESTRING macro by function in hpread.c Joel Brobecker
2003-01-11 17:48 ` Daniel Jacobowitz
2003-01-12 11:51   ` Joel Brobecker
2003-01-11 18:31 ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox