Bug 24830 - FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: all with invalid regexp: run until breakpoint in main (unknown output after running)
Summary: FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: all with invalid regexp: run until ...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: mi (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-22 07:59 UTC by Tom de Vries
Modified: 2019-07-25 16:41 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
gdb.log (5.54 KB, text/x-log)
2019-07-22 08:00 UTC, Tom de Vries
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2019-07-22 07:59:00 UTC
...
PASS: gdb.mi/mi-catch-cpp-exceptions.exp: all with invalid regexp: Setup -catch-catch
-exec-continue^M
^running^M
*running,thread-id="all"^M
(gdb) ^M
&"not stopped at a C++ exception catchpoint\n"^M
=breakpoint-modified,bkpt={number="12",type="catchpoint",disp="keep",enabled="y",what="exception throw",catch-type="throw",thread-groups=["i1"],regexp="blahblah",times="1"}^M
~"\n"^M
~"Catchpoint 12 (exception thrown), 0x00007ffff7ae7010 in __cxa_throw () from /usr/lib64/libstdc++.so.6\n"^M
*stopped,bkptno="12",reason="breakpoint-hit",disp="keep",frame={addr="0x00007ffff7ae7010",func="__cxa_throw",args=[],from="/usr/lib64/libstdc++.so.6",arch="i386:x86-64"},thread-id="1",stopped-threads="all",core="1"^M
mi_expect_stop: expecting: \*stopped,reason="breakpoint-hit",disp="keep",bkptno="[0-9]+",frame={addr="0x[0-9A-Fa-\
f]+",func="main",args=\[.*\],(?:file="[^
]*.*",fullname="(/[^\n]*/|\\\\[^\\]+\\[^\n]+\\|\\[^\\][^\n]*\\|[a-zA-Z]:[^\n]*\\).*",line="67",arch="[^
]*"|from=".*")}.*,thread-id="[0-9]+",stopped-threads=[^
]*^M
(=thread-selected,id="[0-9]+"^M
|=(?:breakpoint-created|breakpoint-deleted)[^
]+"^M
)*[(]gdb[)] ^M
$
(gdb) ^M
got &"not stopped at a C++ exception catchpoint\n"^M
=breakpoint-modified,bkpt={number="12",type="catchpoint",disp="keep",enabled="y",what="exception throw",catch-type="throw",thread-groups=["i1"],regexp="blahblah",times="1"}^M
~"\n"^M
~"Catchpoint 12 (exception thrown), 0x00007ffff7ae7010 in __cxa_throw () from /usr/lib64/libstdc++.so.6\n"^M
*stopped,bkptno="12",reason="breakpoint-hit",disp="keep",frame={addr="0x00007ffff7ae7010",func="__cxa_throw",args=[],from="/usr/lib64/libstdc++.so.6",arch="i386:x86-64"},thread-id="1",stopped-threads="all",core="1"^M
(gdb) ^M

FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: all with invalid regexp: run until breakpoint in main (unknown output after running)
...
Comment 1 Tom de Vries 2019-07-22 08:00:41 UTC
Created attachment 11915 [details]
gdb.log
Comment 2 Tom de Vries 2019-07-24 10:26:58 UTC
I've rewritten the problem into a command line (not using mi):
...
$ ./gdb -nw -nx -data-directory /data/gdb_versions/devel/build/gdb/testsuite/../data-directory -q -batch  ./build/gdb/testsuite/outputs/gdb.mi/mi-catch-cpp-exceptions/mi-catch-cpp-exceptions -ex "tb main" -ex run -ex "b 67" -ex "catch throw -r blahblah" -ex continue
Temporary breakpoint 1 at 0x4008a4: file /data/gdb_versions/devel/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc, line 58.

Temporary breakpoint 1, main () at /data/gdb_versions/devel/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc:58
58        for (int i = 0; i < 2; ++i)
Breakpoint 2 at 0x4008e5: file /data/gdb_versions/devel/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc, line 67.
Catchpoint 3 (throw)
not stopped at a C++ exception catchpoint

Catchpoint 3 (exception thrown), 0x00007ffff7ae7010 in __cxa_throw () from /usr/lib64/libstdc++.so.6
...
Comment 3 Tom de Vries 2019-07-24 10:30:22 UTC
And on ubuntu 18.04 I get:
...
$ ./gdb -nw -nx -q -batch  ./build/gdb/testsuite/outputs/gdb.mi/mi-catch-cpp-exceptions/mi-catch-cpp-exceptions -ex "tb main" -ex run -ex "b 67" -ex "catch throw -r blahblah" -ex continue
Temporary breakpoint 1 at 0x9d9: file /home/vries/gdb/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc, line 58.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 1, main () at /home/vries/gdb/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc:58
58	  for (int i = 0; i < 2; ++i)
Breakpoint 2 at 0x555555554a1a: file /home/vries/gdb/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc, line 67.
Catchpoint 3 (throw)

Breakpoint 2, main () at /home/vries/gdb/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc:67
67		    return 1;	/* Stop here.  */
...
Comment 4 Tom de Vries 2019-07-24 11:42:46 UTC
(In reply to Tom de Vries from comment #2)
> I've rewritten the problem into a command line (not using mi):
> ...
> $ ./gdb -nw -nx -data-directory
> /data/gdb_versions/devel/build/gdb/testsuite/../data-directory -q -batch 
> ./build/gdb/testsuite/outputs/gdb.mi/mi-catch-cpp-exceptions/mi-catch-cpp-
> exceptions -ex "tb main" -ex run -ex "b 67" -ex "catch throw -r blahblah"
> -ex continue
> Temporary breakpoint 1 at 0x4008a4: file
> /data/gdb_versions/devel/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc,
> line 58.
> 
> Temporary breakpoint 1, main () at
> /data/gdb_versions/devel/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc:
> 58
> 58        for (int i = 0; i < 2; ++i)
> Breakpoint 2 at 0x4008e5: file
> /data/gdb_versions/devel/src/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc,
> line 67.
> Catchpoint 3 (throw)
> not stopped at a C++ exception catchpoint
> 
> Catchpoint 3 (exception thrown), 0x00007ffff7ae7010 in __cxa_throw () from
> /usr/lib64/libstdc++.so.6
> ...


So, we end up in check_status_exception_catchpoint, where we go into the "if (self->pattern != NULL)" case (due to the -r blahblah), and call fetch_probe_arguments.  There we get a pc using get_frame_pc, but when doing:
...
  pc_probe = find_probe_by_pc (pc);
...
we end up with a NULL pc_probe, and run into the error:
...
  if (pc_probe.prob == NULL
      || pc_probe.prob->get_provider () != "libstdcxx"
      || (pc_probe.prob->get_name () != "catch"
          && pc_probe.prob->get_name () != "throw"
          && pc_probe.prob->get_name () != "rethrow"))
    error (_("not stopped at a C++ exception catchpoint"));
...
which is caught in check_status_exception_catchpoint, where we fail to set bs->stop to 0, and consequently, we hit the catchpoint.
Comment 5 Tom de Vries 2019-07-24 12:27:11 UTC
This fails because on libstdc++.so.6 on openSUSE leap 15.0 does not contain systemtap probe descriptors, while libstdc++.so.6 on ubuntu 18.04 does contains those (visible with readelf -n).


Doc confirms ( https://sourceware.org/gdb/current/onlinedocs/gdb/Set-Catchpoints.html#Set-Catchpoints ):
...
The regular expression feature and the $_exception convenience variable rely on the presence of some SDT probes in libstdc++. If these probes are not present, then these features cannot be used. These probes were first available in the GCC 4.8 release, but whether or not they are available in your GCC also depends on how it was built.
...
Comment 6 Tom de Vries 2019-07-24 12:41:14 UTC
It would be good to test whether catch points with regexps are supported at the point that we set them, rather than giving this "not stopped at a C++ exception catchpoint" error when encountering pc_probe.prob == NULL.
Comment 8 Tom de Vries 2019-07-25 12:27:23 UTC
(In reply to Tom de Vries from comment #6)
> It would be good to test whether catch points with regexps are supported at
> the point that we set them, rather than giving this "not stopped at a C++
> exception catchpoint" error when encountering pc_probe.prob == NULL.

Filed PR24852 - "Improve error message for catch catch/rethow/catch command when using libstdc++ without SDT probes", which looks easier to implement.
Comment 9 Sourceware Commits 2019-07-25 16:40:13 UTC
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=297989a10c56aec56eab0ee63f1e61c33ab20905

commit 297989a10c56aec56eab0ee63f1e61c33ab20905
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Jul 25 18:39:31 2019 +0200

    [gdb/testsuite] Test skip_libstdcxx_probe_tests in mi-catch-cpp-exceptions.exp
    
    On a system without SDT probes in libstdc++, we run into:
    ...
    FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: all with invalid regexp: run until \
      breakpoint in main (unknown output after running)
    ...
    
    The test-case uses a regexp argument for the catch throw/rethrow/catch
    command, which is only supported on systems with SDT probes in libstdc++.
    
    Fix this by marking the portions of the test-case that use a regexp argument
    as unsupported on a system without SDT probes.
    
    Tested on x86_64-linux.
    
    gdb/testsuite/ChangeLog:
    
    2019-07-25  Tom de Vries  <tdevries@suse.de>
    
    	PR testsuite/24830
    	* gdb.mi/mi-catch-cpp-exceptions.exp: Call
    	mi_skip_libstdcxx_probe_tests, and skip unsupported tests.
    	* lib/gdb.exp (skip_libstdcxx_probe_tests_prompt): Factor out of ...
    	(skip_libstdcxx_probe_tests): ... here.
    	* lib/mi-support.exp (mi_skip_libstdcxx_probe_tests): New proc.
Comment 10 Tom de Vries 2019-07-25 16:41:09 UTC
Patch committed, marking resolved-fixed.