Commit Graph

97012 Commits

Author SHA1 Message Date
Tom Tromey
ef93dd73bc Add --with-static-standard-libraries to the top level
[ Backport of master commit c1a5d03a89. ]

gdb should normally not be linked with -static-libstdc++.  Currently
this has not caused problems, but it's incompatible with catching an
exception thrown from a shared library -- and a subsequent patch
changes gdb to do just this.

This patch adds a new --with-static-standard-libraries flag to the
top-level configure.  It defaults to "auto", which means enabled if
gcc is being built, and disabled otherwise.

ChangeLog
2019-08-19  Tom Tromey  <tom@tromey.com>

	PR gdb/25009
	* configure: Rebuild.
	* configure.ac: Add --with-static-standard-libraries.
2019-09-19 16:18:33 +02:00
GDB Administrator
fe3e346568 Automatic date update in version.in 2019-09-19 00:01:13 +00:00
Tom de Vries
59047affb0 Update ChangeLog entry of commit 98c90f8028 and mention PR c++/20020 2019-09-18 22:53:21 +02:00
Tom de Vries
3d80b2e754 Update ChangeLog entry of commit 3b752ac2e6 and mention PR testsuite/25016 2019-09-18 22:48:57 +02:00
Tom de Vries
88f07f28d5 Update ChangeLog entry of commit 7e38ddcb2e and mention PR breakpoints/25011 2019-09-18 22:39:39 +02:00
Tom de Vries
5ca0b868fa Update ChangeLog entry of commit 8ac39635f6 and mention PR gdb/25010 2019-09-18 16:20:25 +02:00
GDB Administrator
2b0b07b8b6 Automatic date update in version.in 2019-09-18 00:01:02 +00:00
Tom de Vries
fafa92ec3c [gdb/testsuite] Fix regexp in skip_opencl_tests
[ Backport of master commit d2b584a55b. ]

When running gdb-caching-proc.exp, if skip_opencl_tests fails like this:
...
(gdb) run
Starting program: \
  build/gdb/testsuite/outputs/gdb.base/gdb-caching-proc/opencltest13530.x
CHK_ERR (clGetPlatformIDs (1, &platform, NULL), -1001)
src/gdb/testsuite/lib/opencl_hostapp.c:73 error: Unknown
[Inferior 1 (process 13600) exited with code 01]
(gdb)
skip_opencl_tests: OpenCL support not detected
...
then this regexp in skip_opencl_tests fails to match:
...
        -re ".*$inferior_exited_re code.*${gdb_prompt} $" {
...
so instead we hit the default clause after a 30 seconds timeout.  With the
iteration count set at 10, we end up taking 6 minutes to run this test-case.

Fix this by adding the missing "with" in the regexp, bring back the runtime to
half a minute.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-04-29  Tom de Vries  <tdevries@suse.de>

	PR testsuite/25005
	* lib/opencl.exp (skip_opencl_tests): Add missing "with" in regexp.
2019-09-17 13:57:09 +02:00
Sergio Durigan Junior
6f4f8f476a Update ChangeLog entry of commit e9224f6d80 and mention PR breakpoints/24541 2019-09-17 00:01:13 -04:00
GDB Administrator
74da864345 Automatic date update in version.in 2019-09-17 00:01:50 +00:00
GDB Administrator
1d5f98eac3 Automatic date update in version.in 2019-09-16 00:01:18 +00:00
GDB Administrator
c44adce9d5 Automatic date update in version.in 2019-09-15 00:01:39 +00:00
GDB Administrator
38abece621 Automatic date update in version.in 2019-09-14 00:01:04 +00:00
GDB Administrator
e0ef9fdab2 Automatic date update in version.in 2019-09-13 00:00:54 +00:00
GDB Administrator
2d21c7260d Automatic date update in version.in 2019-09-12 00:01:03 +00:00
Sergio Durigan Junior
3b0e664e2f Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
[ Backport of master commit 7d7571f0c1. ]

This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:

  make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'

The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs.  I'll use
Andrew's example on the bug to illustrate the problem.

libstdc++ has a probe named "throw" with two arguments.  On i386, the
probe is:

  stapsdt              0x00000028       NT_STAPSDT (SystemTap probe descriptors)
    Provider: libstdcxx
    Name: throw
    Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
    Arguments: 4@%si 4@%di

I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di.  Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).

However, if you take a look at the disassemble of a program that uses
this probe, you will see:

    00072c80 <__cxa_throw@@CXXABI_1.3>:
       72c80:       57                      push   %edi
       72c81:       56                      push   %esi
       72c82:       53                      push   %ebx
       72c83:       8b 74 24 10             mov    0x10(%esp),%esi
       72c87:       e8 74 bf ff ff          call   6ec00 <__cxa_finalize@plt+0x980>
       72c8c:       81 c3 74 e3 10 00       add    $0x10e374,%ebx
       72c92:       8b 7c 24 14             mov    0x14(%esp),%edi
       72c96:       90                      nop                      <----------------- PROBE IS HERE
       72c97:       e8 d4 a2 ff ff          call   6cf70 <__cxa_get_globals@plt>
       72c9c:       83 40 04 01             addl   $0x1,0x4(%eax)
       72ca0:       83 ec 04                sub    $0x4,%esp
       72ca3:       ff 74 24 1c             pushl  0x1c(%esp)
       72ca7:       57                      push   %edi
       72ca8:       56                      push   %esi
       72ca9:       e8 62 a3 ff ff          call   6d010 <__cxa_init_primary_exception@plt>
       72cae:       8d 70 40                lea    0x40(%eax),%esi
       72cb1:       c7 00 01 00 00 00       movl   $0x1,(%eax)
       72cb7:       89 34 24                mov    %esi,(%esp)
       72cba:       e8 61 96 ff ff          call   6c320 <_Unwind_RaiseException@plt>
       72cbf:       89 34 24                mov    %esi,(%esp)
       72cc2:       e8 c9 84 ff ff          call   6b190 <__cxa_begin_catch@plt>
       72cc7:       e8 d4 b3 ff ff          call   6e0a0 <_ZSt9terminatev@plt>
       72ccc:       66 90                   xchg   %ax,%ax
       72cce:       66 90                   xchg   %ax,%ax

Note how the program is actually using %edi, and not %di, to store the
second argument.  This is the problem here.

GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained.  In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string.  In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.

After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.

The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386.  The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.

The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part).  If it
is, we're fine.  Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.).  If we
are, it will change the register name to include the "e" prefix.

I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp.  No regressions where found on other tests.

Comments?

gdb/ChangeLog:
2019-06-27  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR breakpoints/24541
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh: Add 'stap_adjust_register'.
	* i386-tdep.c: Include '<unordered_set>'.
	(i386_stap_adjust_register): New function.
	(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
	* stap-probe.c (stap_parse_register_operand): Call
	'gdbarch_stap_adjust_register'.
2019-09-11 22:03:40 +02:00
Sergio Durigan Junior
e9224f6d80 Make stap-probe.c:stap_parse_register_operand's "regname" an std::string
[ Backport of master commit 677052f2a5. ]

This patch simplifies the code of
stap-probe.c:stap_parse_register_operand by making "regname" an
std::string.  No functionality change.

I'm this code's maintainer, so I'm pushing this as it's a fairly
trivial patch.

gdb/ChangeLog:
2019-05-16  Sergio Durigan Junior  <sergiodj@redhat.com>

	* stap-probe.c (stap_parse_register_operand): Make "regname" an
	"std::string", simplifying the algorithm.
2019-09-11 22:03:40 +02:00
GDB Administrator
d98f1d629b Automatic date update in version.in 2019-09-11 00:00:44 +00:00
GDB Administrator
037b23d08d Automatic date update in version.in 2019-09-10 00:00:59 +00:00
GDB Administrator
ee3857f2e7 Automatic date update in version.in 2019-09-09 00:01:36 +00:00
GDB Administrator
450c4b5c2a Automatic date update in version.in 2019-09-08 00:01:49 +00:00
GDB Administrator
db4a63fe54 Automatic date update in version.in 2019-09-07 00:00:59 +00:00
GDB Administrator
e9ddef0e66 Automatic date update in version.in 2019-09-06 00:01:07 +00:00
GDB Administrator
30f2a435e5 Automatic date update in version.in 2019-09-05 00:01:35 +00:00
GDB Administrator
af6b62c780 Automatic date update in version.in 2019-09-04 00:01:39 +00:00
GDB Administrator
ed14c4a538 Automatic date update in version.in 2019-09-03 00:01:05 +00:00
GDB Administrator
33ffb2c1b5 Automatic date update in version.in 2019-09-02 00:01:01 +00:00
GDB Administrator
0a4c3bdb1a Automatic date update in version.in 2019-09-01 00:01:33 +00:00
GDB Administrator
790ea6e3b3 Automatic date update in version.in 2019-08-31 00:01:45 +00:00
GDB Administrator
188e561c21 Automatic date update in version.in 2019-08-30 00:01:10 +00:00
GDB Administrator
061ca9bbc1 Automatic date update in version.in 2019-08-29 00:00:59 +00:00
GDB Administrator
607a69b8b0 Automatic date update in version.in 2019-08-28 00:01:25 +00:00
GDB Administrator
4ee05fb967 Automatic date update in version.in 2019-08-27 00:01:31 +00:00
GDB Administrator
69e0be31ee Automatic date update in version.in 2019-08-26 00:01:39 +00:00
GDB Administrator
3b5beecae9 Automatic date update in version.in 2019-08-25 00:02:21 +00:00
GDB Administrator
11e76e8d01 Automatic date update in version.in 2019-08-24 00:01:41 +00:00
GDB Administrator
727aef8153 Automatic date update in version.in 2019-08-23 00:01:48 +00:00
GDB Administrator
cf1bc0cd80 Automatic date update in version.in 2019-08-22 00:01:18 +00:00
GDB Administrator
e967953e28 Automatic date update in version.in 2019-08-21 00:00:52 +00:00
GDB Administrator
908db690e8 Automatic date update in version.in 2019-08-20 00:01:01 +00:00
GDB Administrator
e13a1a16d5 Automatic date update in version.in 2019-08-19 00:01:58 +00:00
GDB Administrator
f36c866169 Automatic date update in version.in 2019-08-18 00:02:23 +00:00
GDB Administrator
e853d5bce5 Automatic date update in version.in 2019-08-17 00:01:01 +00:00
GDB Administrator
55f04e741e Automatic date update in version.in 2019-08-16 00:00:56 +00:00
Tom de Vries
ee479c89ed [gdb] Handle vfork in thread with follow-fork-mode child
[ Backport of master commit b73715df01. ]

When debugging any of the testcases added by this commit, which do a
vfork in a thread with "set follow-fork-mode child" + "set
detach-on-fork on", we run into this assertion:

...
src/gdb/nat/x86-linux-dregs.c:146: internal-error: \
  void x86_linux_update_debug_registers(lwp_info*): \
  Assertion `lwp_is_stopped (lwp)' failed.
...

The assert is caused by the following: the vfork-child exit or exec
event is handled by handle_vfork_child_exec_or_exit, which calls
target_detach to detach from the vfork parent.  During target_detach
we call linux_nat_target::detach, which:

However, during the second step we run into this code in
stop_wait_callback:

...
  /* If this is a vfork parent, bail out, it is not going to report
     any SIGSTOP until the vfork is done with.  */
  if (inf->vfork_child != NULL)
    return 0;
...

and we don't wait for the threads to be stopped, which results in this
assert in x86_linux_update_debug_registers triggering during the third
step:

...
  gdb_assert (lwp_is_stopped (lwp));
...

The fix is to reset the vfork parent's vfork_child field before
calling target_detach in handle_vfork_child_exec_or_exit.  There's
already similar code for the other paths handled by
handle_vfork_child_exec_or_exit, so this commit refactors the code a
bit so that all paths share the same code.

The new tests cover both a vfork child exiting, and a vfork child
execing, since both cases would trigger the assertion.

The new testcases also exercise following the vfork children with "set
detach-on-fork off", since it doesn't seem to be tested anywhere.

Tested on x86_64-linux, using native and native-gdbserver.

gdb/ChangeLog:
2019-04-18  Tom de Vries  <tdevries@suse.de>
	    Pedro Alves  <palves@redhat.com>

	PR gdb/24454
	* infrun.c (handle_vfork_child_exec_or_exit): Reset vfork parent's
	vfork_child field before calling target_detach.

gdb/testsuite/ChangeLog:
2019-04-18  Tom de Vries  <tdevries@suse.de>
	    Pedro Alves  <palves@redhat.com>

	PR gdb/24454
	* gdb.threads/vfork-follow-child-exec.c: New file.
	* gdb.threads/vfork-follow-child-exec.exp: New file.
	* gdb.threads/vfork-follow-child-exit.c: New file.
	* gdb.threads/vfork-follow-child-exit.exp: New file.
2019-08-16 00:31:48 +02:00
GDB Administrator
cfa3fa0f41 Automatic date update in version.in 2019-08-15 00:01:13 +00:00
GDB Administrator
5302b8b344 Automatic date update in version.in 2019-08-14 00:01:04 +00:00
GDB Administrator
0a04b387e6 Automatic date update in version.in 2019-08-13 00:01:06 +00:00
GDB Administrator
8d597d0217 Automatic date update in version.in 2019-08-12 00:00:59 +00:00
GDB Administrator
15a7492a25 Automatic date update in version.in 2019-08-11 00:01:39 +00:00