diff options
author | Sergio Durigan Junior <sergiodj@redhat.com> | 2014-05-02 17:45:35 -0300 |
---|---|---|
committer | Sergio Durigan Junior <sergiodj@redhat.com> | 2014-05-02 17:45:35 -0300 |
commit | f33da99a5410692ddf1302435e27b1bfc21d0b11 (patch) | |
tree | c90573c1140dbffc7520c52198b6d84e6c8808cf /gdb/stap-probe.c | |
parent | 54cb4522e7555fdf766201c3c74bfc8510c83424 (diff) | |
download | gdb-f33da99a5410692ddf1302435e27b1bfc21d0b11.zip gdb-f33da99a5410692ddf1302435e27b1bfc21d0b11.tar.gz gdb-f33da99a5410692ddf1302435e27b1bfc21d0b11.tar.bz2 |
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.
Diffstat (limited to 'gdb/stap-probe.c')
-rw-r--r-- | gdb/stap-probe.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index dbe9f31..ef45495 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -1098,10 +1098,8 @@ stap_parse_probe_arguments (struct stap_probe *probe, struct gdbarch *gdbarch) Where `N' can be [+,-][4,8]. This is not mandatory, so we check it here. If we don't find it, go to the next state. */ - if ((*cur == '-' && cur[1] != '\0' && cur[2] != '@') - && cur[1] != '@') - arg.bitness = STAP_ARG_BITNESS_UNDEFINED; - else + if ((cur[0] == '-' && isdigit (cur[1]) && cur[2] == '@') + || (isdigit (cur[0]) && cur[1] == '@')) { if (*cur == '-') { @@ -1127,11 +1125,14 @@ stap_parse_probe_arguments (struct stap_probe *probe, struct gdbarch *gdbarch) } arg.bitness = b; - arg.atype = stap_get_expected_argument_type (gdbarch, b); /* Discard the number and the `@' sign. */ cur += 2; } + else + arg.bitness = STAP_ARG_BITNESS_UNDEFINED; + + arg.atype = stap_get_expected_argument_type (gdbarch, arg.bitness); expr = stap_parse_argument (&cur, arg.atype, gdbarch); |