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]
Other format: [Raw text]

Re: bug in gdb/target.c:target_signal_to_name


> On Sun, Jan 13, 2002 at 04:10:05PM -0500, Andrew Cagney wrote:
> 
>> --- 214,223 ----
>> /* I think the code which prints this will always print it along with
>> the string, so no need to be verbose.  */
>> return "?";
>> !   else if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
>> !     return signals[sig].name;
>> !   else
>> !     return signals[sig].name;
>> }
>> > /* Given a name, return its signal.  */
> 
> 
> That's probably not what you meant to commit, since both cases are the
> same.


Er, no. Lets try the attached.  Turns out that 
signals[TARGET_SIGNAL_UNKNOWN].name is NULL.

Andrew


2002-01-13  Andrew Cagney  <ac131313@redhat.com>

	* signals.c (target_signal_to_name): Rewrite.  Only use
	signals[].name when in bounds and non-NULL.
	
Index: signals.c
===================================================================
RCS file: /cvs/src/src/gdb/signals.c,v
retrieving revision 1.2
diff -p -r1.2 signals.c
*** signals.c	2002/01/13 21:11:38	1.2
--- signals.c	2002/01/13 21:51:26
*************** target_signal_to_string (enum target_sig
*** 210,223 ****
  char *
  target_signal_to_name (enum target_signal sig)
  {
!   if (sig == TARGET_SIGNAL_UNKNOWN)
!     /* I think the code which prints this will always print it along with
!        the string, so no need to be verbose.  */
!     return "?";
!   else if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
      return signals[sig].name;
    else
!     return signals[sig].name;
  }
  
  /* Given a name, return its signal.  */
--- 210,222 ----
  char *
  target_signal_to_name (enum target_signal sig)
  {
!   if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST)
!       && signals[sig].name != NULL)
      return signals[sig].name;
    else
!     /* I think the code which prints this will always print it along
!        with the string, so no need to be verbose (very old comment).  */
!     return "?";
  }
  
  /* Given a name, return its signal.  */

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