Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* (patch) hpjyg21: FAT_FREE_PSYMTABS
@ 1999-11-11 12:53 Jimmy Guo
  1999-11-11 15:10 ` Andrew Cagney
  0 siblings, 1 reply; 2+ messages in thread
From: Jimmy Guo @ 1999-11-11 12:53 UTC (permalink / raw)
  To: gdb-patches

***
Patch dependecies: hpjyg05 (config/pa/tm-hppa.h)
		   hpjyg16 (symtab.c)
		   hpjyg20 (symtab.c)
***

This patch contains:

- addition of codes ifdef'd by FAT_FREE_PSYMTABS to rely on linker
  symbol table entries to determine which translation unit's partial
  symbol table must be expanded.  Here is a more complete overview of
  this feature:
        We use the partial symbol tables to identify which TU's partial
	symbol table must be expanded to get further information about a
	symbol. This decision can also be made by consulting the minimal
	symbol table, determining the address of the symbol therefrom
	and finding out which partial symbol table's address range
	(texthigh & textlow) envelops the symbol's address.

        If we are successful in using the minimal symbol table to zoom
	in on which psymtab to expand, then we could eliminate the
	"kernels" of these N partial symbol tables and build just the shell. 

ChangeLog:

1999-11-11	Jimmy Guo	<guo@cup.hp.com>

	* symtab.c: FAT_FREE_PSYMTABS support.
	(find_pc_sect_psymtab): If find_pc_sect_psymbol failed to find a
        psymtab, check textlow and texthigh and return tpst if it houses
        pc + 4.
	(find_main_psymtab): Fall back to linker symbol table to find
        the psymtab housing psymbol.
	(find_functions): Iterate over linker symbol table to expand the
	psymtab containing psymbol.
	(expand_containing_psymtab): New function.

	* minsyms.c (foreach_text_minsym): New function.

	* config/pa/tm-hppa.h (FAT_FREE_PSYMTABS): Define.

Index: gdb/symtab.c
/opt/gnu/bin/diff -r -c -N  /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/symtab.c gdb/symtab.c
*** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/symtab.c	Thu Nov 11 12:45:24 1999
--- gdb/symtab.c	Thu Nov 11 12:34:12 1999
***************
*** 449,454 ****
--- 449,477 ----
  
  		p = find_pc_sect_psymbol (tpst, pc, section);
  
+ #ifdef FAT_FREE_PSYMTABS
+ 
+ 		/* srikanth, in the case of the Wildebeest, the psymtabs could be empty
+ 		   and hence the call to find_pc_sect_psymbol() could fail to find anything.
+ 		   Due potentially to a combination of bugs in compilers, linkers, loaders,
+ 		   editors and debugger engineers :-), sometimes there is an overlap of
+ 		   textlow and texthigh values between and multiple psymtabs. As a result,
+ 		   if we are handed an address equal to the texthigh or textlow, we could
+ 		   end up identifying the wrong psymtab.
+ 
+ 		   To be absolutely sure of the identity of the psymtab, let us verify that
+ 		   the one we narrow down on, also houses pc + 4.
+ 		 */
+ 
+ 		if (p == NULL)
+ 		  {
+ 		    CORE_ADDR pc_plus4 = pc + 4;
+ 		    if (pc_plus4 >= tpst->textlow &&
+ 			pc_plus4 <= tpst->texthigh)
+ 		      return tpst;
+ 		  }
+ #endif
+ 
  		if (p != NULL
  		    && SYMBOL_VALUE_ADDRESS (p)
  		    == SYMBOL_VALUE_ADDRESS (msymbol))
***************
*** 1367,1372 ****
--- 1390,1408 ----
        }
    }
  
+ #ifdef FAT_FREE_PSYMTABS
+ 
+   /* srikanth, under the new world order, psymtabs could be empty
+      for the Wildebeest. Fall back on the linker symbol table, use the
+      address therefrom to find out which psymtab would have housed the
+      psymbol were one to exist.
+    */
+ 
+   if ((m = lookup_minimal_symbol_text (default_main, NULL, NULL)))
+     return find_pc_psymtab (SYMBOL_VALUE_ADDRESS (m));
+ 
+ #endif
+ 
    return (NULL);
  }
  
***************
*** 2725,2730 ****
--- 2761,2785 ----
    return (i1);
  }
  
+ #ifdef FAT_FREE_PSYMTABS
+ 
+ static void
+ expand_containing_psymtab (m)
+      struct minimal_symbol *m;
+ {
+   struct objfile *objfile;
+   struct partial_symtab *pst = NULL;
+   CORE_ADDR pc;
+ 
+   if (m)
+     pst = find_pc_psymtab (SYMBOL_VALUE_ADDRESS (m));
+ 
+   if (pst && !pst->readin)
+     PSYMTAB_TO_SYMTAB (pst);
+ }
+ 
+ #endif
+ 
  /* Helper function for decode_line_1.
     Look for functions named NAME in all the symbol tables.
     Return number of matches.
***************
*** 2812,2817 ****
--- 2867,2887 ----
    /* If we found match(es) in the current source file we are done */
    if (i1)
      goto lookup_over;
+ 
+ #ifdef FAT_FREE_PSYMTABS
+ 
+   /* srikanth, in the case of the Wildebeest, the psymtabs are no 
+      longer populated with psymbols. We need to rely on the linker
+      symbol table to lookup the symbol, use its address to decide 
+      which psymtab would have housed the psymbol, were one to exist.
+      The function `foreach_text_minsym' is an iterator, which would
+      call its second argument for each matched minimal symbol
+      (mst_text and mst_file_text) and pass the match.
+    */
+ 
+   foreach_text_minsym (name, expand_containing_psymtab);
+ 
+ #endif
  
    /* Now search all the global symbols.  Do the symtab's first, then
       check the psymtab's. If a psymtab indicates the existence
Index: gdb/minsyms.c
/opt/gnu/bin/diff -r -c -N  /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/minsyms.c gdb/minsyms.c
*** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/minsyms.c	Wed Nov 10 12:30:56 1999
--- gdb/minsyms.c	Thu Nov 11 09:25:44 1999
***************
*** 80,85 ****
--- 80,108 ----
  static int
  compact_minimal_symbols PARAMS ((struct minimal_symbol *, int));
  
+ /* srikanth, an iterator for functions in the linker symbol table.
+    Looks up `name' and for each matching symbol, calls `action' and
+    passes the selected symbol. */
+ 
+ void 
+ foreach_text_minsym (name, action)
+      char *name;
+      void (*action) (struct minimal_symbol *);
+ {
+ 
+   struct objfile *objfile;
+   struct minimal_symbol m, *msymbol = &m;
+   char *mangled_prefix;
+ 
+   ALL_MSYMBOLS (objfile, msymbol)
+   {
+     if (MSYMBOL_TYPE (msymbol) == mst_text ||
+ 	MSYMBOL_TYPE (msymbol) == mst_file_text)
+       if (SYMBOL_MATCHES_NAME (msymbol, name))
+ 	action (msymbol);
+   }
+ }
+ 
  /* Look through all the current minimal symbol tables and find the
     first minimal symbol that matches NAME.  If OBJF is non-NULL, limit
     the search to that objfile.  If SFILE is non-NULL, limit the search
Index: gdb/config/pa/tm-hppa.h
/opt/gnu/bin/diff -r -c -N  /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/config/pa/tm-hppa.h gdb/config/pa/tm-hppa.h
*** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/config/pa/tm-hppa.h	Tue Nov  2 16:04:12 1999
--- gdb/config/pa/tm-hppa.h	Wed Nov 10 12:06:11 1999
***************
*** 146,152 ****
     top byte of the address for all 1's.  Sigh.
   */
  #define PC_REQUIRES_RUN_BEFORE_USE(pc) \
!   (! target_has_stack && (pc & 0xFF000000))
  
  /* return instruction is bv r0(rp) or bv,n r0(rp) */
  
--- 146,152 ----
     top byte of the address for all 1's.  Sigh.
   */
  #define PC_REQUIRES_RUN_BEFORE_USE(pc) \
!   (! target_has_stack && ((pc & 0xFF000000) == 0xFF000000))
  
  /* return instruction is bv r0(rp) or bv,n r0(rp) */
  
***************
*** 331,337 ****
      else \
        memcpy ((VALBUF), \
  	      (char *)(REGBUF) + REGISTER_BYTE (28) + \
! 	      (TYPE_LENGTH (TYPE) > 4 ? (8 - TYPE_LENGTH (TYPE)) : (4 - TYPE_LENGTH (TYPE))), \
  	      TYPE_LENGTH (TYPE)); \
    }
  
--- 331,337 ----
      else \
        memcpy ((VALBUF), \
  	      (char *)(REGBUF) + REGISTER_BYTE (28) + \
! 	      (TYPE_LENGTH (TYPE) > 4 ? (8 - TYPE_LENGTH (TYPE)) : (REGISTER_SIZE - TYPE_LENGTH (TYPE))), \
  	      TYPE_LENGTH (TYPE)); \
    }
  
***************
*** 810,815 ****
--- 810,817 ----
  		 || (strncmp ((symname), "$PIC", 4) == 0)               \
  		 || ((symname)[0] == '$' && isdigit ((symname)[1]))     \
  		 ))
+ 
+ #define FAT_FREE_PSYMTABS
  
  /* Here's how to step off a permanent breakpoint.  */
  #define SKIP_PERMANENT_BREAKPOINT (hppa_skip_permanent_breakpoint)


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

* Re: (patch) hpjyg21: FAT_FREE_PSYMTABS
  1999-11-11 12:53 (patch) hpjyg21: FAT_FREE_PSYMTABS Jimmy Guo
@ 1999-11-11 15:10 ` Andrew Cagney
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cagney @ 1999-11-11 15:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jimmy Guo

Maintainers,

I've another meta maintainer question on this :-)

Is it better to use #ifdef or have the compiler eliminate optional
code?  For instance:

	if (FAT_FREE_PSYMTABS)
	  {
	  }

If the compiler does the elimination (instead of CPP) the code is always
being checked and hence less likely to suffer bit rot.

Yes I know it's something of a radical departure from the existing
conventions.

Andrew


> + #ifdef FAT_FREE_PSYMTABS
> +
> +               /* srikanth, in the case of the Wildebeest, the psymtabs could be empty
> +                  and hence the call to find_pc_sect_psymbol() could fail to find anything.
> +                  Due potentially to a combination of bugs in compilers, linkers, loaders,
> +                  editors and debugger engineers :-), sometimes there is an overlap of
> +                  textlow and texthigh values between and multiple psymtabs. As a result,
> +                  if we are handed an address equal to the texthigh or textlow, we could
> +                  end up identifying the wrong psymtab.
> +
> +                  To be absolutely sure of the identity of the psymtab, let us verify that
> +                  the one we narrow down on, also houses pc + 4.
> +                */
> +
> +               if (p == NULL)
> +                 {
> +                   CORE_ADDR pc_plus4 = pc + 4;
> +                   if (pc_plus4 >= tpst->textlow &&
> +                       pc_plus4 <= tpst->texthigh)
> +                     return tpst;
> +                 }
> + #endif
From shebs@cygnus.com Thu Nov 11 15:41:00 1999
From: Stan Shebs <shebs@cygnus.com>
To: cagney@cygnus.com
Cc: gdb-patches@sourceware.cygnus.com, guo@cup.hp.com
Subject: Re: (patch) hpjyg21: FAT_FREE_PSYMTABS
Date: Thu, 11 Nov 1999 15:41:00 -0000
Message-id: <199911112341.PAA29252@andros.cygnus.com>
References: <382B4CD6.4B13DFA1@cygnus.com>
X-SW-Source: 1999-q4/msg00238.html
Content-length: 1094

   Date: Fri, 12 Nov 1999 10:10:14 +1100
   From: Andrew Cagney <ac131313@cygnus.com>

   I've another meta maintainer question on this :-)

   Is it better to use #ifdef or have the compiler eliminate optional
   code?  For instance:

	   if (FAT_FREE_PSYMTABS)
	     {
	     }

I favor this over ifdefs.  Not only does it facilitate maintenance,
but it leaves open options for cross-debugging and for making
decisions at runtime.  The only reasonable exception would be provably
time-critical code where ifdefs would allow compiler optimizations not
available if the code were merely "if (0)".  (There might be examples
of this in the stabs reader, although I don't know of any myself.)

   If the compiler does the elimination (instead of CPP) the code is always
   being checked and hence less likely to suffer bit rot.

   Yes I know it's something of a radical departure from the existing
   conventions.

A departure from habit, true, but there's not a rule that says "use
more ifdefs".  Ifdefs are the easy way out, but we want to go the
right way, not the expedient way.

								Stan
From ac131313@cygnus.com Thu Nov 11 15:52:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: Jimmy Guo <guo@cup.hp.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: (patch) hpjyg15: hppah-nat.c & related
Date: Thu, 11 Nov 1999 15:52:00 -0000
Message-id: <382B5609.A4548C6D@cygnus.com>
References: <Pine.LNX.4.10.9911081520150.2309-100000@hpcll168.cup.hp.com>
X-SW-Source: 1999-q4/msg00239.html
Content-length: 1445

Jimmy Guo wrote:
> 
> This patch updates hppah-nat.c and related files target.[ch] and
> infrun.c.  See ChangeLog below.
> 
> - Jimmy Guo, guo@cup.hp.com
> 
> ChangeLog
> 
> 1999-11-08      Jimmy Guo       <guo@cup.hp.com>
> 
>         * hppah-nat.c (child_xfer_memory): when reading, also try the
>           other way.
>           (require_notification_of_events): start by ignoring all
>           signals and then adding back in ones we're interested in.
>           (child_has_execd): cache pathname info, used for the 2nd exec
>           event reported by ptrace.
>           (child_pid_to_exec_file): make sure ptrace request for
>           pathname is made after an exec.
> 
>         * target.c (target_signal_exists): New function.  Given a GDB
>           target signal enum, return 1 if it's available on the host.
> 
>         * target.h (target_signal_exists): Declare.

I'd prefer the name (target_signal_p()) (Well actually I don't prefer
that name but its more consistent with the general naming convetion :-).

I'll check in a change to target.[ch] that adds the target_singal_p(). 
Hmm, I might do it slightly differently - were getting too many separate
places where there is code like:

	#if SIG...
	   case TARGET_SIGNAL...
	#endif

With that in, can the hppa-nat.c be re-submitted?  BTW, you might also
split it, I think it contains two changes - the code that uses this new
function and something else.

enjoy,
	Andrew
From ac131313@cygnus.com Thu Nov 11 16:03:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: Jimmy Guo <guo@cup.hp.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: (patch) hpjyg15: hppah-nat.c & related
Date: Thu, 11 Nov 1999 16:03:00 -0000
Message-id: <382B585D.421E98F3@cygnus.com>
References: <Pine.LNX.4.10.9911081520150.2309-100000@hpcll168.cup.hp.com>
X-SW-Source: 1999-q4/msg00240.html
Content-length: 25465

Jimmy Guo wrote:
> 
> This patch updates hppah-nat.c and related files target.[ch] and
> infrun.c.  See ChangeLog below.

Jim,

Don't forget that the GDB's coding style is defined by the output of
indent.  Looking more closely I noticed that some of the changes are to
``fix'' the indentation. Please just grit your teath and ignore it.

It's a good idea to carefully review the diffs and revert/remove any
changes not specific to the problem at hand.

Doing this makes the reviewers life so much easier.

	enjoy,
		Andrew


> ***************
> *** 74,80 ****
>         len = REGISTER_RAW_SIZE (regno);
> 
>         /* Requests for register zero actually want the save_state's
> !        ss_flags member.  As RM says: "Oh, what a hack!"  */
>         if (regno == 0)
>         {
>           save_state_t ss;
> --- 74,80 ----
>         len = REGISTER_RAW_SIZE (regno);
> 
>         /* Requests for register zero actually want the save_state's
> !          ss_flags member.  As RM says: "Oh, what a hack!"  */
>         if (regno == 0)
>         {
>           save_state_t ss;
> ***************
> *** 90,109 ****
> 
>         /* Floating-point registers come from the ss_fpblock area.  */
>         else if (regno >= FP0_REGNUM)
> !       addr = (HPPAH_OFFSETOF (save_state_t, ss_fpblock)
>                 + (REGISTER_BYTE (regno) - REGISTER_BYTE (FP0_REGNUM)));
> 
>         /* Wide registers come from the ss_wide area.
> !        I think it's more PC to test (ss_flags & SS_WIDEREGS) to select
> !        between ss_wide and ss_narrow than to use the raw register size.
> !        But checking ss_flags would require an extra ptrace call for
> !        every register reference.  Bleah.  */
>         else if (len == 8)
> !       addr = (HPPAH_OFFSETOF (save_state_t, ss_wide)
>                 + REGISTER_BYTE (regno));
> 
>         /* Narrow registers come from the ss_narrow area.  Note that
> !        ss_narrow starts with gr1, not gr0.  */
>         else if (len == 4)
>         addr = (HPPAH_OFFSETOF (save_state_t, ss_narrow)
>                 + (REGISTER_BYTE (regno) - REGISTER_BYTE (1)));
> --- 90,109 ----
> 
>         /* Floating-point registers come from the ss_fpblock area.  */
>         else if (regno >= FP0_REGNUM)
> !       addr = (HPPAH_OFFSETOF (save_state_t, ss_fpblock)
>                 + (REGISTER_BYTE (regno) - REGISTER_BYTE (FP0_REGNUM)));
> 
>         /* Wide registers come from the ss_wide area.
> !          I think it's more PC to test (ss_flags & SS_WIDEREGS) to select
> !          between ss_wide and ss_narrow than to use the raw register size.
> !          But checking ss_flags would require an extra ptrace call for
> !          every register reference.  Bleah.  */
>         else if (len == 8)
> !       addr = (HPPAH_OFFSETOF (save_state_t, ss_wide)
>                 + REGISTER_BYTE (regno));
> 
>         /* Narrow registers come from the ss_narrow area.  Note that
> !          ss_narrow starts with gr1, not gr0.  */
>         else if (len == 4)
>         addr = (HPPAH_OFFSETOF (save_state_t, ss_narrow)
>                 + (REGISTER_BYTE (regno) - REGISTER_BYTE (1)));
> ***************
> *** 112,131 ****
> 
>   #ifdef GDB_TARGET_IS_HPPA_20W
>         /* Unbelieveable.  The PC head and tail must be written in 64bit hunks
> !        or we will get an error.  Worse yet, the oddball ptrace/ttrace
> !        layering will not allow us to perform a 64bit register store.
> 
> !        What a crock.  */
>         if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM && len == 8)
>         {
>           CORE_ADDR temp;
> 
> !         temp = *(CORE_ADDR *)&registers[REGISTER_BYTE (regno)];
> 
>           /* Set the priv level (stored in the low two bits of the PC.  */
>           temp |= 0x3;
> 
> !         ttrace_write_reg_64 (inferior_pid, (CORE_ADDR)addr, (CORE_ADDR)&temp);
> 
>           /* If we fail to write the PC, give a true error instead of
>              just a warning.  */
> --- 112,131 ----
> 
>   #ifdef GDB_TARGET_IS_HPPA_20W
>         /* Unbelieveable.  The PC head and tail must be written in 64bit hunks
> !          or we will get an error.  Worse yet, the oddball ptrace/ttrace
> !          layering will not allow us to perform a 64bit register store.
> 
> !          What a crock.  */
>         if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM && len == 8)
>         {
>           CORE_ADDR temp;
> 
> !         temp = *(CORE_ADDR *) &registers[REGISTER_BYTE (regno)];
> 
>           /* Set the priv level (stored in the low two bits of the PC.  */
>           temp |= 0x3;
> 
> !         ttrace_write_reg_64 (inferior_pid, (CORE_ADDR) addr, (CORE_ADDR) &temp);
> 
>           /* If we fail to write the PC, give a true error instead of
>              just a warning.  */
> ***************
> *** 134,150 ****
>               char *err = safe_strerror (errno);
>               char *msg = alloca (strlen (err) + 128);
>               sprintf (msg, "writing `%s' register: %s",
> !                       REGISTER_NAME (regno), err);
>               perror_with_name (msg);
>             }
>           return;
>         }
> 
>         /* Another crock.  HPUX complains if you write a nonzero value to
> !        the high part of IPSW.  What will it take for HP to catch a
> !        clue about building sensible interfaces?  */
> !      if (regno == IPSW_REGNUM && len == 8)
> !       *(int *)&registers[REGISTER_BYTE (regno)] = 0;
>   #endif
> 
>         for (i = 0; i < len; i += sizeof (int))
> --- 134,150 ----
>               char *err = safe_strerror (errno);
>               char *msg = alloca (strlen (err) + 128);
>               sprintf (msg, "writing `%s' register: %s",
> !                      REGISTER_NAME (regno), err);
>               perror_with_name (msg);
>             }
>           return;
>         }
> 
>         /* Another crock.  HPUX complains if you write a nonzero value to
> !          the high part of IPSW.  What will it take for HP to catch a
> !          clue about building sensible interfaces?  */
> !       if (regno == IPSW_REGNUM && len == 8)
> !       *(int *) &registers[REGISTER_BYTE (regno)] = 0;
>   #endif
> 
>         for (i = 0; i < len; i += sizeof (int))
> ***************
> *** 155,167 ****
>           if (errno != 0)
>             {
>               /* Warning, not error, in case we are attached; sometimes
> !                the kernel doesn't let us at the registers. */
>               char *err = safe_strerror (errno);
>               char *msg = alloca (strlen (err) + 128);
>               sprintf (msg, "writing `%s' register: %s",
> !                       REGISTER_NAME (regno), err);
>               /* If we fail to write the PC, give a true error instead of
> !                just a warning.  */
>               if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
>                 perror_with_name (msg);
>               else
> --- 155,167 ----
>           if (errno != 0)
>             {
>               /* Warning, not error, in case we are attached; sometimes
> !                the kernel doesn't let us at the registers. */
>               char *err = safe_strerror (errno);
>               char *msg = alloca (strlen (err) + 128);
>               sprintf (msg, "writing `%s' register: %s",
> !                      REGISTER_NAME (regno), err);
>               /* If we fail to write the PC, give a true error instead of
> !                just a warning.  */
>               if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
>                 perror_with_name (msg);
>               else
> ***************
> *** 197,212 ****
>         len = sizeof (ss.ss_flags);
> 
>         /* Note that ss_flags is always an int, no matter what
> !        REGISTER_RAW_SIZE(0) says.  Assuming all HP-UX PA machines
> !        are big-endian, put it at the least significant end of the
> !        value, and zap the rest of the buffer.  */
>         offset = REGISTER_RAW_SIZE (0) - len;
>         memset (buf, 0, sizeof (buf));
>       }
> 
>     /* Floating-point registers come from the ss_fpblock area.  */
>     else if (regno >= FP0_REGNUM)
> !     addr = (HPPAH_OFFSETOF (save_state_t, ss_fpblock)
>             + (REGISTER_BYTE (regno) - REGISTER_BYTE (FP0_REGNUM)));
> 
>     /* Wide registers come from the ss_wide area.
> --- 197,212 ----
>         len = sizeof (ss.ss_flags);
> 
>         /* Note that ss_flags is always an int, no matter what
> !          REGISTER_RAW_SIZE(0) says.  Assuming all HP-UX PA machines
> !          are big-endian, put it at the least significant end of the
> !          value, and zap the rest of the buffer.  */
>         offset = REGISTER_RAW_SIZE (0) - len;
>         memset (buf, 0, sizeof (buf));
>       }
> 
>     /* Floating-point registers come from the ss_fpblock area.  */
>     else if (regno >= FP0_REGNUM)
> !     addr = (HPPAH_OFFSETOF (save_state_t, ss_fpblock)
>             + (REGISTER_BYTE (regno) - REGISTER_BYTE (FP0_REGNUM)));
> 
>     /* Wide registers come from the ss_wide area.
> ***************
> *** 215,221 ****
>        But checking ss_flags would require an extra ptrace call for
>        every register reference.  Bleah.  */
>     else if (len == 8)
> !     addr = (HPPAH_OFFSETOF (save_state_t, ss_wide)
>             + REGISTER_BYTE (regno));
> 
>     /* Narrow registers come from the ss_narrow area.  Note that
> --- 215,221 ----
>        But checking ss_flags would require an extra ptrace call for
>        every register reference.  Bleah.  */
>     else if (len == 8)
> !     addr = (HPPAH_OFFSETOF (save_state_t, ss_wide)
>             + REGISTER_BYTE (regno));
> 
>     /* Narrow registers come from the ss_narrow area.  Note that
> ***************
> *** 232,240 ****
>         errno = 0;
>         /* Copy an int from the U area to buf.  Fill the least
>            significant end if len != raw_size.  */
> !       * (int *) &buf[offset + i] =
> !         call_ptrace (PT_RUREGS, inferior_pid,
> !                      (PTRACE_ARG3_TYPE) addr + i, 0);
>         if (errno != 0)
>         {
>           /* Warning, not error, in case we are attached; sometimes
> --- 232,240 ----
>         errno = 0;
>         /* Copy an int from the U area to buf.  Fill the least
>            significant end if len != raw_size.  */
> !       *(int *) &buf[offset + i] =
> !       call_ptrace (PT_RUREGS, inferior_pid,
> !                    (PTRACE_ARG3_TYPE) addr + i, 0);
>         if (errno != 0)
>         {
>           /* Warning, not error, in case we are attached; sometimes
> ***************
> *** 277,283 ****
>   {
>     register int i;
>     /* Round starting address down to longword boundary.  */
> !   register CORE_ADDR addr = memaddr & - (CORE_ADDR)(sizeof (int));
>     /* Round ending address up; get number of longwords that makes.  */
>     register int count
>     = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
> --- 277,283 ----
>   {
>     register int i;
>     /* Round starting address down to longword boundary.  */
> !   register CORE_ADDR addr = memaddr & -(CORE_ADDR) (sizeof (int));
>     /* Round ending address up; get number of longwords that makes.  */
>     register int count
>     = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
> ***************
> *** 363,370 ****
>                                    inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
>           if (errno)
>             {
> !             free (buffer);
> !             return 0;
>             }
>           QUIT;
>         }
> --- 363,379 ----
>                                    inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
>           if (errno)
>             {
> !             /* As above, we may have guessed wrong about code vs. data, so
> !                        try it the other way. */
> !             errno = 0;
> !             buffer[i] = call_ptrace (addr >= text_end ?
> !                                      PT_RIUSER : PT_RDUSER,
> !                                      inferior_pid,
> !                                      (PTRACE_ARG3_TYPE) addr, 0);
> !             if (errno) {
> !               free(buffer);
> !               return 0;
> !             }
>             }
>           QUIT;
>         }
> ***************
> *** 697,702 ****
> --- 706,713 ----
>   {
>   #if defined(PT_SET_EVENT_MASK)
>     int pt_status;
> +   int nsigs;
> +   int signum;
>     ptrace_event_t ptrace_events;
> 
>     /* Instruct the kernel as to the set of events we wish to be
> ***************
> *** 709,715 ****
>        the kernel to keep certain signals hidden from us, we do it
>        by calling sigdelset (ptrace_events.pe_signals, signal) for
>        each such signal here, before doing PT_SET_EVENT_MASK.  */
> !   sigemptyset (&ptrace_events.pe_signals);
> 
>     ptrace_events.pe_set_event = 0;
> 
> --- 720,749 ----
>        the kernel to keep certain signals hidden from us, we do it
>        by calling sigdelset (ptrace_events.pe_signals, signal) for
>        each such signal here, before doing PT_SET_EVENT_MASK.  */
> !   /* RM: The above comment is no longer true. We start with ignoring
> !    * all signals, and then add the ones we are interested in. We could
> !    * do it the other way: start by looking at all signals and then
> !    * deleting the ones that we aren't interested in, except that
> !    * multiple gdb signals may be mapped to the same host signal
> !    * (eg. TARGET_SIGNAL_IO and TARGET_SIGNAL_POLL both get mapped to
> !    * signal 22 on HPUX 10.20) We want to be notified if we are
> !    * interested in either signal.
> !    */
> !   sigfillset (&ptrace_events.pe_signals);
> !
> !   /* RM: Let's not bother with signals we don't care about */
> !   nsigs = (int) TARGET_SIGNAL_LAST;
> !   for (signum = nsigs; signum > 0; signum--)
> !     {
> !       if ((signal_stop_state (signum)) ||
> !         (signal_print_state (signum)) ||
> !         (!signal_pass_state (signum)))
> !       {
> !         if (target_signal_exists (signum))
> !           sigdelset (&ptrace_events.pe_signals,
> !                      target_signal_to_host (signum));
> !       }
> !     }
> 
>     ptrace_events.pe_set_event = 0;
> 
> ***************
> *** 724,730 ****
>     errno = 0;
>     pt_status = call_ptrace (PT_SET_EVENT_MASK,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) & ptrace_events,
>                            sizeof (ptrace_events));
>     if (errno)
>       perror_with_name ("ptrace");
> --- 758,764 ----
>     errno = 0;
>     pt_status = call_ptrace (PT_SET_EVENT_MASK,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) &ptrace_events,
>                            sizeof (ptrace_events));
>     if (errno)
>       perror_with_name ("ptrace");
> ***************
> *** 763,769 ****
>     errno = 0;
>     pt_status = call_ptrace (PT_SET_EVENT_MASK,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) & ptrace_events,
>                            sizeof (ptrace_events));
>     if (errno)
>       perror_with_name ("ptrace");
> --- 797,803 ----
>     errno = 0;
>     pt_status = call_ptrace (PT_SET_EVENT_MASK,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) &ptrace_events,
>                            sizeof (ptrace_events));
>     if (errno)
>       perror_with_name ("ptrace");
> ***************
> *** 913,919 ****
>     errno = 0;
>     pt_status = call_ptrace (PT_GET_PROCESS_STATE,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) & ptrace_state,
>                            sizeof (ptrace_state));
>     if (errno)
>       perror_with_name ("ptrace");
> --- 947,953 ----
>     errno = 0;
>     pt_status = call_ptrace (PT_GET_PROCESS_STATE,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) &ptrace_state,
>                            sizeof (ptrace_state));
>     if (errno)
>       perror_with_name ("ptrace");
> ***************
> *** 947,953 ****
>     errno = 0;
>     pt_status = call_ptrace (PT_GET_PROCESS_STATE,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) & ptrace_state,
>                            sizeof (ptrace_state));
>     if (errno)
>       perror_with_name ("ptrace");
> --- 981,987 ----
>     errno = 0;
>     pt_status = call_ptrace (PT_GET_PROCESS_STATE,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) &ptrace_state,
>                            sizeof (ptrace_state));
>     if (errno)
>       perror_with_name ("ptrace");
> ***************
> *** 1008,1013 ****
> --- 1042,1049 ----
>        int pid;
>        char **execd_pathname;
>   {
> +   static char saved_pathname[1024];
> +
>     /* This request is only available on HPUX 10.0 and later.  */
>   #if !defined(PT_GET_PROCESS_STATE)
>     *execd_pathname = NULL;
> ***************
> *** 1020,1026 ****
>     errno = 0;
>     pt_status = call_ptrace (PT_GET_PROCESS_STATE,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) & ptrace_state,
>                            sizeof (ptrace_state));
>     if (errno)
>       perror_with_name ("ptrace");
> --- 1056,1062 ----
>     errno = 0;
>     pt_status = call_ptrace (PT_GET_PROCESS_STATE,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) &ptrace_state,
>                            sizeof (ptrace_state));
>     if (errno)
>       perror_with_name ("ptrace");
> ***************
> *** 1029,1036 ****
> 
>     if (ptrace_state.pe_report_event & PTRACE_EXEC)
>       {
> !       char *exec_file = target_pid_to_exec_file (pid);
> !       *execd_pathname = savestring (exec_file, strlen (exec_file));
>         return 1;
>       }
> 
> --- 1065,1083 ----
> 
>     if (ptrace_state.pe_report_event & PTRACE_EXEC)
>       {
> !       char *exec_file;
> !
> !       if (ptrace_state.pe_path_len > 0)
> !       {
> !         /* RM: ptrace reports 2 exec events per exec. Only the first one
> !            allows us to get a valid pathname. For the second one simply
> !            return the previously cached pathname */
> !         exec_file = target_pid_to_exec_file (pid);
> !         *execd_pathname = savestring (exec_file, strlen (exec_file));
> !         strncpy (saved_pathname, exec_file, sizeof (saved_pathname) - 1);
> !       }
> !       else
> !       *execd_pathname = saved_pathname;
>         return 1;
>       }
> 
> ***************
> *** 1064,1069 ****
> --- 1111,1117 ----
>   {
>     static char exec_file_buffer[1024];
>     int pt_status;
> +   ptrace_state_t ptrace_state;
>     CORE_ADDR top_of_stack;
>     char four_chars[4];
>     int name_index;
> ***************
> *** 1073,1084 ****
> 
>   #ifdef PT_GET_PROCESS_PATHNAME
>     /* As of 10.x HP-UX, there's an explicit request to get the pathname. */
> !   pt_status = call_ptrace (PT_GET_PROCESS_PATHNAME,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) exec_file_buffer,
> !                          sizeof (exec_file_buffer) - 1);
> !   if (pt_status == 0)
> !     return exec_file_buffer;
>   #endif
> 
>     /* It appears that this request is broken prior to 10.30.
> --- 1121,1146 ----
> 
>   #ifdef PT_GET_PROCESS_PATHNAME
>     /* As of 10.x HP-UX, there's an explicit request to get the pathname. */
> !   /* RM: According to the documentation, this request only works right
> !    * after an exec */
> !   errno = 0;
> !   pt_status = call_ptrace (PT_GET_PROCESS_STATE,
>                            pid,
> !                          (PTRACE_ARG3_TYPE) &ptrace_state,
> !                          sizeof (ptrace_state));
> !   if (errno)
> !     perror_with_name ("ptrace");
> !
> !   if (ptrace_state.pe_report_event & PTRACE_EXEC)
> !     {
> !       pt_status = call_ptrace (PT_GET_PROCESS_PATHNAME,
> !                              pid,
> !                              (PTRACE_ARG3_TYPE) exec_file_buffer,
> !                              sizeof (exec_file_buffer) - 1);
> !       /* RM: ??? pt_status < 0 indicates failure, I think */
> !       if (pt_status >= 0)
> !       return exec_file_buffer;
> !     }
>   #endif
> 
>     /* It appears that this request is broken prior to 10.30.
> Index: gdb/target.c
> /opt/gnu/bin/diff -r -c -N  /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/target.c gdb/target.c
> *** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/target.c    Fri Nov  5 17:36:01 1999
> --- gdb/target.c        Fri Nov  5 17:37:12 1999
> ***************
> *** 1915,1920 ****
> --- 1915,2066 ----
>       }
>   }
> 
> + int
> + target_signal_exists (oursig)
> +      enum target_signal oursig;
> + {
> +   switch (oursig)
> +     {
> +     case TARGET_SIGNAL_0:
> + #if defined (SIGHUP)
> +     case TARGET_SIGNAL_HUP:
> + #endif
> + #if defined (SIGINT)
> +     case TARGET_SIGNAL_INT:
> + #endif
> + #if defined (SIGQUIT)
> +     case TARGET_SIGNAL_QUIT:
> + #endif
> + #if defined (SIGILL)
> +     case TARGET_SIGNAL_ILL:
> + #endif
> + #if defined (SIGTRAP)
> +     case TARGET_SIGNAL_TRAP:
> + #endif
> + #if defined (SIGABRT)
> +     case TARGET_SIGNAL_ABRT:
> + #endif
> + #if defined (SIGEMT)
> +     case TARGET_SIGNAL_EMT:
> + #endif
> + #if defined (SIGFPE)
> +     case TARGET_SIGNAL_FPE:
> + #endif
> + #if defined (SIGKILL)
> +     case TARGET_SIGNAL_KILL:
> + #endif
> + #if defined (SIGBUS)
> +     case TARGET_SIGNAL_BUS:
> + #endif
> + #if defined (SIGSEGV)
> +     case TARGET_SIGNAL_SEGV:
> + #endif
> + #if defined (SIGSYS)
> +     case TARGET_SIGNAL_SYS:
> + #endif
> + #if defined (SIGPIPE)
> +     case TARGET_SIGNAL_PIPE:
> + #endif
> + #if defined (SIGALRM)
> +     case TARGET_SIGNAL_ALRM:
> + #endif
> + #if defined (SIGTERM)
> +     case TARGET_SIGNAL_TERM:
> + #endif
> + #if defined (SIGUSR1)
> +     case TARGET_SIGNAL_USR1:
> + #endif
> + #if defined (SIGUSR2)
> +     case TARGET_SIGNAL_USR2:
> + #endif
> + #if defined (SIGCHLD) || defined (SIGCLD)
> +     case TARGET_SIGNAL_CHLD:
> + #endif /* SIGCLD or SIGCHLD */
> + #if defined (SIGPWR)
> +     case TARGET_SIGNAL_PWR:
> + #endif
> + #if defined (SIGWINCH)
> +     case TARGET_SIGNAL_WINCH:
> + #endif
> + #if defined (SIGURG)
> +     case TARGET_SIGNAL_URG:
> + #endif
> + #if defined (SIGIO)
> +     case TARGET_SIGNAL_IO:
> + #endif
> + #if defined (SIGPOLL)
> +     case TARGET_SIGNAL_POLL:
> + #endif
> + #if defined (SIGSTOP)
> +     case TARGET_SIGNAL_STOP:
> + #endif
> + #if defined (SIGTSTP)
> +     case TARGET_SIGNAL_TSTP:
> + #endif
> + #if defined (SIGCONT)
> +     case TARGET_SIGNAL_CONT:
> + #endif
> + #if defined (SIGTTIN)
> +     case TARGET_SIGNAL_TTIN:
> + #endif
> + #if defined (SIGTTOU)
> +     case TARGET_SIGNAL_TTOU:
> + #endif
> + #if defined (SIGVTALRM)
> +     case TARGET_SIGNAL_VTALRM:
> + #endif
> + #if defined (SIGPROF)
> +     case TARGET_SIGNAL_PROF:
> + #endif
> + #if defined (SIGXCPU)
> +     case TARGET_SIGNAL_XCPU:
> + #endif
> + #if defined (SIGXFSZ)
> +     case TARGET_SIGNAL_XFSZ:
> + #endif
> + #if defined (SIGWIND)
> +     case TARGET_SIGNAL_WIND:
> + #endif
> + #if defined (SIGPHONE)
> +     case TARGET_SIGNAL_PHONE:
> + #endif
> + #if defined (SIGLOST)
> +     case TARGET_SIGNAL_LOST:
> + #endif
> + #if defined (SIGWAITING)
> +     case TARGET_SIGNAL_WAITING:
> + #endif
> + #if defined (SIGLWP)
> +     case TARGET_SIGNAL_LWP:
> + #endif
> + #if defined (SIGDANGER)
> +     case TARGET_SIGNAL_DANGER:
> + #endif
> + #if defined (SIGGRANT)
> +     case TARGET_SIGNAL_GRANT:
> + #endif
> + #if defined (SIGRETRACT)
> +     case TARGET_SIGNAL_RETRACT:
> + #endif
> + #if defined (SIGMSG)
> +     case TARGET_SIGNAL_MSG:
> + #endif
> + #if defined (SIGSOUND)
> +     case TARGET_SIGNAL_SOUND:
> + #endif
> + #if defined (SIGSAK)
> +     case TARGET_SIGNAL_SAK:
> + #endif
> + #if defined (SIGPRIO)
> +     case TARGET_SIGNAL_PRIO:
> + #endif
> +       return 1;
> +
> +     default:
> +       return 0;
> +     }
> + }
> +
>   /* Helper function for child_wait and the Lynx derivatives of child_wait.
>      HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
>      translation of that in OURSTATUS.  */
> Index: gdb/target.h
> /opt/gnu/bin/diff -r -c -N  /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/target.h gdb/target.h
> *** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/target.h    Fri Nov  5 17:37:37 1999
> --- gdb/target.h        Fri Nov  5 17:38:12 1999
> ***************
> *** 1327,1332 ****
> --- 1327,1333 ----
>   /* Convert between host signal numbers and enum target_signal's.  */
>   extern enum target_signal target_signal_from_host PARAMS ((int));
>   extern int target_signal_to_host PARAMS ((enum target_signal));
> + extern int target_signal_exists PARAMS ((enum target_signal));
> 
>   /* Convert from a number used in a GDB command to an enum target_signal.  */
>   extern enum target_signal target_signal_from_command PARAMS ((int));
> Index: gdb/infrun.c
> /opt/gnu/bin/diff -r -c -N  /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/infrun.c gdb/infrun.c
> *** /view/guo.wdb.c//CLO/Components/WDB/Src/gnu/gdb/infrun.c    Fri Nov  5 18:37:38 1999
> --- gdb/infrun.c        Fri Nov  5 18:38:41 1999
> ***************
> *** 3621,3626 ****
> --- 3621,3633 ----
>         }
>       }
> 
> +
> + #ifdef GDB_TARGET_IS_HPPA
> +   /* RM: Use OS interface to ignore signals we don't care about */
> +   if (target_has_execution)
> +     require_notification_of_events (inferior_pid);
> + #endif
> +
>     do_cleanups (old_chain);
>   }
>
From ac131313@cygnus.com Thu Nov 11 16:07:00 1999
From: Andrew Cagney <ac131313@cygnus.com>
To: Stan Shebs <shebs@cygnus.com>
Cc: cagney@cygnus.com, gdb-patches@sourceware.cygnus.com, guo@cup.hp.com
Subject: Re: (patch) hpjyg21: FAT_FREE_PSYMTABS
Date: Thu, 11 Nov 1999 16:07:00 -0000
Message-id: <382B5A0D.31585A7A@cygnus.com>
References: <199911112341.PAA29252@andros.cygnus.com>
X-SW-Source: 1999-q4/msg00241.html
Content-length: 967

Stan Shebs wrote:
> 
>    Date: Fri, 12 Nov 1999 10:10:14 +1100
>    From: Andrew Cagney <ac131313@cygnus.com>
> 
>    I've another meta maintainer question on this :-)
> 
>    Is it better to use #ifdef or have the compiler eliminate optional
>    code?  For instance:
> 
>            if (FAT_FREE_PSYMTABS)
>              {
>              }
> 
> I favor this over ifdefs.  Not only does it facilitate maintenance,
> but it leaves open options for cross-debugging and for making
> decisions at runtime.  The only reasonable exception would be provably
> time-critical code where ifdefs would allow compiler optimizations not
> available if the code were merely "if (0)".  (There might be examples
> of this in the stabs reader, although I don't know of any myself.)

``Trust me'', there are no cases where this can occure :-)

Compiling with -O eliminates all of them (well it does for GCC, if other
compilers can't eliminate that then they are broken :-).

	Andrew
From guo@cup.hp.com Thu Nov 11 16:31:00 1999
From: Jimmy Guo <guo@cup.hp.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: gdb-patches@sourceware.cygnus.com
Subject: Re: (patch) hpjyg15: hppah-nat.c & related
Date: Thu, 11 Nov 1999 16:31:00 -0000
Message-id: <Pine.LNX.4.10.9911111610120.6426-100000@hpcll168.cup.hp.com>
References: <382B585D.421E98F3@cygnus.com>
X-SW-Source: 1999-q4/msg00242.html
Content-length: 1348

>Don't forget that the GDB's coding style is defined by the output of
>indent.  Looking more closely I noticed that some of the changes are to
>``fix'' the indentation. Please just grit your teath and ignore it.
>
>It's a good idea to carefully review the diffs and revert/remove any
>changes not specific to the problem at hand.
>
>Doing this makes the reviewers life so much easier.

Andrew,

I'm aware of this problem and I'm trying to resolve this.  Interestly,
yes I'm reversing what indent did, _not_ to create noises, but to remove
them.  If you run indent on, say hppah-nat.c, straight from the 19991108
snapshot, you will see that it's not in GDB's coding style (since indent
is not happy with the way the code is!)

I _ran_ indent on source files before I make a patch (ok, in some cases
I might forgot to do so which might have turned out to be a good thing)
... and that's how most diff noises are introduced.  I came to realize
this and am starting to do the reserve -- change back what indent changed
that's not relevant to the patch, to make the changes in my patches
conform to GDB's coding style.  Given how much indent changes a source
file, it could be very time consuming and 'non-productive', but I'm
doing my share to help the situation.

BTW, I'm using indent 1.9.1 on Linux, with no arguments.

- Jimmy Guo, guo@cup.hp.com


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

end of thread, other threads:[~1999-11-11 15:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-11 12:53 (patch) hpjyg21: FAT_FREE_PSYMTABS Jimmy Guo
1999-11-11 15:10 ` Andrew Cagney

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