Fix PR breakpoints/16889: gdb segfaults when printing ASM SDT arguments
authorSergio Durigan Junior <sergiodj@redhat.com>
Fri, 2 May 2014 20:45:35 +0000 (17:45 -0300)
committerSergio Durigan Junior <sergiodj@redhat.com>
Fri, 2 May 2014 20:45:35 +0000 (17:45 -0300)
commitf33da99a5410692ddf1302435e27b1bfc21d0b11
treec90573c1140dbffc7520c52198b6d84e6c8808cf
parent54cb4522e7555fdf766201c3c74bfc8510c83424
Fix PR breakpoints/16889: gdb segfaults when printing  ASM SDT arguments

This commit fixes PR breakpoints/16889, which is about a bug that
triggers when GDB tries to parse probes whose arguments do not contain
the initial (and optional) "N@" part.  For reference sake, the de
facto format is described here:

  <https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation>

Anyway, this PR actually uncovered two bugs (related) that were
happening while parsing the arguments.  The first one was that the
parser *was* catching *some* arguments that were missing the "N@"
part, but it wasn't correctly setting the argument's type.  This was
causing a NULL pointer being dereferenced, ouch...

The second bug uncovered was that the parser was not catching all of
the cases for a probe which did not provide the "N@" part.  The fix
for that was to simplify the check that the code was making to
identify non-prefixed probes.  The code is simpler and easier to read
now.

I am also providing a testcase for this bug, only for x86_64
architectures.

gdb/
2014-05-02  Sergio Durigan Junior  <sergiodj@redhat.com>

PR breakpoints/16889
* stap-probe.c (stap_parse_probe_arguments): Simplify
check for non-prefixed probes (i.e., probes whose
arguments do not start with "N@").  Always set the
argument type to a sane value.

gdb/testsuite/
2014-05-02  Sergio Durigan Junior  <sergiodj@redhat.com>

PR breakpoints/16889
* gdb.arch/amd64-stap-optional-prefix.S: New file.
* gdb.arch/amd64-stap-optional-prefix.exp: Likewise.
gdb/ChangeLog
gdb/stap-probe.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.S [new file with mode: 0644]
gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp [new file with mode: 0644]