* m10300-dis.c (disassemble): Move extraction of DREG, AREG, RREG,
and XRREG value earlier to avoid a shift with negative exponent.
* m10200-dis.c (disassemble): Similarly.
Also fixes a real bug. The DECODE_INSN_I9a and DECODE_INSN_I9b both
use UNSIGNED_EXTRACT for 7 low bits of the result, but this was an
unsigned value due to "insn" being unsigned. DECODE_INSN_I9* is
therefore unsigned too, leading to a zero extension in an expression
using a bfd_vma if bfd_vma is 64 bits.
* opcode/spu.h: Formatting.
(UNSIGNED_EXTRACT): Use 1u.
(SIGNED_EXTRACT): Don't sign extend with shifts.
(DECODE_INSN_I9a, DECODE_INSN_I9b): Avoid left shift of signed value.
Keep result signed.
(DECODE_INSN_U9a, DECODE_INSN_U9b): Delete.
Until recently when the source window was scrolled the assembler
window would scroll in sync - keeping the disassembly for the current
line in view.
This was broken in commit:
commit b4b49dcbff
Date: Wed Nov 13 16:47:58 2019 -0700
Don't call tui_show_source from tui_ui_out
This commit restores the synchronised scrolling and also maintains the
horizontal scroll within the source view when it is vertically
scrolled, something that was broken before.
This commit does not mean that scrolling the assembler view scrolls
the source view. The connection this way never existed, though maybe
it should, but I'll leave adding this feature for a separate commit.
gdb/ChangeLog:
* tui/tui-source.c (tui_source_window::do_scroll_vertical): Update
all source windows, and maintain horizontal scroll status while
doing so.
gdb/testsuite/ChangeLog:
* gdb.tui/basic.exp: Add more scrolling tests.
Change-Id: I250114a3bc670040a6a759d41905776771b2f818
Hannes Domani pointed out that my previous patch to fix the "list"
command in the TUI instead broke vertical scrolling. While looking at
this, I found that do_scroll_vertical calls print_source_lines, which
seems like a very roundabout way to change the source window. This
patch removes this oddity and fixes the bug at the same time.
I've added a new test case. This is somewhat tricky, because the
obvious approach of sending a dummy command after the scroll did not
work -- due to how the TUI works, sennding a command causes the scroll
to take effect.
gdb/ChangeLog
2019-12-22 Tom Tromey <tom@tromey.com>
PR tui/18932:
* tui/tui-source.c (tui_source_window::do_scroll_vertical): Call
update_source_window, not print_source_lines.
gdb/testsuite/ChangeLog
2019-12-22 Tom Tromey <tom@tromey.com>
PR tui/18932:
* lib/tuiterm.exp (Term::wait_for): Rename from _accept. Return a
meangingful value.
(Term::command, Term::resize): Update.
* gdb.tui/basic.exp: Add scrolling test.
Change-Id: I9636a7c8a8cade37431c6165ee996a9d556ef1c8
Currently if a user starts the tui with 'layout asm' then they will be
presented with the 'src' layout.
What happens is:
1. Layout command enables TUI, selecting the SRC layout by default.
2. As part of tui_enable we call tui_display_main, which calls
tui_get_begin_asm_address, which calls
set_default_source_symtab_and_line. This changes core GDBs
current symtab and line, which triggers a call to the symtab
changed hook tui_symtab_changed, which sets the flag
from_source_symtab.
3. Back in the layout command, the layout is changed from SRC to
ASM. After this the layout command completes and we return to
core GDB which prints the prompt, however...
4. The before prompt hook is called which sees the
from_source_symtab flag is set and forces the SRC window to be
displayed. This switches us back to SRC view.
The solution I propose here is to delay installing the hooks into core
GDB until after we have finished setting up the tui and selecting the
default frame to view. In this way we effectively ignore the first
symtab changed event triggered when making main the default symtab.
gdb/ChangeLog:
* tui/tui.c (tui_enable): Register tui hooks after calling
tui_display_main.
gdb/testsuite/ChangeLog:
* gdb.tui/tui-layout-asm.exp: New file.
Change-Id: I858ab81a17ffb4aa72deb3f36c3755228a9c9d9a
A new test procedure for matching the contents of one screen box
against a regexp. This can be used to match the contents of one TUI
window against a regexp without any of the borders, or other windows
being included in the matched output (as is currently the case with
check_contents).
This will be used in a later commit.
gdb/testsuite/ChangeLog:
* lib/tuiterm.exp (Term::check_box_contents): New proc.
Change-Id: Icf795bf38dd9295e282a34eecc318a9cdbc73926
Split Term::enter_tui into two procedures, a core which does the
setup, but doesn't actually enable tui mode, and the old enter_tui
that calls the new core, and then enables tui mode.
This is going to be useful in a later commit.
gdb/testsuite/ChangeLog:
* lib/tuiterm.exp (Term::prepare_for_tui): New proc.
(Term::enter_tui): Use Term::prepare_for_tui.
Change-Id: I501dfb2ddaa4a4e7246a5ad319ab428e4f42b3af
The Term::dump_screen routine currently dumps the screen using calls
to 'verbose', this means it will only dump the screen when the
testsuite is running in verbose mode.
However, the Term::dump_screen is most often called when a test fails,
in this case I think it is useful to have the screen dumped even when
we're not in verbose mode.
This commit changes the calls to 'verbose' to be 'verbose -log' so we
always get the screen dump.
gdb/testsuite/ChangeLog:
* lib/tuiterm.exp (Term::dump_screen): Always dump the screen when
called.
Change-Id: I5f0a7f5ac2ece04d6fe6e9c5a28ea2a0dda38955
In this commit:
commit 5024637fac
Date: Sun Dec 15 11:05:47 2019 +0100
Fix skip.exp test failure observed with gcc-9.2.0
A race condition was introduced into the gdb.base/skip.exp test when
this line:
gdb_test "step" "foo \\(\\) at.*" "step 3"
Was changed to this:
gdb_test "step" "foo \\(\\) at.*" "step 3" "main \\(\\) at .*" "step"
Before the above change we expected GDB to behave like this:
(gdb) step
foo () at /path/to/gdb/testsuite/gdb.base/skip.c:42
42 return 0;
(gdb)
However, when the test is compiled with GCC 9.2.0 we get a different
behaviour, and so we need a second 'step', like this:
(gdb) step
main () at /path/to/gdb.base/skip.c:32
32 x = baz ((bar (), foo ()));
(gdb) step
foo () at /path/to/gdb/testsuite/gdb.base/skip.c:42
42 return 0;
(gdb)
Now the change to the test matches against 'main () at .*', however if
GDB or expect is being slow then we might only get to see output like
this:
(gdb) step
main () at /path/to/g
This will happily match the question pattern, so we send 'step' to GDB
again. Now GDB continues to produce output which expect accepts, we
now see this:
b.base/skip.c:32
32 x = baz ((bar (), foo ()));
(gdb)
This has carried on from where the previous block of output left off.
This doesn't match the final pattern 'foo \\(\\) at.*', but it does
match the prompt pattern that gdb_test_multiple adds, and so we report
the test as failing.
The solution is to simply ensure that the question consumes everything
up to, and including the prompt. This ensures that the prompt can't
then match the failure case. The new test line becomes:
gdb_test "step" "foo \\(\\) at.*" "step 3" \
"main \\(\\) at .*\r\n$gdb_prompt " "step"
gdb/testsuite/ChangeLog:
* gdb.base/skip.exp: Fix race condition in test.
Change-Id: I9f0b0b52ef1b4f980bfaa8fe405ff06d520f3482
Recent MinGW versions require -lssp when using _FORTIFY_SOURCE, which
gdb does (in common-defs.h)
https://github.com/msys2/MINGW-packages/issues/5868#issuecomment-544107564
To avoid all the complications with checking for -lssp and making sure it's
linked statically, just don't define it.
gdb/ChangeLog:
2020-01-09 Christian Biesinger <cbiesinger@google.com>
* gdbsupport/common-defs.h: Don't define _FORTIFY_SOURCE on MinGW.
Change-Id: Ide6870ab57198219a2ef78bc675768a789ca2b1d
The body of this this big "for" loop is missing an indentation level,
this patch fixes that.
gdb/ChangeLog:
* thread.c (print_thread_info_1): Fix indentation.
compute_and_set_names would only free the name if we did not find the name
in the hashtable, but it needs to always free it. Solve this by moving the
smart pointer outside the if.
Thanks to PhilippeW for finding this.
gdb/ChangeLog:
2020-01-09 Christian Biesinger <cbiesinger@google.com>
* symtab.c (general_symbol_info::compute_and_set_names): Move the
unique_xmalloc_ptr outside the if to always free the demangled name.
Change-Id: Id7c6b8408432183700ccb5ff634818d6c5a3ac95
PR 25220
* objcopy.c (empty_name): New variable.
(need_sym_before): Prevent an attempt to free a static variable.
(filter_symbols): Avoid strcmp test by checking for pointer
equality.
debuginfod is a lightweight web service that indexes ELF/DWARF
debugging resources by build-id and serves them over HTTP. This patch
enables objdump and readelf to query debuginfod servers when they are
otherwise not able to find separate debug files. Binutils can be built
with debuginfod using the --with-debuginfod configure option. This
requires that libdebuginfod be installed and found at configure time.
debuginfod is packaged with elfutils, starting with version 0.178. For
more information see https://sourceware.org/elfutils/.
toplevel* config/debuginfod.m4: New file. Add macro AC_DEBUGINFOD. Adds
new configure option --with-debuginfod.
* configure: Regenerate.
* configure.ac: Call AC_DEBUGINFOD.
binutils* Makefile.am (readelf_LDADD, objdump_LDADD): Add libdebuginfod.
* Makefile.in: Regenerate.
* NEWS: Update.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Call AC_DEBUGINFOD.
* doc/Makefile.in: Regenerate.
* doc/binutils.texi: Add section on using binutils
with debuginfod.
* dwarf.c (debuginfod_fetch_separate_debug_info): New function.
Query debuginfod servers for the target debug file.
(load_separate_debug_info): Call
debuginfod_fetch_separate_debug_info if configured with
debuginfod.
(load_separate_debug_files): Add file argument to
load_separate_debug_info calls.
* dwarf.h (get_build_id): Add declaration.
* objdump.c (get_build_id): New function. Get build-id of file.
* readelf.c (get_build_id): Likewise.
* testsuite/binutils-all/debuginfod.exp: New tests.
* testsuite/binutils-all/linkdebug.s: Add .note.gnu.build-id
section.
Checking just the base opcode without also checking this isn't a VEX
encoding, and without there being other insn properties avoiding a match
once respective VEX/XOP/EXEX-encoded insns would appear, is at least
dangerous. Add respective checks. At the same time there's no real need
to check the extension opcode to be None for the 0xA8 form - there's
nothing it can be confused with, and non-VEX-and-alike forms also can't
appear.
Commit ac0ab1842d ("i386: Also check R12-R15 registers when optimizing
testq to testb") didn't go quite far enough: In order to avoid confusing
other code registers would better be converted to byte ones uniformly.
The disassembler change is such that in default mode we'd disassemble
the insns (for there not ebing any conflicts), but when AMD64 mode was
explicitly requested, we'd show them as "(bad)".
This replaces two instances of manual string management in
dwarf2read.c with std::string.
gdb/ChangeLog
2020-01-08 Tom Tromey <tromey@adacore.com>
* dwarf2read.c (parse_macro_definition): Use std::string.
(parse_macro_definition): Likewise.
Change-Id: Iec437100105484aa4a116fb5d651d7ed52ee9d81
This removes some manual memory management from
abbrev_table_read_table, replacing it with a std::vector.
gdb/ChangeLog
2020-01-08 Tom Tromey <tromey@adacore.com>
* dwarf2read.c (abbrev_table_read_table): Use std::vector.
(ATTR_ALLOC_CHUNK): Remove.
Change-Id: I0b0e70ac2281d89a78f4d6a642700c9f0506871d
This changes fixup_go_packaging to use unique_xmalloc_ptr. I kept
this patch separate as it is slightly more complicated than the
previous changes.
gdb/ChangeLog
2020-01-08 Tom Tromey <tromey@adacore.com>
* dwarf2read.c (fixup_go_packaging): Use unique_xmalloc_ptr.
Change-Id: I0c553d0c6579db478c27bc40fc21133a61e1a4d9
I noticed a few spots in dwarf2read.c that could be improved by moving
to unique_xmalloc_ptr or, in one case, std::vector.
gdb/ChangeLog
2020-01-08 Tom Tromey <tromey@adacore.com>
* dwarf2read.c (add_partial_symbol): Use unique_xmalloc_ptr.
(dwarf2_compute_name, open_dwo_file): Likewise.
(process_enumeration_scope): Use std::vector.
(guess_partial_die_structure_name): Use unique_xmalloc_ptr.
(partial_die_info::fixup, dwarf2_start_subfile)
(guess_full_die_structure_name, dwarf2_name): Likewise.
(determine_prefix): Update.
(guess_full_die_structure_name): Make return type const.
(partial_die_full_name): Return unique_xmalloc_ptr.
(DW_FIELD_ALLOC_CHUNK): Remove.
Change-Id: I1cb278c608041ef36ef1f77c7e7565c921038d08
PR 14891
* config/obj-elf.c (obj_elf_section): Fail if the section name is
already defined as a different symbol type.
* testsuite/gas/elf/pr14891.s: New test source file.
* testsuite/gas/elf/pr14891.d: New test driver.
* testsuite/gas/elf/pr14891.s: New test expected error output.
* testsuite/gas/elf/elf.exp: Run the new test.
The fix is the additional ARRAY_SIZE test, the rest just tidies
variable types rather than adding a cast to avoid warnings.
opcodes/
* z8k-dis.c: Include libiberty.h
(instr_data_s): Make max_fetched unsigned.
(z8k_lookup_instr): Make nibl_index and tabl_index unsigned.
Don't exceed byte_info bounds.
(output_instr): Make num_bytes unsigned.
(unpack_instr): Likewise for nibl_count and loop.
* z8kgen.c (gas <opcode_entry_type>): Make noperands, length and
idx unsigned.
* z8k-opc.h: Regenerate.
gas/
* config/tc-z8k.c (md_begin): Make idx unsigned.
(get_specific): Likewise for this_index.
PR build/24937 concerns an error given by the clang provided by a
particular version of macOS. In particular, it reports
error: default initialization of an object of const type 'const
stap_static_probe_ops' without a user-provided default constructor
Although (at least according to sources I found online) this was
resolved as a bug in the standard, it seemed simple enough to work
around this.
Given that this is a trivial build fix, I think it should go on the
gdb 9 branch as well.
gdb/ChangeLog
2020-01-07 Tom Tromey <tromey@adacore.com>
PR build/24937:
* stap-probe.c (class stap_static_probe_ops): Add constructor.
Change-Id: I18f180c17850f420e9b66afc67f9cb3d8dceb0b3
Cygwin meets the expectations of gdb for styling (if TERM is set and not
'DUMB', the terminal supports 'ANSI' (ECMA-48) escape sequences.
gdb/ChangeLog:
2020-01-02 Jon Turney <jon.turney@dronecode.org.uk>
* cli/cli-style.c: Set cli_styling to 'true' in the Cygwin build.
We use gas' expression function to parse the operands of an
instruction in a generic way. There are situations when we have labels
and registers having the same name as well as the substraction sign
doesn't always stands for the arithmetical operation but for the
register range (e.g. enter instruction). This patch improves parsing
symbols found in a instruction operand, cleans up code and avoids
using default or undefined variables.
gas/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* config/tc-arc.c (parse_reloc_symbol): New function.
(tokenize_arguments): Clean up, use parse_reloc_symbol function.
(md_operand): Set X_md to absent.
(arc_parse_name): Check for X_md.
This patch changes the "class" of LLOCK/SCOND from "MEMORY" to
"LLOCK/SCOND" respectively. Moreover, it corrects the "data_size_mode".
These changes are necessary for GDB's atmoic sequence handler.
Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
In this commit:
commit ec8e2b6d30
Date: Fri Jun 14 23:43:00 2019 +0100
gdb: Don't allow annotations to influence what else GDB prints
A change was accidentally made that moved a call to do_gdb_disassembly
out of an if block guarded by 'if (source_print && sal.symtab)'. The
result was that if a user has 'set disassemble-next-line on' then the
backtrace would now include some disassembly of a few instructions in
each frame.
This change was not intentional, but was not spotted by any tests.
This commit restores the old behaviour and adds a test to ensure this
doesn't break again in the future.
gdb/ChangeLog:
* stack.c (print_frame_info): Move disassemble_next_line code
inside source_print block.
gdb/testsuite/ChangeLog:
* gdb.base/backtrace.c: New file.
* gdb.base/backtrace.exp: New file.
Change-Id: I47c52a202fa74be138382646b695827940178689
gdb/ChangeLog
2020-01-06 Eli Zaretskii <eliz@gnu.org>
* gdbsupport/gdb_wait.c: Include <signal.h> instead of
gdb/signals.h, as we are now using native signal symbols.
In tui_disasm_window::addr_is_displayed(), there can be situations
where "content" is empty. For instance, it can happen when the
"content" was not filled in tui_disasm_window::set_contents(),
because tui_disassemble() threw an exception. Usually this exception
is the result of fetching invalid PC addresses like the ones beyond
the end of the program.
Having "content.size ()" zero leads to an overflow in this condition
check inside tui_disasm_window::addr_is_displayed():
int i = 0;
while (i < content.size () - threshold ...) {
... content[i] ...
}
"threshold" is 2 and there are times that "content.size ()" is 0.
This results into an overflow and the loop is entered whereas it
should have been skipped. Finally, "content[i]" access leads to
a segmentation fault.
Same problem applies to tui_source_window::line_is_displayed().
The issue has been discussed at length in bug 25345:
https://sourceware.org/bugzilla/show_bug.cgi?id=25345
This commit avoids the segmentation faults with an early check:
if (content.size () < SCROLL_THRESHOLD)
return false;
Moreover, those functions have been overhauled to a leaner code.
gdb/ChangeLog:
2020-01-06 Shahab Vahedi <shahab@synopsys.com>
* tui/tui-disasm.c (tui_disasm_window::addr_is_displayed): Avoid
overflow by an early check of content vs threshold.
* tui/tui-source.c (tui_source_window::line_is_displayed):
Likewise.
Don't try to read the PE export table when no section contains the RVA
for it.
(I have a PE executable [1] packed with UPX, where the export table data
directory entry contains a RVA which doesn't correspond to any section.
Mistakenly trying to debug this with gdb makes it crash.)
[1] https://cygwin.com/setup/setup-2.898.x86_64.exe
gdb/ChangeLog:
2020-01-02 Jon Turney <jon.turney@dronecode.org.uk>
* coff-pe-read.c (read_pe_exported_syms): Don't try to read the
export table if no section contains it's RVA.