[RFA] gdbserver crash if the_target->supports_z_point_type is NULL

Message ID 1401905805-22408-1-git-send-email-brobecker@adacore.com
State Committed
Headers

Commit Message

Joel Brobecker June 4, 2014, 6:16 p.m. UTC
  Hello,

When debugging on LynxOS targets (and probably on SPU targets as well),
inserting a breakpoint and resuming the program's execution causes
GDBserver to crash.

The crash occurs while handling the Z0 packet sent by GDB to insert
our breakpoint, because z_type_supported calls
the_target->supports_z_point_type without checking that it is not NULL
This patch fixes the issue by making z_type_supported return false if
the_target->supports_z_point_type is NULL.

gdb/gdbserver/ChangeLog:

        PR server/17023
        * mem-break.c (z_type_supported): Return zero if
        THE_TARGET->SUPPORTS_Z_POINT_TYPE is NULL.

Tested on ppx-lynx5. I haven't tested on GNU/Linux, but I feel
sufficiently confident since supports_z_point_type is defined there,
and I am eager to take a look at Windows next. But I can do it
if people think it would be best.  OK to push?

Thanks,
  

Comments

Pedro Alves June 4, 2014, 8:09 p.m. UTC | #1
On 06/04/2014 07:16 PM, Joel Brobecker wrote:
> Hello,
> 
> When debugging on LynxOS targets (and probably on SPU targets as well),
> inserting a breakpoint and resuming the program's execution causes
> GDBserver to crash.
> 
> The crash occurs while handling the Z0 packet sent by GDB to insert
> our breakpoint, because z_type_supported calls
> the_target->supports_z_point_type without checking that it is not NULL
> This patch fixes the issue by making z_type_supported return false if
> the_target->supports_z_point_type is NULL.
> 
> gdb/gdbserver/ChangeLog:
> 
>         PR server/17023
>         * mem-break.c (z_type_supported): Return zero if
>         THE_TARGET->SUPPORTS_Z_POINT_TYPE is NULL.
> 
> Tested on ppx-lynx5. I haven't tested on GNU/Linux, but I feel
> sufficiently confident since supports_z_point_type is defined there,
> and I am eager to take a look at Windows next. But I can do it
> if people think it would be best.  OK to push?

OK.
  
Joel Brobecker June 4, 2014, 10:21 p.m. UTC | #2
> > gdb/gdbserver/ChangeLog:
> > 
> >         PR server/17023
> >         * mem-break.c (z_type_supported): Return zero if
> >         THE_TARGET->SUPPORTS_Z_POINT_TYPE is NULL.
> 
> OK.

Thanks, Pedro. Patch has been pushed.
  

Patch

diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c
index 71876f7..2ce3ab2 100644
--- a/gdb/gdbserver/mem-break.c
+++ b/gdb/gdbserver/mem-break.c
@@ -897,6 +897,7 @@  static int
 z_type_supported (char z_type)
 {
   return (z_type >= '0' && z_type <= '4'
+	  && the_target->supports_z_point_type != NULL
 	  && the_target->supports_z_point_type (z_type));
 }