Compare commits

...

29 Commits

Author SHA1 Message Date
Joel Brobecker
e53a8e8685 Set GDB version number to 12.1.
This commit changes gdb/version.in to 12.1.
2022-05-01 11:46:32 -07:00
Tom Tromey
4324e94471 Import gnulib changes
This imports the gnulib patches that were mentioned by Eli.  I created
the patches from gnulib git, ran them through filterdiff, and then
applied them using update-gnulib.sh's patch-applying facility.

I think the patches are either obviously Windows-specific or harmless,
but I encourage you to look for yourself.

I tested by rebuilding on x86-64 Fedora 34, and also using the Fedora
mingw cross toolchain.
2022-04-25 07:29:02 -06:00
Andrew Burgess
e312dfbe95 gdb: move setbuf calls out of gdb_readline_no_editing_callback
After this commit:

  commit d08cbc5d32
  Date:   Wed Dec 22 12:57:44 2021 +0000

      gdb: unbuffer all input streams when not using readline

Issues were reported with some MS-Windows hosts, see the thread
starting here:

  https://sourceware.org/pipermail/gdb-patches/2022-March/187004.html

Filed in bugzilla as: PR mi/29002

The problem seems to be that calling setbuf on terminal file handles
is not always acceptable, see this mail for more details:

  https://sourceware.org/pipermail/gdb-patches/2022-April/187310.html

This commit does two things, first moving the setbuf calls out of
gdb_readline_no_editing_callback so that we don't end up calling
setbuf so often.

Then, for MS-Windows hosts, we don't call setbuf for terminals, this
appears to resolve the issues that have been reported.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29002
2022-04-24 08:44:02 -07:00
Andrew Burgess
3ab22dba1b gdb: fix 'remote show FOO-packet' aliases
The following behaviour was observed in GDB:

  (gdb) show remote X-packet
  Support for the `p' packet is auto-detected, currently unknown.

Note the message mentions the 'p' packet.  This is a regression since
this commit:

  commit 8579fd136a
  Date:   Mon Nov 8 14:58:46 2021 +0000

      gdb/gdbsupport: make xstrprintf and xstrvprintf return a unique_ptr

Before this commit the behaviour was:

  (gdb) show remote X-packet
  Support for the `X' packet is auto-detected, currently unknown.

The problem was caused by a failed attempt to ensure that some
allocated strings were deleted when GDB exits.  The code in the above
commit attempted to make use of 'static' to solve this problem,
however, the solution was just wrong.

In this new commit I instead allocate a static vector into which all
the allocated strings are stored, this ensures the strings are
released when GDB exits (which makes output from tools like valgrind
cleaner), but each string within the vector can be unique, which fixes
the regression.
2022-04-21 11:49:30 +01:00
Tom de Vries
f0072f79e1 [gdb/testsuite] Fix gdb.ada/float-bits.exp with -m32
With test-case gdb.ada/float-bits.exp and native we get:
...
(gdb) print 16llf#7FFFF7FF4054A56FA5B99019A5C8#^M
$9 = 5.0e+25^M
(gdb) PASS: gdb.ada/float-bits.exp: print 16llf#7FFFF7FF4054A56FA5B99019A5C8#
...
but with target board unix/-m32 we have instead:
...
(gdb) print 16llf#7FFFF7FF4054A56FA5B99019A5C8#^M
Cannot export value 2596145952482202326224873165792712 as 96-bits \
  unsigned integer (must be between 0 and 79228162514264337593543950335)^M
(gdb) FAIL: gdb.ada/float-bits.exp: print 16llf#7FFFF7FF4054A56FA5B99019A5C8#
...

Fix this by testing whether 16llf is supported by doing ptype long_long_float
which gets us either:
...
type = <16-byte float>^M
...
or:
...
type = <12-byte float>^M
...

Tested on x86_64-linux with native and unix/-m32.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29041
2022-04-15 18:01:07 +02:00
Tom de Vries
04f521a6ef [gdb/testsuite] Fix gdb.go/methods.exp with check-readmore
When running test-case gdb.go/methods.exp with make check we have:
...
(gdb) break main.T.Foo^M
Function "main.T.Foo" not defined.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) XFAIL: gdb.go/methods.exp: gdb_breakpoint: set breakpoint at main.T.Foo
...
but with make check-readmore the XFAIL fails to trigger:
...
(gdb) break main.T.Foo^M
Function "main.T.Foo" not defined.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: gdb.go/methods.exp: gdb_breakpoint: set breakpoint at main.T.Foo
...

This happens because this gdb_test_multiple "maintenance print symbols"
regexp:
...
    -re "\r\n$gdb_prompt $" {
...
matches the entire command output.

Fix this by adding the missing ^ at the regexp start.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29064
2022-04-15 16:54:21 +02:00
Lancelot SIX
d063203192 gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
Pedro Alves warned me that there is a race in
gdb.dwarf2/calling-convention.exp making the test sometimes fail on his
setup.  This can be reliably reproduced using :

    make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"

The relevant part of the gdb.log file is:

    return 35
    Function 'foo' does not follow the target calling convention.
    If you continue, setting the return value will probably lead to unpredictable behaviors.
    Make foo return now? (y or n) PASS: gdb.dwarf2/calling-convention.exp: return 35
    n
    Not confirmed
    (gdb) FAIL: gdb.dwarf2/calling-convention.exp: finish

The issue is that when doing the test for "return 35", the DejaGnu test
sends "n" (to tell GDB not to perform the return action) but never
consumes the "Not confirmed" acknowledgment sent by GDB.  Later, when
trying to do the next test, DejaGnu tries to match the leftover output
from the "return" test. As this output is not expected, the test fails.

Fix by using gdb_test to send the "n" answer and match the confirmation
and consume all output to the prompt.

Also do minor adjustments to the main regex:
  - Remove the leading ".*" which is not required.
  - Ensure that the "?" from the question is properly escaped.

Tested on x86_64-gnu-linux, using

- make check TESTS="gdb.dwarf2/calling-convention.exp"
- make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"
- make check-readmore TESTS="gdb.dwarf2/calling-convention.exp"

Co-authored-by: Pedro Alves <pedro@palves.net>
Change-Id: I42858b13db2cbd623c5c1739de65ad423e0c0938
2022-04-14 18:27:51 +01:00
Tom Tromey
db7127461e Silence -Wmaybe-uninitialized warning from target_waitstatus
Currently, one use of target_waitstatus yields a warning:

     target/waitstatus.h: In function 'void stop_all_threads()':
     target/waitstatus.h:175:13: warning: 'ws.target_waitstatus::m_value' may be used uninitialized in this function [-Wmaybe-uninitialized]
       175 |     m_value = other.m_value;
	   |     ~~~~~~~~^~~~~~~~~~~~~~~

This patch silences the warning.  I tried the "volatile member"
approach that was used for gdb::optional, but that didn't work, so
this patch simply initializes the member.
2022-04-14 10:19:16 -06:00
Tom Tromey
7b5e70a921 Fix regression on Windows with WOW64
Internally at AdaCore, we recently started testing a 64-bit gdb
debugging 32-bit processes.  This failed with gdb head, but not with
gdb 11.

The tests fail like this:

     Starting program: [...].exe
     warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
     Do you need "set solib-search-path" or "set sysroot"?
     warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
     Do you need "set solib-search-path" or "set sysroot"?
     warning: Could not load shared library symbols for NOT_AN_IMAGE.
     Do you need "set solib-search-path" or "set sysroot"?
     warning: Could not load shared library symbols for NOT_AN_IMAGE.
     Do you need "set solib-search-path" or "set sysroot"?

After some debugging and bisecting, to my surprise the bug was
introduced by commit 183be222 ("gdb, gdbserver: make target_waitstatus
safe").

The problem occurs in handle_exception.  Previously the code did:

    -  ourstatus->kind = TARGET_WAITKIND_STOPPED;
    [...]
	 case EXCEPTION_BREAKPOINT:
    [...]
    -	  ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
    [...]
	   /* FALLTHROUGH */
	 case STATUS_WX86_BREAKPOINT:
	   DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT");
    -      ourstatus->value.sig = GDB_SIGNAL_TRAP;
    [...]
    -  last_sig = ourstatus->value.sig;

However, in the new code, the fallthrough case does:

    +      ourstatus->set_stopped (GDB_SIGNAL_TRAP);

... which changes the 'kind' in 'ourstatus' after falling through.

This patch rearranges the 'last_sig' setting to more closely match
what was done before (this is probably not strictly needed but also
seemed harmless), and removes the fall-through in the
'ignore_first_breakpoint' case when __x86_64__ is defined.
2022-04-14 10:02:56 -06:00
Tom de Vries
74f8cb8887 [gdb/testsuite] Fix gdb.base/annota1.exp with pie
Since commit 359efc2d89 ("[gdb/testsuite] Make gdb.base/annota1.exp more
robust") we see this fail with target board unix/-fPIE/-pie:
...
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
...

The problem is that the commit makes the number and order of matched
annotations fixed, while between target boards unix and unix/-fPIE/-pie there
is a difference:
...
 \032\032post-prompt
 Starting program: outputs/gdb.base/annota1/annota1

+\032\032breakpoints-invalid
+
 \032\032starting

 \032\032frames-invalid
...

Fix this by optionally matching the additional annotation.

Tested on x86_64-linux.
2022-04-14 14:56:21 +02:00
Tom de Vries
013dbf15db [gdb/testsuite] Make gdb.base/annota1.exp more robust
On openSUSE Tumbleweed I run into:
...
FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
...

The problem is that the libthread_db message occurs at a location where it's
not expected:
...
Starting program: outputs/gdb.base/annota1/annota1 ^M
^M
^Z^Zstarting^M
^M
^Z^Zframes-invalid^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
^M
^Z^Zbreakpoints-invalid^M
^M
...

Fix this by making the matching more robust:
- rewrite the regexp such that each annotation is on a single line,
  starting with \r\n\032\032 and ending with \r\n
- add a regexp variable optional_re, that matches all possible optional
  output, and use it as a separator in the first part of the regexp

Tested on x86_64-linux.
2022-04-14 14:56:21 +02:00
Tom de Vries
f48fc32448 [gdb/testsuite] Fix gdb.base/stap-probe.exp with read1
When running test-case gdb.base/stap-probe.exp with make target check-read1, I
run into this and similar:
...
FAIL: gdb.base/stap-probe.exp: without semaphore, not optimized: \
  info probes stap (timeout)
...

Fix this by using gdb_test_lines instead of gdb_test.

Tested on x86_64-linux.
2022-04-14 13:52:19 +02:00
Tom de Vries
d4c9e8f583 [gdb/testsuite] Detect 'No MPX support'
On openSUSE Leap 15.3, mpx support has been disabled for m32, so I run into:
...
(gdb) run ^M
Starting program: outputs/gdb.arch/i386-mpx/i386-mpx ^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
No MPX support^M
...
and eventually into all sort of fails in this and other mpx test-cases.

Fix this by detecting the "No MPX support" message in have_mpx.

Tested on x86_64-linux with target boards unix and unix/-m32.
2022-04-14 13:17:24 +02:00
Tom de Vries
4f538bcbb7 [gdb/testsuite] Fix gdb.dwarf2/dw2-lines.exp for m32 pie
As reported in PR29043, when running test-case gdb.dwarf2/dw2-lines.exp with
target board unix/-m32/-fPIE/-pie, we run into:
...
Breakpoint 2, 0x56555540 in bar ()^M
(gdb) PASS: gdb.dwarf2/dw2-lines.exp: cv=2: cdw=32: lv=2: ldw=32: \
  continue to breakpoint: foo \(1\)
next^M
Single stepping until exit from function bar,^M
which has no line number information.^M
0x56555587 in main ()^M
(gdb) FAIL: gdb.dwarf2/dw2-lines.exp: cv=2: cdw=32: lv=2: ldw=32: \
  next to foo (2)
...

The problem is that the bar breakpoint ends up at an unexpected location
because:
- the synthetic debug info is incomplete and doesn't provide line info
  for the prologue part of the function, so consequently gdb uses the i386
  port prologue skipper to get past the prologue
- the i386 port prologue skipper doesn't get past a get_pc_thunk call.

Work around this in the test-case by breaking on bar_label instead.

Tested on x86_64-linux with target boards unix, unix/-m32, unix/-fPIE/-pie and
unix/-m32/-fPIE/-pie.
2022-04-13 14:29:00 +02:00
Simon Marchi
1ab8f3967d gdb/testsuite: use nopie in gdb.dwarf2/dw2-inline-param.exp
I see this failure:

    (gdb) run ^M
    Starting program: /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.dwarf2/dw2-inline-param/dw2-inline-param ^M
    Warning:^M
    Cannot insert breakpoint 1.^M
    Cannot access memory at address 0x113b^M
    ^M
    (gdb) FAIL: gdb.dwarf2/dw2-inline-param.exp: runto: run to *0x113b

The test loads the binary in GDB, grabs the address of a symbol, strips
the binary, reloads it in GDB, runs the program, and then tries to place
a breakpoint at that address.  The problem is that the binary is built
as position independent, so the address GDB grabs in the first place
isn't where the code ends up after running.

Fix this by linking the binary as non-position-independent.  The
alternative would be to compute the relocated address where to place the
breakpoint, but that's not very straightforward, unfortunately.

I was confused for a while, I was trying to load the binary in GDB
manually to get the symbol address, but GDB was telling me the symbol
could not be found.  Meanwhile, it clearly worked in gdb.log.  The thing
is that GDB strips the binary in-place, so we don't have access to the
intermediary binary with symbols.  Change the test to output the
stripped binary to a separate file instead.

Change-Id: I66c56293df71b1ff49cf748d6784bd0e935211ba
2022-04-13 14:29:00 +02:00
Tom Tromey
0349d33f1d Fix bug in Ada number lexing
On irc, Pedro pointed out that Ada couldn't properly handle
0xffffffffffffffff.  This used to work, but is a regression due to
some patches I wrote in the Ada lexer.  This patch fixes the bug.
2022-04-12 13:02:00 -06:00
Tom Tromey
81f81faa8f Remove "Ada Settings" node from the manual
A while back, I sent a patch to unify the Ada varsize-limit setting
with the more generic max-value-size:

https://sourceware.org/pipermail/gdb-patches/2021-September/182004.html

However, it turns out I somehow neglected to send part of the patch.
Internally, I also removed the "Ada Settings" node from the manual, as
it only documents the obsolete setting.

This patch removes this text.
2022-04-12 07:01:06 -06:00
John Baldwin
aba6eff2e0 Handle TLS variable lookups when using separate debug files.
Commit df22c1e5d5 handled the case that
a separate debug file was passed as the objfile for a shared library
to svr4_fetch_objfile_link_map.  However, a separate debug file can
also be passed for TLS variables in the main executable.  In addition,
frv_fetch_objfile_link_map also expects to be passed the original
objfile rather than a separate debug file, so pull the code to resolve
a separate debug file to the main objfile up into
target_translate_tls_address.
2022-04-11 08:50:52 -07:00
Simon Marchi
4393855615 gdb: don't copy entirely optimized out values in value_copy
Bug 28980 shows that trying to value_copy an entirely optimized out
value causes an internal error.  The original bug report involves MI and
some Python pretty printer, and is quite difficult to reproduce, but
another easy way to reproduce (that is believed to be equivalent) was
proposed:

    $ ./gdb -q -nx --data-directory=data-directory -ex "py print(gdb.Value(gdb.Value(5).type.optimized_out()))"
    /home/smarchi/src/binutils-gdb/gdb/value.c:1731: internal-error: value_copy: Assertion `arg->contents != nullptr' failed.

This is caused by 5f8ab46bc6 ("gdb: constify parameter of
value_copy").  It added an assertion that the contents buffer is
allocated if the value is not lazy:

  if (!value_lazy (val))
    {
      gdb_assert (arg->contents != nullptr);

This was based on the comment on value::contents, which suggest that
this is the case:

  /* Actual contents of the value.  Target byte-order.  NULL or not
     valid if lazy is nonzero.  */
  gdb::unique_xmalloc_ptr<gdb_byte> contents;

However, it turns out that it can also be nullptr also if the value is
entirely optimized out, for example on exit of
allocate_optimized_out_value.  That function creates a lazy value, marks
the entire value as optimized out, and then clears the lazy flag.  But
contents remains nullptr.

This wasn't a problem for value_copy before, because it was calling
value_contents_all_raw on the input value, which caused contents to be
allocated before doing the copy.  This means that the input value to
value_copy did not have its contents allocated on entry, but had it
allocated on exit.  The result value had it allocated on exit.  And that
we copied bytes for an entirely optimized out value (i.e. meaningless
bytes).

From here I see two choices:

 1. respect the documented invariant that contents is nullptr only and
    only if the value is lazy, which means making
    allocate_optimized_out_value allocate contents
 2. extend the cases where contents can be nullptr to also include
    values that are entirely optimized out (note that you could still
    have some entirely optimized out values that do have contents
    allocated, it depends on how they were created) and adjust
    value_copy accordingly

Choice #1 is safe, but less efficient: it's not very useful to allocate
a buffer for an entirely optimized out value.  It's even a bit less
efficient than what we had initially, because values coming out of
allocate_optimized_out_value would now always get their contents
allocated.

Choice #2 would be more efficient than what we had before: giving an
optimized out value without allocated contents to value_copy would
result in an optimized out value without allocated contents (and the
input value would still be without allocated contents on exit).  But
it's more risky, since it's difficult to ensure that all users of the
contents (through the various_contents* accessors) are all fine with
that new invariant.

In this patch, I opt for choice #2, since I think it is a better
direction than choice #1.  #1 would be a pessimization, and if we go
this way, I doubt that it will ever be revisited, it will just stay that
way forever.

Add a selftest to test this.  I initially started to write it as a
Python test (since the reproducer is in Python), but a selftest is more
straightforward.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28980
Change-Id: I6e2f5c0ea804fafa041fcc4345d47064b5900ed7
2022-04-06 16:12:00 -04:00
Simon Marchi
810db22c7f gdb/testsuite: fix intermittent failures in gdb.mi/mi-cmd-user-context.exp
I got failures like this once on a CI:

    frame^M
    &"frame\n"^M
    ~"#0  child_sub_function () at /home/jenkins/workspace/binutils-gdb_master_build/arch/amd64/target_board/unix/src/binutils-gdb/gdb/testsuite/gdb.mi/user-selected-context-sync.c:33\n"^M
    ~"33\t    dummy = !dummy; /* thread loop line */\n"^M
    ^done^M
    (gdb) ^M
    FAIL: gdb.mi/mi-cmd-user-context.exp: frame 1 (unexpected output)

The problem is that the test expects the following regexp:

  ".*#0  0x.*"

And that typically works, when the output of the frame command looks
like:

  #0  0x00005555555551bb in child_sub_function () at ...

Note the lack of hexadecimal address in the failing case.  Whether or
not the hexadecimal address is printed (roughly) depends on whether the
current PC is at the beginning of a line.  So depending on where thread
2 was when GDB stopped it (after thread 1 hit its breakpoint), we can
get either output.  Adjust the regexps to not expect an hexadecimal
prefix (0x) but a function name instead (either child_sub_function or
child_function).  That one is always printed, and is also a good check
that we are in the frame we expect.

Note that for test "frame 5", we are showing a pthread frame (on my
system), so the function name is internal to pthread, not something we
can rely on.  In that case, it's almost certain that we are not at the
beginning of a line, or that we don't have debug info, so I think it's
fine to expect the hex prefix.

And for test "frame 6", it's ok to _not_ expect a hex prefix (what the
test currently does), since we are showing thread 1, which has hit a
breakpoint placed at the beginning of a line.

When testing this, Tom de Vries pointed out that the current test code
doesn't ensure that the child threads are in child_sub_function when
they are stopped.  If the scheduler chooses so, it is possible for the
child threads to be still in the pthread_barrier_wait or child_function
functions when they get stopped.  So that would be another racy failure
waiting to happen.

The only way I can think of to ensure the child threads are in the
child_sub_function function when they get stopped is to synchronize the
threads using some variables instead of pthread_barrier_wait.  So,
replace the barrier with an array of flags (one per child thread).  Each
child thread flips its flag in child_sub_function to allow the main
thread to make progress and eventually hit the breakpoint.

I copied user-selected-context-sync.c to a new mi-cmd-user-context.c and
made modifications to that, to avoid interfering with
user-selected-context-sync.exp.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29025
Change-Id: I919673bbf9927158beb0e8b7e9e980b8d65eca90
2022-04-05 08:02:15 -04:00
Tom de Vries
b86dbc4c45 [gdb/testsuite] Fix KPASS in gdb.ada/arrayptr.exp
On openSUSE Leap 15.3 I run into:
...
KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all \
  (PRMS minimal encodings)
KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr(3) \
  (PRMS minimal encodings)
KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all(3) \
  (PRMS minimal encodings)
...

The test-case KFAILs some tests.  However, the analysis in the corresponding
PR talks of a compiler problem, so it should use XFAILs instead.

The KFAILs are setup for pre-gcc-12, but apparantly the fix has been
backported to system compiler 7.5.0, hence the KPASS.

Fix this by:
- using an XFAIL instead of a KFAIL
- matching the specific gdb output that corresponds to the XFAILs
  (reproduced on Fedora 34).

Tested on x86_64-linux, specifically openSUSE Leap 15.3 and Fedora 34.
2022-04-04 12:25:55 +02:00
Rainer Orth
09ab0d2eec Fix procfs.c compilation
procfs.c doesn't compile on Solaris:

/vol/src/gnu/gdb/hg/master/local/gdb/procfs.c: In member function ‘virtual bool procfs_target::info_proc(const char*, info_proc_what)’:
/vol/src/gnu/gdb/hg/master/local/gdb/procfs.c:3302:3: error: ‘gdb_argv’ was not declared in this scope
 3302 |   gdb_argv built_argv (args);
      |   ^~~~~~~~
/vol/src/gnu/gdb/hg/master/local/gdb/procfs.c:3303:20: error: ‘built_argv’ was not declared in this scope; did you mean ‘buildargv’?
 3303 |   for (char *arg : built_argv)
      |                    ^~~~~~~~~~
      |                    buildargv

Fixed by including  "gdbsupport/buildargv.h".

Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11.
2022-03-31 10:38:01 +02:00
Andrew Burgess
95c82cbf7e gdb/mi: fix use after free of frame_info causing spurious notifications
In commit:

  commit a2757c4ed6
  Date:   Wed Mar 16 15:08:22 2022 +0000

      gdb/mi: consistently notify user when GDB/MI client uses -thread-select

Changes were made to GDB to address some inconsistencies in when
notifications are sent from a MI terminal to a CLI terminal (when
multiple terminals are in use, see new-ui command).

Unfortunately, in order to track when the currently selected frame has
changed, that commit grabs a frame_info pointer before and after an MI
command has executed, and compares the pointers to see if the frame
has changed.

This is not safe.

If the frame cache is deleted for any reason then the frame_info
pointer captured before the command started, is no longer valid, and
any comparisons based on that pointer are undefined.

This was leading to random test failures for some folk, see:

  https://sourceware.org/pipermail/gdb-patches/2022-March/186867.html

This commit changes GDB so we no longer hold frame_info pointers, but
instead store the frame_id and frame_level, this is safe even when the
frame cache is flushed.
2022-03-29 10:55:11 +01:00
Tom Tromey
7685884a38 Add Rust parser check for end of expression
I noticed that "print 5," passed in Rust -- the parser wasn't checking
that the entire input was used.  This patch fixes the problem.  This
in turn pointed out another bug in the parser, namely that it didn't
lex the next token after handling a string token.  This is also fixed
here.
2022-03-28 15:19:47 -06:00
Joel Brobecker
eb3ec1b698 Bump GDB's version number to 12.0.90.DATE-git.
This commit changes gdb/version.in to 12.0.90.DATE-git.
2022-03-20 09:55:10 +04:00
Joel Brobecker
9d7105d14c Set GDB version number to 12.0.90.
This commit changes gdb/version.in to 12.0.90.
2022-03-20 09:30:32 +04:00
Joel Brobecker
fc8b2d4b5d Update gdb/NEWS to say "in GDB 12" instead of "since GDB 11" 2022-03-20 09:25:52 +04:00
Joel Brobecker
5dd959bace Set development mode to "off" by default.
This is done by setting the "development" variable to "false"
in bfd/development.sh.
2022-03-20 09:07:50 +04:00
Joel Brobecker
5e8b7e78b6 Bump version to 12.0.90.DATE-git.
Now that the GDB 12 branch has been created,
this commit bumps the version number in gdb/version.in to
12.0.90.DATE-git

For the record, the GDB 12 branch was created
from commit 2be64de603.
2022-03-20 09:07:19 +04:00
41 changed files with 522 additions and 146 deletions

View File

@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Controls whether to enable development-mode features by default.
development=true
development=false
# Indicate whether this is a release branch.
experimental=true

View File

@@ -1,7 +1,7 @@
What has changed in GDB?
(Organized release by release)
*** Changes since GDB 11
*** Changes in GDB 12
* DBX mode is deprecated, and will be removed in GDB 13

View File

@@ -434,11 +434,11 @@ processInt (struct parser_state *par_state, const char *base0,
return FLOAT;
}
gdb_mpz maxval (ULONGEST_MAX / base);
gdb_mpz maxval (ULONGEST_MAX);
if (mpz_cmp (result.val, maxval.val) > 0)
error (_("Integer literal out of range"));
LONGEST value = result.as_integer<LONGEST> ();
ULONGEST value = result.as_integer<ULONGEST> ();
if ((value >> (gdbarch_int_bit (par_state->gdbarch ())-1)) == 0)
yylval.typed_val.type = type_int (par_state);
else if ((value >> (gdbarch_long_bit (par_state->gdbarch ())-1)) == 0)

View File

@@ -18014,7 +18014,6 @@ to be difficult.
* Ada Tasks and Core Files:: Tasking Support when Debugging Core Files
* Ravenscar Profile:: Tasking Support when using the Ravenscar
Profile
* Ada Settings:: New settable GDB parameters for Ada.
* Ada Source Character Set:: Character set of Ada source files.
* Ada Glitches:: Known peculiarities of Ada mode.
@end menu
@@ -18748,37 +18747,6 @@ it isn't currently possible to single-step through the runtime
initialization sequence. If you need to debug this code, you should
use @code{set ravenscar task-switching off}.
@node Ada Settings
@subsubsection Ada Settings
@cindex Ada settings
@table @code
@kindex set varsize-limit
@item set varsize-limit @var{size}
Prevent @value{GDBN} from attempting to evaluate objects whose size
is above the given limit (@var{size}) when those sizes are computed
from run-time quantities. This is typically the case when the object
has a variable size, such as an array whose bounds are not known at
compile time for example. Setting @var{size} to @code{unlimited}
removes the size limitation. By default, the limit is about 65KB.
The purpose of having such a limit is to prevent @value{GDBN} from
trying to grab enormous chunks of virtual memory when asked to evaluate
a quantity whose bounds have been corrupted or have not yet been fully
initialized. The limit applies to the results of some subexpressions
as well as to complete expressions. For example, an expression denoting
a simple integer component, such as @code{x.y.z}, may fail if the size of
@code{x.y} is variable and exceeds @code{size}. On the other hand,
@value{GDBN} is sometimes clever; the expression @code{A(i)}, where
@code{A} is an array variable with non-constant size, will generally
succeed regardless of the bounds on @code{A}, as long as the component
size is less than @var{size}.
@kindex show varsize-limit
@item show varsize-limit
Show the limit on types whose size is determined by run-time quantities.
@end table
@node Ada Source Character Set
@subsubsection Ada Source Character Set
@cindex Ada, source character set

View File

@@ -821,19 +821,6 @@ gdb_readline_no_editing_callback (gdb_client_data client_data)
FILE *stream = ui->instream != nullptr ? ui->instream : ui->stdin_stream;
gdb_assert (stream != nullptr);
/* Unbuffer the input stream, so that, later on, the calls to fgetc
fetch only one char at the time from the stream. The fgetc's will
get up to the first newline, but there may be more chars in the
stream after '\n'. If we buffer the input and fgetc drains the
stream, getting stuff beyond the newline as well, a select, done
afterwards will not trigger.
This unbuffering was, at one point, not applied if the input stream
was a tty, however, the buffering can cause problems, even for a tty,
in some cases. Please ensure that any changes in this area run the MI
tests with the FORCE_SEPARATE_MI_TTY=1 flag being passed. */
setbuf (stream, NULL);
/* We still need the while loop here, even though it would seem
obvious to invoke gdb_readline_no_editing_callback at every
character entered. If not using the readline library, the

View File

@@ -1974,27 +1974,51 @@ struct user_selected_context
{
/* Constructor. */
user_selected_context ()
: m_previous_ptid (inferior_ptid),
m_previous_frame (deprecated_safe_get_selected_frame ())
{ /* Nothing. */ }
: m_previous_ptid (inferior_ptid)
{
save_selected_frame (&m_previous_frame_id, &m_previous_frame_level);
}
/* Return true if the user selected context has changed since this object
was created. */
bool has_changed () const
{
return ((m_previous_ptid != null_ptid
&& inferior_ptid != null_ptid
&& m_previous_ptid != inferior_ptid)
|| m_previous_frame != deprecated_safe_get_selected_frame ());
/* Did the selected thread change? */
if (m_previous_ptid != null_ptid && inferior_ptid != null_ptid
&& m_previous_ptid != inferior_ptid)
return true;
/* Grab details of the currently selected frame, for comparison. */
frame_id current_frame_id;
int current_frame_level;
save_selected_frame (&current_frame_id, &current_frame_level);
/* Did the selected frame level change? */
if (current_frame_level != m_previous_frame_level)
return true;
/* Did the selected frame id change? If the innermost frame is
selected then the level will be -1, and the frame-id will be
null_frame_id. As comparing null_frame_id with itself always
reports not-equal, we only do the equality test if we have something
other than the innermost frame selected. */
if (current_frame_level != -1
&& !frame_id_eq (current_frame_id, m_previous_frame_id))
return true;
/* Nothing changed! */
return false;
}
private:
/* The previously selected thread. This might be null_ptid if there was
no previously selected thread. */
ptid_t m_previous_ptid;
/* The previously selected frame. This might be nullptr if there was no
previously selected frame. */
frame_info *m_previous_frame;
/* The previously selected frame. If the innermost frame is selected, or
no frame is selected, then the frame_id will be null_frame_id, and the
level will be -1. */
frame_id m_previous_frame_id;
int m_previous_frame_level;
};
static void

View File

@@ -201,6 +201,8 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
thread_rec (ptid_t (current_event.dwProcessId, current_event.dwThreadId, 0),
DONT_SUSPEND);
last_sig = GDB_SIGNAL_0;
switch (code)
{
case EXCEPTION_ACCESS_VIOLATION:
@@ -261,8 +263,10 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
on startup, first a BREAKPOINT for the 64bit ntdll.dll,
then a WX86_BREAKPOINT for the 32bit ntdll.dll.
Here we only care about the WX86_BREAKPOINT's. */
DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT - ignore_first_breakpoint");
ourstatus->set_spurious ();
ignore_first_breakpoint = false;
break;
}
else if (wow64_process)
{
@@ -273,7 +277,7 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
gdb lets the target process continue.
So handle it as SIGINT instead, then the target is stopped
unconditionally. */
DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT");
DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT - wow64_process");
rec->ExceptionCode = DBG_CONTROL_C;
ourstatus->set_stopped (GDB_SIGNAL_INT);
break;

View File

@@ -45,6 +45,7 @@
#include "observable.h"
#include "gdbsupport/scoped_fd.h"
#include "gdbsupport/pathstuff.h"
#include "gdbsupport/buildargv.h"
/* This module provides the interface between GDB and the
/proc file system, which is used on many versions of Unix

View File

@@ -1968,15 +1968,17 @@ add_packet_config_cmd (struct packet_config *config, const char *name,
/* set/show remote NAME-packet {auto,on,off} -- legacy. */
if (legacy)
{
/* It's not clear who should take ownership of this string, so, for
now, make it static, and give copies to each of the add_alias_cmd
calls below. */
static gdb::unique_xmalloc_ptr<char> legacy_name
/* It's not clear who should take ownership of the LEGACY_NAME string
created below, so, for now, place the string into a static vector
which ensures the strings is released when GDB exits. */
static std::vector<gdb::unique_xmalloc_ptr<char>> legacy_names;
gdb::unique_xmalloc_ptr<char> legacy_name
= xstrprintf ("%s-packet", name);
add_alias_cmd (legacy_name.get (), cmds.set, class_obscure, 0,
&remote_set_cmdlist);
add_alias_cmd (legacy_name.get (), cmds.show, class_obscure, 0,
&remote_show_cmdlist);
legacy_names.emplace_back (std::move (legacy_name));
}
}

View File

@@ -271,7 +271,10 @@ struct rust_parser
operation_up parse_entry_point ()
{
lex ();
return parse_expr ();
operation_up result = parse_expr ();
if (current_token != 0)
error (_("Syntax error near '%s'"), pstate->prev_lexptr);
return result;
}
operation_up parse_tuple ();
@@ -2020,6 +2023,7 @@ rust_parser::parse_atom (bool required)
case STRING:
result = parse_string ();
lex ();
break;
case BYTESTRING:

View File

@@ -1453,11 +1453,6 @@ svr4_fetch_objfile_link_map (struct objfile *objfile)
if (objfile == current_program_space->symfile_object_file)
return info->main_lm_addr;
/* If OBJFILE is a separate debug object file, look for the
original object file. */
if (objfile->separate_debug_objfile_backlink != NULL)
objfile = objfile->separate_debug_objfile_backlink;
/* The other link map addresses may be found by examining the list
of shared libraries. */
for (struct so_list *so : current_program_space->solibs ())

View File

@@ -1296,6 +1296,11 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
struct target_ops *target = current_inferior ()->top_target ();
struct gdbarch *gdbarch = target_gdbarch ();
/* If OBJFILE is a separate debug object file, look for the
original object file. */
if (objfile->separate_debug_objfile_backlink != NULL)
objfile = objfile->separate_debug_objfile_backlink;
if (gdbarch_fetch_tls_load_module_address_p (gdbarch))
{
ptid_t ptid = inferior_ptid;

View File

@@ -418,7 +418,7 @@ private:
char *execd_pathname;
/* Syscall number */
int syscall_number;
} m_value;
} m_value {};
};
/* Extended reasons that can explain why a target/thread stopped for a

View File

@@ -49,27 +49,56 @@ foreach_with_prefix scenario {all minimal} {
gdb_test "ptype string_access" "= access array \\(<>\\) of character"
set kfail_int128support_re \
"That operation is not available on integers of more than 8 bytes\\."
set kfail_packed_array_range_re \
# GNAT >= 12.0 has the needed fix here.
set xfail_expected 0
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
set xfail_expected 1
}
gdb_test_multiple "print pa_ptr.all" "" {
-re -wrap " = \\(10, 20, 30, 40, 50, 60, 62, 63, -23, 42\\)" {
pass $gdb_test_name
}
-re -wrap " = \[0-9\]+" {
if { $xfail_expected } {
xfail $gdb_test_name
} else {
fail $gdb_test_name
}
}
}
set xfail_cannot_subscript_re \
"cannot subscript or call something of type `foo__packed_array_ptr'"
# GNAT >= 12.0 has the needed fix here.
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
setup_kfail "minimal encodings" *-*-*
}
gdb_test "print pa_ptr.all" \
" = \\(10, 20, 30, 40, 50, 60, 62, 63, -23, 42\\)"
gdb_test_multiple "print pa_ptr(3)" "" {
-re -wrap " = 30" {
pass $gdb_test_name
# GNAT >= 12.0 has the needed fix here.
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
setup_kfail "minimal encodings" *-*-*
}
-re -wrap $xfail_cannot_subscript_re {
if { $xfail_expected } {
xfail $gdb_test_name
} else {
fail $gdb_test_name
}
}
}
gdb_test "print pa_ptr(3)" " = 30"
# GNAT >= 12.0 has the needed fix here.
if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
setup_kfail "minimal encodings" *-*-*
set xfail_attempt_to_index_re \
"Attempt to index or call something other than an array or function"
gdb_test_multiple "print pa_ptr.all(3)" "" {
-re -wrap " = 30" {
pass $gdb_test_name
}
-re -wrap $xfail_attempt_to_index_re {
if { $xfail_expected } {
xfail $gdb_test_name
} else {
fail $gdb_test_name
}
}
}
gdb_test "print pa_ptr.all(3)" " = 30"
}

View File

@@ -42,12 +42,29 @@ gdb_test "print val_double := 16lf#bc0d83c94fb6d2ac#" " = -2.0e-19"
gdb_test "print val_double" " = -2.0e-19" \
"print val_double after assignment"
gdb_test "print 16llf#7FFFF7FF4054A56FA5B99019A5C8#" " = 5.0e\\+25"
set 16llf_supported 0
gdb_test_multiple "ptype long_long_float" "" {
-re -wrap "<16-byte float>" {
set 16llf_supported 1
pass $gdb_test_name
}
-re -wrap "<\\d+-byte float>" {
pass $gdb_test_name
}
}
if { $16llf_supported } {
gdb_test "print 16llf#7FFFF7FF4054A56FA5B99019A5C8#" " = 5.0e\\+25"
}
gdb_test "print val_long_double" " = 5.0e\\+25"
gdb_test "print val_long_double := 16llf#7FFFF7FF4054A56FA5B99019A5C8#" \
" = 5.0e\\+25"
if { $16llf_supported } {
gdb_test "print val_long_double := 16llf#7FFFF7FF4054A56FA5B99019A5C8#" \
" = 5.0e\\+25"
}
gdb_test "print val_long_double" " = 5.0e\\+25" \
"print val_long_double after assignment"
gdb_test "print 16llf#a56fa5b99019a5c800007ffff7ff4054#" \
" = <invalid float value>"
if { $16llf_supported } {
gdb_test "print 16llf#a56fa5b99019a5c800007ffff7ff4054#" \
" = <invalid float value>"
}

View File

@@ -34,3 +34,6 @@ gdb_test "print 2e1000" "Integer literal out of range"
gdb_test "print 16#ffff#" " = 65535"
gdb_test "print 16#f#e1" " = 240"
gdb_test "print 16#1#e10" " = 1099511627776"
gdb_test "print/x 16#7fffffffffffffff#" " = 0x7fffffffffffffff"
gdb_test "print 16#ffffffffffffffff#" " = -1"

View File

@@ -128,41 +128,66 @@ gdb_test_multiple "info break" "breakpoint info" {
set binexp [string_to_regexp $binfile]
set warning_slow_re \
"warning: File transfers from remote targets can be slow\[^\r\n\]+"
"warning: File transfers from remote targets can be slow\[^\r\n\]+\r\n"
set warning_gdb_index_re \
[multi_line \
"warning: Skipping \[^\r\n\]+ .gdb_index section in \[^\r\n\]+" \
"Do \"set use-deprecated-index-sections on\" before the file is read" \
"to use the section anyway\\."]
"to use the section anyway\\.\r\n"]
set reading_re \
"Reading \[^\r\n\]+"
"Reading \[^\r\n\]+\r\n"
set libthread_db_re \
[multi_line \
"\\\[Thread debugging using libthread_db enabled\\\]" \
"Using host libthread_db library \[^\r\n\]+"]
"Using host libthread_db library \[^\r\n\]+\r\n"]
set optional_re \
[list \
"\(" \
"\($reading_re)" \
"|" \
"\($warning_slow_re\)" \
"|" \
"\($libthread_db_re\)" \
"|" \
"\(\r\n$warning_gdb_index_re\)?" \
"\)*"]
set optional_re [join $optional_re ""]
set run_re \
[list \
"\r\n\032\032post-prompt\r\nStarting program: $binexp " \
"\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)\)*" \
"\(\r\n$warning_gdb_index_re\)?" \
"\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \
"\032\032starting\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)|\r\n$libthread_db_re\)*" \
"\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \
"\032\032breakpoint 1\r\n\r\n" \
"Breakpoint 1, \r\n" \
"\032\032frame-begin 0 $hex\r\n\r\n" \
"\032\032frame-function-name\r\n" \
"main\r\n" \
"\032\032frame-args\r\n \\(\\)\r\n" \
"\032\032frame-source-begin\r\n at \r\n" \
"\032\032frame-source-file\r\n.*annota1.c\r\n" \
"\032\032frame-source-file-end\r\n:\r\n" \
"\032\032frame-source-line\r\n$main_line\r\n" \
"\032\032frame-source-end\r\n\r\n\r\n" \
"\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n\r\n" \
"\032\032frame-end\r\n\r\n" \
"\032\032stopped"]
"\r\n\032\032post-prompt\r\n" \
"Starting program: $binexp \r\n" \
$optional_re \
"\(\r\n\032\032breakpoints-invalid\r\n\)?" \
$optional_re \
"\r\n\032\032starting\r\n" \
$optional_re \
"\r\n\032\032frames-invalid\r\n" \
$optional_re \
"\r\n\032\032breakpoints-invalid\r\n" \
$optional_re \
"\r\n\032\032breakpoint 1\r\n" \
"\r\n" \
"Breakpoint 1, " \
"\r\n\032\032frame-begin 0 $hex\r\n" \
"\r\n\032\032frame-function-name\r\n" \
"main" \
"\r\n\032\032frame-args\r\n" \
" \\(\\)" \
"\r\n\032\032frame-source-begin\r\n" \
" at " \
"\r\n\032\032frame-source-file\r\n" \
".*annota1.c" \
"\r\n\032\032frame-source-file-end\r\n" \
":" \
"\r\n\032\032frame-source-line\r\n" \
"$main_line" \
"\r\n\032\032frame-source-end\r\n" \
"\r\n" \
"\r\n\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n" \
"\r\n\032\032frame-end\r\n" \
"\r\n\032\032stopped\r\n"]
set run_re [join $run_re ""]

View File

@@ -195,4 +195,9 @@ gdb_test_no_output "set remote hardware-breakpoint-limit -1"
gdb_test_no_output "set remote hardware-watchpoint-limit 2147483647"
gdb_test_no_output "set remote hardware-breakpoint-limit 2147483647"
# Check the X/P/p alias commands display the correct packet names.
foreach pkt {X P p} {
gdb_test "show remote ${pkt}-packet" "Support for the `${pkt}' packet is.*"
}
gdb_exit

View File

@@ -42,10 +42,10 @@ proc stap_test {exec_name {args ""}} {
"check argument not at probe point"
if {[string first "-DUSE_SEMAPHORES" $args] != -1} {
gdb_test "info probes stap" \
gdb_test_lines "info probes stap" "" \
"test *user *$hex *$hex .*"
} else {
gdb_test "info probes stap" \
gdb_test_lines "info probes stap" "" \
"test *user *$hex .*"
}

View File

@@ -84,9 +84,9 @@ gdb_breakpoint "foo"
gdb_continue_to_breakpoint "foo"
gdb_test_multiple "return 35" "" {
-re ".*Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now?.*\\(y or n\\) $" {
send_gdb "n\n"
-re "Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now\\? \\(y or n\\) $" {
pass $gdb_test_name
gdb_test "n" "Not confirmed" "cancel return"
}
}

View File

@@ -21,8 +21,10 @@ if {![dwarf2_support]} {
standard_testfile .S -main.c
set binfile_stripped ${binfile}-stripped
if { [prepare_for_testing "failed to prepare" "${testfile}" \
[list $srcfile2 $srcfile] {nodebug}] } {
[list $srcfile2 $srcfile] {nodebug nopie}] } {
return -1
}
@@ -40,7 +42,7 @@ gdb_unload
# Strip out any labels there as they could corrupt the `main' name.
set objcopy_program [gdb_find_objcopy]
set command "$objcopy_program -N block_start -N block_end -N break_at ${binfile}"
set command "$objcopy_program -N block_start -N block_end -N break_at ${binfile} ${binfile_stripped}"
verbose -log "Executing: $command"
set result [catch "exec $command" output]
verbose "result is $result"
@@ -49,7 +51,7 @@ if {$result != 0} {
return -1
}
gdb_load ${binfile}
gdb_load ${binfile_stripped}
if ![runto "*${break_at}"] {
return -1

View File

@@ -114,7 +114,7 @@ proc test_1 { _cv _cdw64 _lv _ldw64 {_string_form ""}} {
return -1
}
gdb_breakpoint "bar"
gdb_breakpoint "bar_label"
gdb_continue_to_breakpoint "foo \\(1\\)"
gdb_test "next" "foo \\(2\\).*" "next to foo (2)"

View File

@@ -49,7 +49,7 @@ gdb_test_multiple "maintenance print symbols" "" {
-re "^\r\n void main.T.Bar\[^\r\n\]*(?=\r\n)" {
exp_continue
}
-re "\r\n$gdb_prompt $" {
-re "^\r\n$gdb_prompt $" {
pass $gdb_test_name
}
-re "\r\n\[^\r\n\]*(?=\r\n)" {

View File

@@ -0,0 +1,73 @@
/* This testcase is part of GDB, the GNU debugger.
Copyright 2016-2022 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <pthread.h>
#include <unistd.h>
#include <stdint.h>
#define NUM_THREADS 2
static volatile int unblock_main[NUM_THREADS];
static void
child_sub_function (int child_idx)
{
volatile int dummy = 0;
unblock_main[child_idx] = 1;
while (1)
/* Dummy loop body to allow setting breakpoint. */
dummy = !dummy; /* thread loop line */
}
static void *
child_function (void *args)
{
int child_idx = (int) (uintptr_t) args;
child_sub_function (child_idx); /* thread caller line */
return NULL;
}
int
main (void)
{
int i = 0;
pthread_t threads[NUM_THREADS];
/* Make the test exit eventually. */
alarm (20);
for (i = 0; i < NUM_THREADS; i++)
pthread_create (&threads[i], NULL, child_function, (void *) (uintptr_t) i);
/* Wait for child threads to reach child_sub_function. */
for (i = 0; i < NUM_THREADS; i++)
while (!unblock_main[i])
;
volatile int dummy = 0;
while (1)
/* Dummy loop body to allow setting breakpoint. */
dummy = !dummy; /* main break line */
return 0;
}

View File

@@ -18,7 +18,7 @@
load_lib mi-support.exp
standard_testfile user-selected-context-sync.c
standard_testfile
if {[build_executable $testfile.exp $testfile ${srcfile} "debug pthreads"] == -1} {
untested "failed to compile"
@@ -79,7 +79,7 @@ mi_gdb_test "thread" \
# Check we're in frame 0.
mi_gdb_test "frame" \
".*#0 0x.*" \
".*#0 .*child_sub_function .*" \
"frame 1"
# Ask about a different frame in the current thread, the current frame
@@ -93,7 +93,7 @@ mi_gdb_test "thread" \
"info thread 6"
mi_gdb_test "frame" \
".*#0 0x.*" \
".*#0 .*child_sub_function.*" \
"frame 2"
@@ -108,7 +108,7 @@ mi_gdb_test "thread" \
"info thread 7"
mi_gdb_test "frame" \
".*#0 0x.*" \
".*#0 .*child_sub_function.*" \
"frame 3"
# Select a different frame in the current thread. Despite the use of
@@ -123,7 +123,7 @@ mi_gdb_test "thread" \
"info thread 8"
mi_gdb_test "frame" \
".*#1 0x.*" \
".*#1 .*child_function.*" \
"frame 4"
# Similar to the previous test, but this time the --frame option is

View File

@@ -76,6 +76,9 @@ proc test_value_creation {} {
# Test address attribute is None in a non-addressable value
gdb_test "python print ('result = %s' % i.address)" "= None" "test address attribute in non-addressable value"
# Test creating / printing an optimized out value
gdb_test "python print(gdb.Value(gdb.Value(5).type.optimized_out()))"
}
# Check that we can call gdb.Value.__init__ to change a value.

View File

@@ -145,3 +145,5 @@ gdb_test "print 0x0 as fn(i64) -> ()" " = \\\(\\*mut fn \\\(i64\\\) -> \\\(\\\)\
gdb_test "print r#" "No symbol 'r' in current context"
gdb_test "printf \"%d %d\\n\", 23+1, 23-1" "24 22"
gdb_test "print 5," "Syntax error near ','"

View File

@@ -8302,6 +8302,29 @@ gdb_caching_proc have_mpx {
remote_file build delete $obj
if { $status == 0 } {
verbose "$me: returning $status" 2
return $status
}
# Compile program with -mmpx -fcheck-pointer-bounds, try to trigger
# 'No MPX support', in other words, see if kernel supports mpx.
set src { int main (void) { return 0; } }
set comp_flags {}
append comp_flags " additional_flags=-mmpx"
append comp_flags " additional_flags=-fcheck-pointer-bounds"
if {![gdb_simple_compile $me-2 $src executable $comp_flags]} {
return 0
}
set result [remote_exec target $obj]
set status [lindex $result 0]
set output [lindex $result 1]
set status [expr ($status == 0) \
&& ![string equal $output "No MPX support\r\n"]]
remote_file build delete $obj
verbose "$me: returning $status" 2
return $status
}

View File

@@ -260,6 +260,41 @@ void (*deprecated_context_hook) (int id);
/* The highest UI number ever assigned. */
static int highest_ui_num;
/* Unbuffer STREAM. This is a wrapper around setbuf(STREAM, nullptr)
which applies some special rules for MS-Windows hosts. */
static void
unbuffer_stream (FILE *stream)
{
/* Unbuffer the input stream so that in gdb_readline_no_editing_callback,
the calls to fgetc fetch only one char at the time from STREAM.
This is important because gdb_readline_no_editing_callback will read
from STREAM up to the first '\n' character, after this GDB returns to
the event loop and relies on a select on STREAM indicating that more
input is pending.
If STREAM is buffered then the fgetc calls may have moved all the
pending input from the kernel into a local buffer, after which the
select will not indicate that more input is pending, and input after
the first '\n' will not be processed immediately.
Please ensure that any changes in this area run the MI tests with the
FORCE_SEPARATE_MI_TTY=1 flag being passed. */
#ifdef __MINGW32__
/* With MS-Windows runtime, making stdin unbuffered when it's
connected to the terminal causes it to misbehave. */
if (!ISATTY (stream))
setbuf (stream, nullptr);
#else
/* On GNU/Linux the issues described above can impact GDB even when
dealing with input from a terminal. For now we unbuffer the input
stream for everyone except MS-Windows. */
setbuf (stream, nullptr);
#endif
}
/* See top.h. */
ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_)
@@ -286,6 +321,8 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_)
{
buffer_init (&line_buffer);
unbuffer_stream (instream_);
if (ui_list == NULL)
ui_list = this;
else
@@ -415,6 +452,8 @@ read_command_file (FILE *stream)
{
struct ui *ui = current_ui;
unbuffer_stream (stream);
scoped_restore save_instream
= make_scoped_restore (&ui->instream, stream);

View File

@@ -343,8 +343,10 @@ struct value
LONGEST embedded_offset = 0;
LONGEST pointed_to_offset = 0;
/* Actual contents of the value. Target byte-order. NULL or not
valid if lazy is nonzero. */
/* Actual contents of the value. Target byte-order.
May be nullptr if the value is lazy or is entirely optimized out.
Guaranteed to be non-nullptr otherwise. */
gdb::unique_xmalloc_ptr<gdb_byte> contents;
/* Unavailable ranges in CONTENTS. We mark unavailable ranges,
@@ -1725,8 +1727,10 @@ value_copy (const value *arg)
val->stack = arg->stack;
val->is_zero = arg->is_zero;
val->initialized = arg->initialized;
val->unavailable = arg->unavailable;
val->optimized_out = arg->optimized_out;
if (!value_lazy (val))
if (!value_lazy (val) && !value_entirely_optimized_out (val))
{
gdb_assert (arg->contents != nullptr);
ULONGEST length = TYPE_LENGTH (value_enclosing_type (arg));
@@ -1735,8 +1739,6 @@ value_copy (const value *arg)
copy (arg_view, value_contents_all_raw (val));
}
val->unavailable = arg->unavailable;
val->optimized_out = arg->optimized_out;
val->parent = arg->parent;
if (VALUE_LVAL (val) == lval_computed)
{
@@ -4271,6 +4273,20 @@ test_insert_into_bit_range_vector ()
}
}
static void
test_value_copy ()
{
type *type = builtin_type (current_inferior ()->gdbarch)->builtin_int;
/* Verify that we can copy an entirely optimized out value, that may not have
its contents allocated. */
value_ref_ptr val = release_value (allocate_optimized_out_value (type));
value_ref_ptr copy = release_value (value_copy (val.get ()));
SELF_CHECK (value_entirely_optimized_out (val.get ()));
SELF_CHECK (value_entirely_optimized_out (copy.get ()));
}
} /* namespace selftests */
#endif /* GDB_SELF_TEST */
@@ -4355,6 +4371,7 @@ and exceeds this limit will cause an error."),
selftests::register_test ("ranges_contain", selftests::test_ranges_contain);
selftests::register_test ("insert_into_bit_range_vector",
selftests::test_insert_into_bit_range_vector);
selftests::register_test ("value_copy", selftests::test_value_copy);
#endif
}

View File

@@ -1 +1 @@
12.0.50.DATE-git
12.1

View File

@@ -14,7 +14,7 @@
@SET_MAKE@
# Copyright (C) 2019-2021 Free Software Foundation, Inc.
# Copyright (C) 2019-2022 Free Software Foundation, Inc.
# This file is part of GDB.

View File

@@ -2,7 +2,7 @@
<!-- Parent-Version: 1.78 -->
<!--
Copyright (C) 2006-2022 Free Software Foundation, Inc.
Copyright (C) 2006-2021 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

View File

@@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<!--
Copyright (C) 2007-2022 Free Software Foundation, Inc.
Copyright (C) 2007-2021 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

View File

@@ -743,6 +743,8 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
else
{
#ifndef WINDOWS32
/* Recognize ~user as a shorthand for the specified user's home
directory. */
char *end_name = strchr (dirname, '/');
char *user_name;
int malloc_user_name = 0;
@@ -881,7 +883,22 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
}
scratch_buffer_free (&pwtmpbuf);
}
#endif /* !WINDOWS32 */
#else /* WINDOWS32 */
/* On native Windows, access to a user's home directory
(via GetUserProfileDirectory) or to a user's environment
variables (via ExpandEnvironmentStringsForUser) requires
the credentials of the user. Therefore we cannot support
the ~user syntax on this platform.
Handling ~user specially (and treat it like plain ~) if
user is getenv ("USERNAME") would not be a good idea,
since it would make people think that ~user is supported
in general. */
if (flags & GLOB_TILDE_CHECK)
{
retval = GLOB_NOMATCH;
goto out;
}
#endif /* WINDOWS32 */
}
}

View File

@@ -530,12 +530,13 @@ restart:
if (h != handle_array[nhandles])
{
/* Perform handle->descriptor mapping. */
WSAEventSelect ((SOCKET) h, NULL, 0);
if (FD_ISSET (h, &handle_rfds))
SOCKET s = (SOCKET) h;
WSAEventSelect (s, NULL, 0);
if (FD_ISSET (s, &handle_rfds))
FD_SET (i, rfds);
if (FD_ISSET (h, &handle_wfds))
if (FD_ISSET (s, &handle_wfds))
FD_SET (i, wfds);
if (FD_ISSET (h, &handle_xfds))
if (FD_ISSET (s, &handle_xfds))
FD_SET (i, xfds);
}
else

View File

@@ -2033,9 +2033,17 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
# undef swab
# define swab _swab
# endif
_GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n));
/* Need to cast, because in old mingw the arguments are
(const char *from, char *to, size_t n). */
_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
# else
# if defined __hpux /* HP-UX */
_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
# elif defined __sun && !defined _XPG4 /* Solaris */
_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
# else
_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
# endif
# endif
_GL_CXXALIASWARN (swab);
#endif

View File

@@ -0,0 +1,49 @@
commit 38d0749a3077b03fda46567510b1217fb5e4e170
Author: Bruno Haible <bruno@clisp.org>
Date: Fri Apr 2 17:34:46 2021 +0200
glob: Reject ~user syntax, when flag GLOB_TILDE_CHECK is given.
Reported and patch suggested by Eli Zaretskii <eliz@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-03/msg00136.html>.
* lib/glob.c (__glob) [WINDOWS32]: If flag GLOB_TILDE_CHECK is given, do
error handling like when ~user is allowed by the user is unknown.
diff --git a/gnulib/import/glob.c b/gnulib/import/glob.c
index 775911ef5b..e148f8d761 100644
--- a/gnulib/import/glob.c
+++ b/gnulib/import/glob.c
@@ -743,6 +743,8 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
else
{
#ifndef WINDOWS32
+ /* Recognize ~user as a shorthand for the specified user's home
+ directory. */
char *end_name = strchr (dirname, '/');
char *user_name;
int malloc_user_name = 0;
@@ -881,7 +883,22 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
}
scratch_buffer_free (&pwtmpbuf);
}
-#endif /* !WINDOWS32 */
+#else /* WINDOWS32 */
+ /* On native Windows, access to a user's home directory
+ (via GetUserProfileDirectory) or to a user's environment
+ variables (via ExpandEnvironmentStringsForUser) requires
+ the credentials of the user. Therefore we cannot support
+ the ~user syntax on this platform.
+ Handling ~user specially (and treat it like plain ~) if
+ user is getenv ("USERNAME") would not be a good idea,
+ since it would make people think that ~user is supported
+ in general. */
+ if (flags & GLOB_TILDE_CHECK)
+ {
+ retval = GLOB_NOMATCH;
+ goto out;
+ }
+#endif /* WINDOWS32 */
}
}

View File

@@ -0,0 +1,36 @@
commit c7b1e060d17023065c776757da406d728310cc38
Author: Bruno Haible <bruno@clisp.org>
Date: Sun Jun 20 17:18:26 2021 +0200
unistd: Avoid compilation error in C++ mode on Solaris, HP-UX, mingw.
Reported by Eli Zaretskii <eliz@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-03/msg00135.html>.
* lib/unistd.in.h (swab): Consider different declarations on Solaris,
HP-UX, and old mingw.
diff --git a/gnulib/import/unistd.in.h b/gnulib/import/unistd.in.h
index d4d4ba7743..73c882f97b 100644
--- a/gnulib/import/unistd.in.h
+++ b/gnulib/import/unistd.in.h
@@ -2034,9 +2034,17 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
# undef swab
# define swab _swab
# endif
-_GL_CXXALIAS_MDA (swab, void, (char *from, char *to, int n));
-# else
+/* Need to cast, because in old mingw the arguments are
+ (const char *from, char *to, size_t n). */
+_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
+# else
+# if defined __hpux /* HP-UX */
+_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
+# elif defined __sun && !defined _XPG4 /* Solaris */
+_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
+# else
_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
+# endif
# endif
_GL_CXXALIASWARN (swab);
#endif

View File

@@ -0,0 +1,33 @@
commit 21fccfa0451ba59fba479e439465da9c360353d3
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu Jul 8 10:00:30 2021 -0700
select: port better to MinGW
Problem reported by Eli Zaretskii in:
https://lists.gnu.org/r/bug-gnulib/2021-07/msg00017.html
* lib/select.c (rpl_select) [_WIN32 && !__CYGWIN__]:
Pass a SOCKET, not a HANDLE, to FD_ISSET.
diff --git a/gnulib/import/select.c b/gnulib/import/select.c
index 2fe6a18064..eddac4b61f 100644
--- a/gnulib/import/select.c
+++ b/gnulib/import/select.c
@@ -530,12 +530,13 @@ restart:
if (h != handle_array[nhandles])
{
/* Perform handle->descriptor mapping. */
- WSAEventSelect ((SOCKET) h, NULL, 0);
- if (FD_ISSET (h, &handle_rfds))
+ SOCKET s = (SOCKET) h;
+ WSAEventSelect (s, NULL, 0);
+ if (FD_ISSET (s, &handle_rfds))
FD_SET (i, rfds);
- if (FD_ISSET (h, &handle_wfds))
+ if (FD_ISSET (s, &handle_wfds))
FD_SET (i, wfds);
- if (FD_ISSET (h, &handle_xfds))
+ if (FD_ISSET (s, &handle_xfds))
FD_SET (i, xfds);
}
else

View File

@@ -180,6 +180,7 @@ fi
# Apply our local patches.
apply_patches ()
{
echo "Applying $1..."
patch -p2 -f -i "$1"
if [ $? -ne 0 ]; then
echo "Failed to apply some patches. Aborting."
@@ -188,6 +189,9 @@ apply_patches ()
}
apply_patches "patches/0001-use-windows-stat"
apply_patches "patches/0002-glob-tilde-check"
apply_patches "patches/0003-unistd-h-fix"
apply_patches "patches/0004-select-mingw"
# Regenerate all necessary files...
aclocal &&