The C++ parts of gdb.base/print-file-var.exp failed to build with
Clang because the "-x c++" option added by gdb_compile caused the
compiler to attempt to parse .so files as C++. This commit splits
the compiler and linker options into separate lists, and switches
to building via build_executable_from_specs which can accommodate
this separation.
gdb/testsuite/ChangeLog:
* gdb.base/print-file-var.exp (test): Separate compiler and
linker options, and build using build_executable_from_specs
to accommodate this.
In commits 221db974e6 and
68d654afdf, these patches:
2020-06-24 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when
compiling C++ programs.
2020-09-25 Gary Benson <gbenson@redhat.com>
* lib/gdb.exp (gdb_compile): Pass "-x c++" earlier, and only
for .c files.
attempted to fix problems with testcases that compile .c files
using the C++ compiler. These patches cause gdb_compile to add
"-x c++" to the compiler options when using Clang. This fix does
not work for gdb.base/print-file-var.exp, however, which attempts
to compile a .c input file to an executable linked with shared
libraries: the resulting command caused the compiler to attempt
to parse the .so files as C++. This commit causes gdb_compile
to reject this combination of options.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_compile): Inhibit passing "-x c++"
for .c files compiled as C++ with Clang if any shared
libraries are specified.
Clang fails to compile a number of files with the following warning:
unknown attribute 'noclone' ignored [-Wunknown-attributes]. This
commit adds a new header, lib/noclone.h, which defines the macro
ATTRIBUTE_NOCLONE accordingly, and updates the relevant testcases
to use it.
gdb/testsuite/ChangeLog:
* lib/attributes.h: New header.
* gdb.base/backtrace.c: Include the above. Replace
__attribute__(noclone)) with ATTRIBUTE_NOCLONE.
* gdb.base/infcall-nested-structs.c: Likewise.
* gdb.base/vla-optimized-out.c: Likewise.
Consider test-case gdb.dwarf2/fission-multi-cu.exp. It produces an executable
fission-multi-cu and a dwo file fission-multi-cu.dwo.
The file fission-multi-cu.dwo contains a .debug_line.dwo section, which
according to the DWARF v5 standard is a "specialized line number table" for
type units in the .debug_info.dwo section, and contains only the directory and
filename lists.
When reading the actual .debug_line.dwo section using readelf -w, we get:
...
The Directory Table is empty.
The File Name Table is empty.
No Line Number Statements.
...
So, the section does not contain any actual information. Furthermore, no
information is required because the .debug_line.dwo section does not contain
any type units.
This is confirmed by:
- re-doing the commands listed at the start of fission-multi-cu.S, which were
used as starting point for fission-multi-cu.S, and
- compiling the fission-multi-cu{1,2}.c files with clang -flto -g -gsplit-dwarf
In both cases, no .debug_line.dwo section is generated.
Remove the .debug_line.dwo section, to make it fit how split dwarf is actually
generated by clang.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-11-02 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/fission-multi-cu.S: Remove .debug_line.dwo section.
I noticed an issue with the RISC-V prologue scanning stack unwinder.
We currently read the frame base register (either $sp or $fp) as a
signed value. This means that the frame_id's stack_addr field will be
a signed value.
In other contexts though these registers are data pointers, and so are
unsigned.
There's not many places where this mismatch actually shows though, but
I did find one place. Consider this GDB session:
(gdb) maintenance set dwarf unwinders off
(gdb) set backtrace past-main on
...
(gdb) b main
Breakpoint 1 at 0x20400344: file main.c, line 86.
(gdb) run
...
(gdb) bt
#0 main () at main.c:86
#1 0x2040005c in _start () at start.S:59
Backtrace stopped: frame did not save the PC
(gdb) info frame 1
Stack frame at 0x80000a1c:
pc = 0x2040005c in _start (start.S:59); saved pc = <not saved>
Outermost frame: frame did not save the PC
caller of frame at 0x80000a1c
source language asm.
Arglist at 0x80000a1c, args:
Locals at 0x80000a1c, Previous frame's sp is 0x80000a1c
(gdb) frame address 0x80000a1c
No frame at address 0x80000a1c.
(gdb) frame address 0xffffffff80000a1c
#1 0x2040005c in _start () at start.S:59
59 call main
Notice that the 'info frame 1' reports that the frame is at
'0x80000a1c', this is the unsigned frame base value, but when I try
to select a frame using this address I can't.
The reason is that the frame_id for frame #1 actually has the
unsigned (and hence sign-extended) stack_addr value. When I use the
sign extended address I can correctly select the frame.
I propose changing the prologue scanning unwinder to read the frame
base as unsigned. After this in the above case I can now do this:
(gdb) frame address 0x80000a1c
#1 0x2040005c in _start () at start.S:59
59 call main
(gdb) frame address 0xffffffff80000a1c
No frame at address 0xffffffff80000a1c.
Which I think makes more sense.
This issue causes failures in gdb.base/frame-selection.exp if you
compile for RV32 with a linker script that places the stack in the
correct location, which are resolved by this patch.
gdb/ChangeLog:
* riscv-tdep.c (riscv_frame_cache): Read the frame base register
as an unsigned value.
I noticed a little diff when re-generating the configure file in this
directory.
sim/ChangeLog:
* bpf/configure: Re-generate.
Change-Id: Ieb26be2cc1be8108d4b08387255f45b57f288171
This patch reverts most of git commit 1e3b96fd6c, so IR symbols are
again not marked def_regular or ref_regular. That should be enough to
stop IR symbols from becoming dynamic. To mark as-needed shared
libraries referenced by IR symbols, use the referencing BFD rather
than the ref flags.
bfd/
PR 15146
PR 26314
PR 26530
PR 26806
* elflink.c (elf_link_add_object_symbols): Don't set def/ref flags
for plugin syms. Do allow plugin syms to mark as-needed libs.
ld/
PR 26806
* testsuite/ld-plugin/lto-19.h,
* testsuite/ld-plugin/lto-19a.c,
* testsuite/ld-plugin/lto-19b.c,
* testsuite/ld-plugin/lto-19c.c: New test.
* testsuite/ld-plugin/pr26806.c,
* testsuite/ld-plugin/pr26806.d: New test.
* testsuite/ld-plugin/lto.exp: Run them.
This changes end_psymtab_common to be a method on partial_symtab.
This seems a little cleaner to me.
gdb/ChangeLog
2020-11-01 Tom Tromey <tom@tromey.com>
* dbxread.c (dbx_end_psymtab): Update.
* dwarf2/read.c (process_psymtab_comp_unit_reader)
(build_type_psymtabs_reader): Update.
* xcoffread.c (xcoff_end_psymtab): Update.
* ctfread.c (scan_partial_symbols): Update.
* psymtab.c (sort_pst_symbols): Remove.
(partial_symtab::end): Rename from end_psymtab_common. Inline
sort_pst_symbols.
* psympriv.h (struct partial_symtab) <end>: New method.
(end_psymtab_common): Don't declare.
The "n_psyms" statistic in the per-objfile stats is not really needed,
but its use requires passing the objfile to add_psymbol. This patch
removes the field in favor of counting the psyms when needed.
Note that this is not exactly equivalent -- in the old approach, a
psymbol can in theory be created and then the psymtab discarded, which
would increment the counter. This does not seem very important to me.
I rewrote the code to count partial symbols; though TBH I think that
this information is not really very useful.
gdb/ChangeLog
2020-11-01 Tom Tromey <tom@tromey.com>
* symmisc.c (count_psyms): New function.
(print_objfile_statistics): Use it.
* psymtab.c (append_psymbol_to_list): Remove.
(partial_symtab::add_psymbol): Inline append_psymbol_to_list.
* objfiles.h (struct objstats) <n_psyms>: Remove.
init_psymbol_list is now empty, and so this removes it.
gdb/ChangeLog
2020-11-01 Tom Tromey <tom@tromey.com>
* dbxread.c (dbx_symfile_read): Update.
* dwarf2/read.c (dwarf2_build_psymtabs): Update.
* xcoffread.c (xcoff_initial_scan): Update.
* psympriv.h (init_psymbol_list): Don't declare.
* psymtab.c (init_psymbol_list): Remove.
The test program being used declares a fixed-point type
(Base_Fixed_Point_Type) Base_Fixed_Point_Type whose (scaled) range
is System.Min_Int .. System.Max_Int. is an unwarranted assumption because
the range is implementation-defined. It means the compiler is therefore
free to reject that declaration.
We noticed this while one of my coworkers was working on enhancing
GNAT to support 128bit integers. The bulk of the work has been done,
but one side-effect is that there is a small gap in this particular
area where the compiler is now rejecting this code. We will eventually
plug that gap, but in meantime, since the testcase itself doesn't really
need such a large range, this commit simply adjusts the test program
to use hard-coded bounds for the range whose value are more reasonable.
gdb/testsuite/ChangeLog:
* gdb.ada/fixed_points/fixed_points.adb: Replace use of
System.Min_Int and System.Max_Int with smaller hardcoded
constants.
This commit renames gnat_encoded_fixed_type_info into
gnat_encoded_fixed_point_type_info, so as to be more consistent
with the naming used for the other associated routines (i.e.
use "fixed_point" rather than just "fixed").
gdb/ChangeLog:
* ada-lang.c (gnat_encoded_fixed_point_type_info): Renames
gnat_encoded_fixed_type_info. Update all callers.
One of the lines got too long after a renaming done in a previous
commit. This fixes that.
gdb/ChangeLog:
* ada-lang.c (cast_from_gnat_encoded_fixed_point_type): Split
line too long.
This patch renames some of the fixed-point-related subprograms in ada-lang.c
so as to make it obvious that those routines only handle the case where
the types are encoded using the GNAT encoding.
No function change; this patch is preparation work for adding support
for fixed-point types purely based on standard DWARF debug info.
gdb/ChangeLog:
* ada-lang.c (cast_from_gnat_encoded_fixed_point_type): Renames
cast_from_fixed. Update all callers.
(cast_to_gnat_encoded_fixed_point_type): Renames cast_to_fixed.
Update all callers.
(gnat_encoded_fixed_point_scaling_factor): Renames ada_scaling_factor.
Update all callers.
* ada-lang.h (gnat_encoded_fixed_point_scaling_factor): Renames
ada_scaling_factor.
* ada-typeprint.c: Replace call to ada_scaling_factor by call
to print_gnat_encoded_fixed_point_type.
* ada-valprint.c: Likewise.
This partially reverts some parts of the commit:
commit 17417fb0ec
Date: Sat Oct 31 09:01:25 2020 -0400
gdb, gdbsupport: add debug_prefixed_printf, remove boilerplate functions
This commit removed 3 places where some debug flags were being
checked. The result was that debug tracing was being printed
unconditionally.
This commit adds back the 3 flag checks.
gdb/ChangeLog:
* infrun.h (infrun_debug_printf): Add check of debug_infrun flag.
(debug_prefixed_printf): Add check of debug_displaced flag.
* linux-nat.c (linux_nat_debug_printf): Add check of
debug_linux_nat flag.
The *_debug_print_1 functions are all very similar, the only difference
being the subsystem name. Remove them all and make the logging macros
use a new debug_prefixed_printf function directly.
gdb/ChangeLog:
* infrun.c (infrun_debug_printf_1): Remove.
(displaced_debug_printf_1): Remove.
(stop_all_threads): Use debug_prefixed_printf.
* infrun.h (infrun_debug_printf_1): Remove.
(infrun_debug_printf): Use debug_prefixed_printf.
(displaced_debug_printf_1): Remove.
(displaced_debug_printf): Use debug_prefixed_printf.
* linux-nat.c (linux_nat_debug_printf_1): Remove.
(linux_nat_debug_printf): Use debug_prefixed_printf.
gdbsupport/ChangeLog:
* common-debug.cc (debug_prefixed_printf): New.
* common-debug.h (debug_prefixed_printf): New declaration.
* event-loop.cc (event_loop_debug_printf_1): Remove.
* event-loop.h (event_loop_debug_printf_1): Remove.
(event_loop_debug_printf): Use debug_prefixed_printf.
(event_loop_ui_debug_printf): Use debug_prefixed_printf.
Change-Id: Ib323087c7257f0060121d302055c41eb64aa60c6
... with AC_COMPILE_IFELSE and AC_LANG_PROGRAM.
All changes in the generated configure file are insignificant
whitespace changes.
gdbserver/ChangeLog:
* acinclude.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE +
AC_LANG_PROGRAM.
* configure: Re-generate.
Change-Id: Idab8b5e1a984046b5283940c02e5a22da2291d58
... with AC_LINK_IFELSE + AC_LANG_PROGRAM.
All changes in the generated configure file are insignificant whitespace
changes.
gdb/ChangeLog:
* configure: Re-generate.
* sanitize.m4: Replace AC_TRY_LINK with AC_LINK_IFELSE +
AC_LANG_PROGRAM.
Change-Id: I6fc4c39e10b28d2ade964e0d59a7f8ec0d3a272a
autoupdate does this change, it fixes this warning:
configure.ac:50: warning: The macro `AC_FUNC_VFORK' is obsolete.
configure.ac:50: You should run autoupdate.
../../lib/autoconf/functions.m4:1944: AC_FUNC_VFORK is expanded from...
common.m4:20: GDB_AC_COMMON is expanded from...
configure.ac:50: the top level
There are not changes in the generated configure files.
gdbsupport/ChangeLog:
* common.m4: Replace AC_FUNC_VFORK with AC_FUNC_FORK.
Change-Id: I9de9f718c57e6d51c9734161f36c36ce39170325
For some reason, autoupdate isn't able to grok ptrace.m4:
$ autoupdate ptrace.m4
/usr/bin/m4:/tmp/auYjuodw/input.m4:171: ERROR: end of file in string
autoupdate: /usr/bin/m4 failed with exit status: 1
Honestly, I'm unable to grok it either. This patch re-indents it in a
way that I think is easier to read. With this patch applied, autoupdate
becomes able to parse ptrace.m4, but I chose to keep this re-indent in a
patch of its own.
All the changes in generated configure files consist of insignificant
whitespace changes.
gdb/ChangeLog:
* configure: Re-generate.
gdbserver/ChangeLog:
* configure: Re-generate.
gdbsupport/ChangeLog:
* configure: Re-generate.
* ptrace.m4: Re-indent.
Change-Id: Ie2afab09fecc8b6d0cccccb47ac9756f3843881e
Run autoupdate, the only change is to split AC_INIT into AC_INIT and
AC_CONFIG_SRCDIR.
gdb/testsuite/ChangeLog:
* configure.ac: Split AC_INIT into AC_INIT and AC_CONFIG_SRCDIR.
* configure: Re-generate.
Change-Id: I6e40c0261bda4fe9144b896799ef460d23e22e09
Run autoupdate on configure.ac and adjust the indentation of the result
for better readability. This removes a bunch of warnings when running
`autoreconf -vf -Wall`. The changes are:
* Replace AC_INIT with AC_INIT and no arguments plus
AC_CONFIG_SRCDIR.
* Replace AC_ERROR with AC_MSG_ERROR.
* Replace AC_TRY_LINK with AC_LINK_IFELSE.
* Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE.
* Replace AC_HELP_STRING with AS_HELP_STRING.
autoupdate erroneously tries to replace AC_C_LONG_DOUBLE in a comment,
which I reverted manually.
All the changes in the generated configure file are insignificant
whitespaces changes.
gdb/ChangeLog:
* configure.ac: Modernize.
* configure: Re-generate.
Change-Id: Ie3a1409c8032a36a6383da964286a46ece9b546e
Run autoupdate on gdbserver/configure.ac and then tweak it to use easier
to read indentation. This removes a few warnings when running
`autoreconf -vf -Wall`.
* Replace AC_INIT with AC_INIT and no arguments plus AC_CONFIG_SRCDIR.
* Replace AC_GNU_SOURCE with AC_USE_SYSTEM_EXTENSIONS.
* Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE.
* Replace AC_TRY_LINK with AC_LINK_IFELSE.
autoupdate gets it right, except this one here:
--- a/gdbserver/configure.ac
+++ b/gdbserver/configure.ac
@@ -304,7 +304,7 @@ if test "$srv_linux_thread_db" = "yes"; then
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[found="-Wl,--dynamic-list"
RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],[RDYNAMIC="-rdynamic"
LDFLAGS="$old_LDFLAGS $RDYNAMIC"
- AC_TRY_LINK([], [],
+ _au_m4_changequote([,])AC_TRY_LINK([], [],
[found="-rdynamic"],
[found="no"
RDYNAMIC=""])])
... which I had to convert manually.
The changes in the generated configure file only contain insignificant
whitespace changes, so that gives confidence that the conversion is
correct.
gdbserver/ChangeLog:
* configure.ac: Modernize.
* configure: Re-generate.
Change-Id: Ia769aaec2aafac595504f477da955e91dffa4d8f
`autoconf -Wall` notes that AM_PROG_CC_STDC is obsolete:
Fixes this autoconf warning:
configure.ac:40: warning: 'AM_PROG_CC_STDC': this macro is obsolete.
configure.ac:40: You should simply use the 'AC_PROG_CC' macro instead.
configure.ac:40: Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
configure.ac:40: but upon 'ac_cv_prog_cc_stdc'.
aclocal.m4:770: AM_PROG_CC_STDC is expanded from...
configure.ac:40: the top level
Since we build with a C++ compiler now, I don't think this is relevant.
If you look at the messages removed from gdbsupport/aclocal.m4, it says
that this functionality is now integrated in AC_PROG_CC, which we
already call. So it might not even make a difference.
We had a local version of AM_PROG_CC_STDC, in gdb/acinclude.m4 (only
used by gdb/configure.ac), remove it.
gdb/ChangeLog:
* acinclude.m4 (AM_PROG_CC_STDC): Remove.
* configure: Re-generate.
* configure.ac: Remove AM_PROG_CC_STDC.
gdbsupport/ChangeLog:
* aclocal.m4: Re-generate.
* configure: Re-generate.
* configure.ac: Remove AM_PROG_CC_STDC.
Change-Id: Ic824393598805d4f78cda9d119f8af46096e9c73
`autoreconf -Wall` notes that AC_CANONICAL_SYSTEM is obsolete:
configure.ac:36: warning: The macro `AC_CANONICAL_SYSTEM' is obsolete.
Replace it by AC_CANONICAL_BUILD, AC_CANONICAL_HOST and
AC_CANONICAL_TARGET in configure.ac files in gdb, gdbserver and
gdbsupport. All three macros may not be needed everywhere, but it is
hard to completely audit the configure files to see which are required,
so I think it's better (and that there's no downside) to just call all
three.
gdb/ChangeLog:
* configure.ac: Use AC_CANONICAL_{BUILD,HOST,TARGET} instead of
AC_CANONICAL_SYSTEM.
* configure: Re-generate.
gdbserver/ChangeLog:
* configure.ac: Use AC_CANONICAL_{BUILD,HOST,TARGET} instead of
AC_CANONICAL_SYSTEM.
* configure: Re-generate.
gdbsupport/ChangeLog:
* configure.ac: Use AC_CANONICAL_{BUILD,HOST,TARGET} instead of
AC_CANONICAL_SYSTEM.
* configure: Re-generate.
Change-Id: Ifd0e21f1e478634e768b5de1b8ee06a7f690d863
Move all debug prints of the "displaced" category to use a new
displaced_debug_printf macro, like what was done for infrun and others
earlier.
The debug output for one displaced step one amd64 looks like:
[displaced] displaced_step_prepare_throw: stepping process 3367044 now
[displaced] displaced_step_prepare_throw: saved 0x555555555042: 1e fa 31 ed 49 89 d1 5e 48 89 e2 48 83 e4 f0 50
[displaced] amd64_displaced_step_copy_insn: copy 0x555555555131->0x555555555042: b8 00 00 00 00 5d c3 0f 1f 84 00 00 00 00 00 f3
[displaced] displaced_step_prepare_throw: displaced pc to 0x555555555042
[displaced] resume_1: run 0x555555555042: b8 00 00 00
[displaced] displaced_step_restore: restored process 3367044 0x555555555042
[displaced] amd64_displaced_step_fixup: fixup (0x555555555131, 0x555555555042), insn = 0xb8 0x00 ...
[displaced] amd64_displaced_step_fixup: relocated %rip from 0x555555555047 to 0x555555555136
On test case needed to be updated because it relied on the specific
formatting of the message.
gdb/ChangeLog:
* infrun.h (displaced_debug_printf): New macro. Replace
displaced debug prints throughout to use it.
(displaced_debug_printf_1): New declaration.
(displaced_step_dump_bytes): Return string, remove ui_file
parameter, update all callers.
* infrun.c (displaced_debug_printf_1): New function.
(displaced_step_dump_bytes): Return string, remove ui_file
parameter
gdb/testsuite/ChangeLog:
* gdb.arch/amd64-disp-step-avx.exp: Update displaced step debug
expected output.
Change-Id: Ie78837f56431f6f98378790ba1e6051337bf6533
With the current implementation of rs6000_dwarf2_reg_to_regnum, if an
unknown DWARF register number is passed, the same number is returned as
the internal GDB number. This assumes that the internal GDB register
numbers match the DWARF register numbers, which is not the case.
Change it to return -1, as documented in gdbarch.sh for the
dwarf2_reg_to_regnum method.
This fixes a failure in gdb.dwarf2/bad-regnum.exp:
(gdb) info addr foo1
-Symbol "foo1" is a variable in $.
-(gdb) FAIL: gdb.dwarf2/bad-regnum.exp: info addr foo1
+Symbol "foo1" is a variable in $bad_register_number.
+(gdb) PASS: gdb.dwarf2/bad-regnum.exp: info addr foo1
I ran the entire testsuite on powerpc64 (gcc203 on the compile farm) and
didn't see any regression.
gdb/ChangeLog:
* rs6000-tdep.c (rs6000_dwarf2_reg_to_regnum): Return -1 for
unknown register numbers.
Change-Id: I585aa07a08f845a46c36bfdb6d3118ea94f8f54d
I recently wrote a patch to modify configure.tgt. However, I did this
incorrectly the first time, and had to go back and add another file.
After building, I was surprised that my changes did not seem to work.
I tracked this down to the fact that init.c had not been rebuilt after
my changes -- because the files I added to the build were already
older than the existing init.c.
This patch changes the gdb Makefile so that init.c will be rebuilt if
config.status changes. This should cover various scenarios that cause
a re-configure, like editing configure.tgt.
2020-10-30 Tom Tromey <tromey@adacore.com>
* Makefile.in (stamp-init): Depend on config.status.
This patch adds new to Armv8.7 WFIT instruction which take one operand:
WFIT <Xt>
Where:
<Xt> is 64-bit name of the general-purpose source register, encoded in the
"Rd" field.
For more details regarding WFIT (Wait For Interrupt with Timeout) instruction for
Armv8.7-a please refer to Arm A64 Instruction set documentation for Armv8-A
architecture profile, see document pages 570 of [0].
[0]: https://developer.arm.com/docs/ddi0596/i
gas/ChangeLog:
2020-10-30 Przemyslaw Wirkus <przemyslaw.wirkus@arm.com>
* NEWS: Update docs.
* testsuite/gas/aarch64/system-5.d: Update test with WFIT insn.
* testsuite/gas/aarch64/system-5.s: Update test with WFIT insn.
opcodes/ChangeLog:
2020-10-30 Przemyslaw Wirkus <przemyslaw.wirkus@arm.com>
* aarch64-tbl.h (struct aarch64_opcode): New instruction WFIT.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.
Having pagination enabled when handling an inferior event gives the
user an option to quit, which causes early exit in GDB's flow and may
lead to half-baked state. For instance, here is a case where we quit
in the middle of handling an inferior exit:
$ gdb ./a.out
Reading symbols from ./a.out...
(gdb) set height 2
(gdb) run
Starting program: ./a.out
--Type <RET> for more, q to quit, c to continue without paging--q
Quit
Couldn't get registers: No such process.
(gdb) set height unlimited
Couldn't get registers: No such process.
(gdb) info threads
Id Target Id Frame
* 1 process 27098 Couldn't get registers: No such process.
Couldn't get registers: No such process.
(gdb)
Or suppose having a multi-threaded program like below:
static void *
fun (void *dummy)
{
int a = 1; /* break-here */
return NULL;
}
int
main (void)
{
pthread_t thread;
pthread_create (&thread, NULL, fun, NULL);
pthread_join (thread, NULL);
return 0;
}
If we define a breakpoint at line "break-here", we expect only Thread
2 to hit it.
$ gdb ./a.out
Reading symbols from ./a.out...
(gdb) break 7
Breakpoint 1 at 0x1182: file mt.c, line 7.
(gdb) set height 2
(gdb) run
Starting program: ./a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff77c4700 (LWP 23048)]
--Type <RET> for more, q to quit, c to continue without paging--q
Quit
(gdb) set height unlimited
(gdb) info thread
Id Target Id Frame
* 1 Thread 0x7ffff7fe3740 (LWP 23044) "a.out" 0x00007ffff7bbed2d in ...
2 Thread 0x7ffff77c4700 (LWP 23048) "a.out" fun (dummy=0x0) at mt.c:7
(gdb)
The prompt for continuation was triggered because Thread 2 hit the
breakpoint. (If we had hit 'c', we were going to see that stop event,
but we didn't.) The context did not switch to Thread 2. GDB also did
not execute several other things it would normally do in
infrun.c:normal_stop after outputting "[Switching to Thread ...]" (but
it seems harmless in this case). If we 'continue' at this state, both
threads run until termination, and we don't see the breakpoint hit
event ever.
Here is another related and more complicated scenario that leads to a
GDB crash. Create two inferiors, one sitting on top of a native
target, and the other on a remote target, so that we have a
multi-target setting, like so:
(gdb) i inferiors
Num Description Connection Executable
1 process 13786 1 (native) a.out
* 2 process 13806 2 (remote ...) target:a.out
Next, resume both inferiors to run until termination:
(gdb) set schedule-multiple on
(gdb) set height 2
(gdb) continue
Continuing.
--Type <RET> for more, q to quit, c to continue without paging--[Inferior 2 (process 13806) exited normally]
terminate called after throwing an instance of 'gdb_exception_error'
Aborted
Here, GDB first received a termination event from Inferior 1. GDB
attempted to print this event, triggering a "prompt for continue", and
GDB started polling for events, hoping to get an input from the user.
However, the exit event from Inferior 2 was received instead. So, GDB
started processing an exit event while being in the middle of
processing another exit event. It was not ready for this situation
and eventually crashed.
To address these cases, temporarily disable pagination in
fetch_inferior_event. This doesn't affect commands like 'info
threads', 'backtrace', or 'thread apply'.
Regression-tested on X86_64 Linux.
gdb/ChangeLog:
2020-10-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (fetch_inferior_event): Temporarily disable pagination.
gdb/testsuite/ChangeLog:
2020-10-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/paginate-after-ctrl-c-running.exp: Update with no pagination
behavior.
* gdb.base/paginate-bg-execution.exp: Ditto.
* gdb.base/paginate-inferior-exit.exp: Ditto.
* gdb.base/double-prompt-target-event-error.c: Remove.
* gdb.base/double-prompt-target-event-error.exp: Remove.
This function is now external, and isn't really threads related. Move
it to frame.c.
gdb/ChangeLog:
* thread.c (lookup_selected_frame): Move ...
* frame.c (lookup_selected_frame): ... here.
Change-Id: Ia96b79c15767337c68efd3358bcc715ce8e26c15
If the remote target closes while we're reading registers/memory for
restoring the selected frame in scoped_restore_current_thread's dtor,
the corresponding TARGET_CLOSE_ERROR error is swallowed by the
scoped_restore_current_thread's dtor, because letting exceptions
escape from a dtor is bad. It isn't great to lose that errors like
that, though. I've been thinking about how to avoid it, and I came up
with this patch.
The idea here is to make scoped_restore_current_thread's dtor do as
little as possible, to avoid any work that might throw in the first
place. And to do that, instead of having the dtor call
restore_selected_frame, which re-finds the previously selected frame,
just record the frame_id/level of the desired selected frame, and have
get_selected_frame find the frame the next time it is called. In
effect, this implements most of Cagney's suggestion, here:
/* On demand, create the selected frame and then return it. If the
selected frame can not be created, this function prints then throws
an error. When MESSAGE is non-NULL, use it for the error message,
otherwize use a generic error message. */
/* FIXME: cagney/2002-11-28: At present, when there is no selected
frame, this function always returns the current (inner most) frame.
It should instead, when a thread has previously had its frame
selected (but not resumed) and the frame cache invalidated, find
and then return that thread's previously selected frame. */
extern struct frame_info *get_selected_frame (const char *message);
The only thing missing to fully implement that would be to make
reinit_frame_cache just clear selected_frame instead of calling
select_frame(NULL), and the call select_frame(NULL) explicitly in the
places where we really wanted reinit_frame_cache to go back to the
current frame too. That can done separately, though, I'm not
proposing to do that in this patch.
Note that this patch renames restore_selected_frame to
lookup_selected_frame, and adds a new restore_selected_frame function
that doesn't throw, to be paired with the also-new save_selected_frame
function.
There's a restore_selected_frame function in infrun.c that I think can
be replaced by the new one in frame.c.
Also done in this patch is make the get_selected_frame's parameter be
optional, so that we don't have to pass down nullptr explicitly all
over the place.
lookup_selected_frame should really move from thread.c to frame.c, but
I didn't do that here, just to avoid churn in the patch while it
collects comments. I did make it extern and declared it in frame.h
already, preparing for the move. I will do the move as a follow up
patch if people agree with this approach.
Incidentally, this patch alone would fix the crashes fixed by the
previous patches in the series, because with this,
scoped_restore_current_thread's constructor doesn't throw either.
gdb/ChangeLog:
* blockframe.c (block_innermost_frame): Use get_selected_frame.
* frame.c
(scoped_restore_selected_frame::scoped_restore_selected_frame):
Use save_selected_frame. Save language as well.
(scoped_restore_selected_frame::~scoped_restore_selected_frame):
Use restore_selected_frame, and restore language as well.
(selected_frame_id, selected_frame_level): New.
(selected_frame): Update comments.
(save_selected_frame, restore_selected_frame): New.
(get_selected_frame): Use lookup_selected_frame.
(get_selected_frame_if_set): Delete.
(select_frame): Record selected_frame_level and selected_frame_id.
* frame.h (scoped_restore_selected_frame) <m_level, m_lang>: New
fields.
(get_selected_frame): Make 'message' parameter optional.
(get_selected_frame_if_set): Delete declaration.
(select_frame): Update comments.
(save_selected_frame, restore_selected_frame)
(lookup_selected_frame): Declare.
* gdbthread.h (scoped_restore_current_thread) <m_lang>: New field.
* infrun.c (struct infcall_control_state) <selected_frame_level>:
New field.
(save_infcall_control_state): Use save_selected_frame.
(restore_selected_frame): Delete.
(restore_infcall_control_state): Use restore_selected_frame.
* stack.c (select_frame_command_core, frame_command_core): Use
get_selected_frame.
* thread.c (restore_selected_frame): Rename to ...
(lookup_selected_frame): ... this and make extern. Select the
current frame if the frame level is -1.
(scoped_restore_current_thread::restore): Also restore the
language.
(scoped_restore_current_thread::~scoped_restore_current_thread):
Don't try/catch.
(scoped_restore_current_thread::scoped_restore_current_thread):
Save the language as well. Use save_selected_frame.
Change-Id: I73fd1cfc40d8513c28e5596383b7ecd8bcfe700f
The last commit missed updating the doc of
gdbarch_displaced_step_hw_singlestep to avoid mentioning the removed
parameter, this one fixes it.
gdb/ChangeLog:
* gdbarch.sh (displaced_step_hw_singlestep): Adjust
documentation.
* gdbarch.h: Re-generate.
Change-Id: I33675d9a6c253443eee707e8285d16615ce20aaa
I noticed that the closure parameter of
gdbarch_displaced_step_hw_singlestep is never used by any
implementation of the method, so this patch removes it.
gdb/ChangeLog:
* gdbarch.sh (displaced_step_hw_singlestep): Remove closure
parameter.
* aarch64-tdep.c (aarch64_displaced_step_hw_singlestep):
Likewise.
* aarch64-tdep.h (aarch64_displaced_step_hw_singlestep):
Likewise.
* arch-utils.c (default_displaced_step_hw_singlestep):
Likewise.
* arch-utils.h (default_displaced_step_hw_singlestep):
Likewise.
* rs6000-tdep.c (ppc_displaced_step_hw_singlestep):
Likewise.
* s390-tdep.c (s390_displaced_step_hw_singlestep):
Likewise.
* gdbarch.c: Re-generate.
* gdbarch.h: Re-generate.
* infrun.c (resume_1): Adjust.
Change-Id: I7354f0b22afc2692ebff0cd700a462db8f389fc1
There's no need to call exec_close from ~progspace, because that
method just does some cleanup that's already going to be done during
destruction. This patch removes the call.
gdb/ChangeLog
2020-10-29 Tom Tromey <tom@tromey.com>
* progspace.c (program_space::~program_space): Don't call
exec_close.
Now that we've removed the macros and moved various functions to be
methods on program_space (removing uses of current_program_space),
it's clear that exec_target::close can operate on program spaces
without changing the current program space.
gdb/ChangeLog
2020-10-29 Tom Tromey <tom@tromey.com>
* exec.c (exec_target::close): Don't change current program
space.
This changes add_target_sections_of_objfile to be a method on
program_space. It is renamed to be another overload of
add_target_sections, because they are semantically equivalent in a
sense.
gdb/ChangeLog
2020-10-29 Tom Tromey <tom@tromey.com>
* symfile.c (add_symbol_file_command): Update.
* exec.c (program_space::add_target_sections): Rename.
* symfile-mem.c (symbol_file_add_from_memory): Update.
* progspace.h (struct program_space) <add_target_sections>:
Declare new overload.
* exec.h (add_target_sections_of_objfile): Don't declare.
This changes add_target_sections to be a method on program_space.
Like the earlier change to remove_target_sections, this makes sense
because this function is manipulating data that is stored on the
program space.
gdb/ChangeLog
2020-10-29 Tom Tromey <tom@tromey.com>
* solib.c (solib_map_sections): Update.
* exec.c (program_space::add_target_sections): Now a method.
(exec_file_attach): Update.
* exec.h (add_target_sections): Don't declare.
* progspace.h (struct program_space) <add_target_sections>:
Declare.
This changes remove_target_sections to be a method on program_space.
This makes sense because this function manipulates data that is
attached to the program space.
gdb/ChangeLog
2020-10-29 Tom Tromey <tom@tromey.com>
* progspace.h (struct program_space) <remove_target_sections>:
Declare.
* exec.c (program_space::remove_target_sections): Now a method.
* exec.h (remove_target_sections): Don't declare.