I noticed that USE_WIN32API is defined separately by gdbserver and
gdb. However, because it is used by code in gdbsupport, it should be
defined by common.m4. This approach ensures that the code will
continue to work when it is moved to the top level.
gdb/ChangeLog
2020-01-14 Tom Tromey <tom@tromey.com>
* gdbsupport/common.m4 (GDB_AC_COMMON): Define WIN32APILIBS and
USE_WIN32API when needed.
* configure.ac (USE_WIN32API): Don't define.
(WIN32LIBS): Use WIN32APILIBS.
* configure: Rebuild.
gdb/gdbserver/ChangeLog
2020-01-14 Tom Tromey <tom@tromey.com>
* configure.ac (LIBS): Use WIN32APILIBS.
(USE_WIN32API): Don't define.
* configure: Rebuild.
Change-Id: I40d524d5445ebfb452b36f4d0e102f0b1e1089df
Simon pointed out that the indentation in common.m4 is off. This
patch fixes the problem.
gdb/ChangeLog
2020-01-14 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* gdbsupport/common.m4 (GDB_AC_COMMON): Fix indentation.
gdb/gdbserver/ChangeLog
2020-01-14 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
Change-Id: I6a629bd5873cca95ba3e17656f0d0ce583a08361
Previously always the outermost function block was used, but
since skip is now able to skip over inline functions it is more
natural to skip the inline function that the program is currently
executing.
gdb:
2020-01-14 Bernd Edlinger <bernd.edlinger@hotmail.de>
* skip.c (skip_function_command): Make skip w/o arguments use the
name of the inlined function if pc is inside any inlined function.
gdb/testsuite:
2020-01-14 Bernd Edlinger <bernd.edlinger@hotmail.de>
* gdb.base/skip-inline.exp: Extend test.
While doing some investigation of mine, i noticed a few typos,
inaccuracies and missing information.
I went ahead and updated/improved those.
gdb/ChangeLog:
2020-01-14 Luis Machado <luis.machado@linaro.org>
* inf-ptrace.c (inf_ptrace_target::resume): Update comments.
* infrun.c (resume_1): Likewise.
(handle_inferior_event): Remove stale comment.
* linux-nat.c (linux_nat_target::resume): Update comments.
(save_stop_reason): Likewise.
(linux_nat_filter_event): Likewise.
* linux-nat.h (struct lwp_info) <stop_pc>, <stop_reason>: Likewise.
PR 25377
gas * config/tc-z80.c: Add support for half precision, single
precision and double precision floating point values.
* config/tc-z80.h b/gas/config/tc-z80.h: Disable string escapes.
* doc/as.texi: Add new z80 command line options.
* doc/c-z80.texi: Document new z80 command line options.
* testsuite/gas/z80/ez80_pref_dis.s: New test.
* testsuite/gas/z80/ez80_pref_dis.d: New test driver.
* testsuite/gas/z80/z80.exp: Run the new test.
* testsuite/gas/z80/fp_math48.d: Use correct command line option.
* testsuite/gas/z80/fp_zeda32.d: Likewise.
* testsuite/gas/z80/strings.d: Update expected output.
opcodes * z80-dis.c (suffix): Use .db instruction to generate double
prefix.
I thought the fuzzers were really going overboard by defining
VMS_DEBUG but that wasn't the case. VMS_DEBUG is defined by
default. Let's not do that, and fix the segv as well.
* vms.h (VMS_DEBUG): Define as 0.
* vms-alpha.c (image_write): Move debug output after bounds check.
Tidy bounds check.
(_bfd_vms_slurp_eihd): Warning fix.
(_bfd_vms_slurp_etir): Init variables to avoid bogus warnings.
I ended up debugging a malformed ELF where a section containing
executable code was not correctly marked as allocatable. Before
realising the ELF was corrupted I tried to place a breakpoint on a
symbol in the non-allocatable, executable section, and GDB crashed.
Though trying to debug such an ELF clearly isn't going to go well I
would prefer, as far as possible, that any input, no matter how
corrupted, not crash GDB.
The crash occurs when trying to set a breakpoint on the name of a
function from the corrupted section. GDB converts the symbol to a
symtab_and_line, and looks up a suitable section for this.
The problem is that the section is actually an obj_section, which is
stored in the table within the objfile, and we only initialise this
table for allocatable sections (see add_to_objfile_sections_full in
objfiles.c). So, if the symbol is in a non-allocatable section then
we end up referencing an uninitialised obj_section.
Later we call get_sal_arch on the symtab_and_line, which calls
get_objfile_arch, which uses the objfile from the uninitialised
obj_section, which will be nullptr, at which point GDB crashes.
The fix I propose here is that when we setup the section references on
msymbols, we should check if the bfd_section being referenced is
allocatable or not. If it is not then we should set the section
reference back to the default 0 section (see how MSYMBOL_OBJ_SECTION
and SYMBOL_OBJ_SECTION treat the 0 section index).
With this fix in place GDB no longer crashes. Instead GDB creates the
breakpoint at the non-allocated address, and then fails, with an
error, when it tries to insert the breakpoint.
gdb/ChangeLog:
* elfread.c (record_minimal_symbol): Set section index to 0 for
non-allocatable sections.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-bad-elf-other.S: New file.
* gdb.dwarf2/dw2-bad-elf.c: New file.
* gdb.dwarf2/dw2-bad-elf.exp: New file.
Change-Id: Ie05436ab4c6a71440304d20ee639dfb021223f8b
Fixes a bug in the DWARF assembler that prevents multiple line tables
from being created in a test. We currently don't initialise a couple
of flags, as a result we will only ever generate one end of file list,
and one end of header, in the first line table. Any additional line
tables will be missing these parts, and will therefore be corrupt.
This fix will be required for a later commit. There should be no
change in the testsuite after this commit.
gdb/testsuite/ChangeLog:
* lib/dwarf.exp (Dwarf::lines): Reset _line_saw_program and
_line_saw_file.
Change-Id: Id7123f217a036f26ee32d608db3064dd43164596
* Process debug_str_offsets section. Handle DW_AT_str_offsets_base attribute and
keep the value in dwarf2_cu.
* Make addr_base field in dwarf2_cu optional to disambiguate 0 value
(absent or present and 0).
* During parsing, there is no guarantee that DW_AT_str_offsets_base and
DW_AT_rnglists_base fields will be processed before the attributes that need
those values for correct computation. So make two passes, on the first one mark
the attributes that depend on *_base attributes and process only the others.
On the second pass, only process the attributes that are marked on the first
pass.
* For string attributes, differentiate between addresses that directly point to
a string and those that point to an offset in debug_str_offsets section.
* There are now two attributes, DW_AT_addr_base and DW_AT_GNU_addr_base to read
address offset base. Likewise, there are two attributes, DW_AT_rnglists_base
and DW_AT_GNU_ranges_base to read ranges base. Since there is no guarantee which
ones the compiler will generate, create helper functions to handle all cases.
Tested with CC=/usr/bin/gcc (version 8.3.0) against master branch (also with
-gsplit-dwarf and -gdwarf-4 flags) and there was no increase in the set of
tests that fails. (gdb still cannot debug a 'hello world' program with DWARF 5,
so for the time being, this is all we care about).
This is part of an effort to support DWARF-5 in gdb.
Since the data held by the `contents` variable is arbitrary binary data,
it should have gdb_byte elements, not char elements. Also, using
gdb::byte_vector is preferable, since it doesn't unnecessarily
zero-initialize the values.
Instead of adding a cast in the call to m_core_vec->core_read_registers,
I have changed core_read_registers' argument to be a gdb_byte* instead
of a char*.
gdb/ChangeLog:
* gdbcore.h (struct core_fns) <core_read_registers>: Change
core_reg_sect type to gdb_byte *.
* arm-nbsd-nat.c (fetch_elfcore_registers): Likewise.
* cris-tdep.c (fetch_core_registers): Likewise.
* corelow.c (core_target::get_core_register_section): Change
type of `contents` to gdb::byte_vector.
In tui-wingeneral.c:box_win () a comment suggest we should display
titles like this:
+-WINDOW TITLE GOES HERE-+
However, we actually display them like this:
+--WINDOW TITLE GOES HERE+
The former seems nicer to me, so that's what this commit does. Short
titles will appear as:
+-SHORT TITLE------------+
We previously didn't test the horizontal windows borders in the test
suite, however, I've updated things so that we do now check for the
'+-' and '-+' on the upper border, this will give us some protection.
gdb/ChangeLog:
* tui/tui-wingeneral.c (box_win): Position the title in the center
of the border.
gdb/testsuite/ChangeLog:
* lib/tuiterm.exp (Term::_check_box): Check some parts of the top
border.
Change-Id: Iead6910e3b4e68bdf6871f861f23d2efd699faf0
As I was trying to compile gdb for an m68k host, I got this error:
CXX corelow.o
In file included from /binutils-gdb/gdb/gdbsupport/common-defs.h:120,
from /binutils-gdb/gdb/defs.h:28,
from /binutils-gdb/gdb/corelow.c:20:
/binutils-gdb/gdb/corelow.c: In member function 'void core_target::get_core_register_section(regcache*, const regset*, const char*, int, int, const char*, bool)':
/binutils-gdb/gdb/../include/libiberty.h:727:36: error: 'alloca' bound is unknown [-Werror=alloca-larger-than=]
727 | # define alloca(x) __builtin_alloca(x)
| ~~~~~~~~~~~~~~~~^~~
/binutils-gdb/gdb/corelow.c:625:23: note: in expansion of macro 'alloca'
625 | contents = (char *) alloca (size);
| ^~~~~~
We are using alloca to hold the contents of a the core register
sections. These sections are typically fairly small, but there is no
realy guarantee, so I think it would be more reasonable to just use
dynamic allocation here.
gdb/ChangeLog:
* corelow.c (core_target::get_core_register_section): Use
std::vector instead of alloca.
The dat files in regformats/i386 were removed a while ago, this rule is
no longer necessary.
gdb/gdbserver/ChangeLog:
* Makefile.in (%-generated.c): Remove rule for files from
regformats/i386.
Now that most warnings of this kind are fixed, we can enable
-Wmissing-declarations. I say "most", because it is likely that there
are some more in some configurations I am not able to build, but they
should be pretty easy to fix.
gdb/ChangeLog:
* warning.m4: Add -Wmissing-declarations to build_warnings.
* configure: Re-generate.
gdb/gdbserver/ChangeLog:
* configure: Re-generate.
Change-Id: Iae9b59f22eb5dd1965d09f34c5c9e212cddf67ba
Fixing the -Wmissing-declarations errors in gdbserver's tracepoint.c is
a bit tricky, because some functions are compiled for both gdbserver, in
which case they should be static, since they are only used in that file,
and for libinproctrace.so, in which case they should be externally
visible, since they need to be looked up. In the case where they are
externally visible, -Wmissing-declarations requires that a declaration
exists (that's the point of the warning).
I've reused the IP_AGENT_EXPORT_FUNC macro to mark the functions as
static when compiled for gdbserver. Some seemingly unnecessary
declarations are added for when compiling libinproctrace.so (thanks to
Tom for the suggestion).
gdb/gdbserver/ChangeLog:
* tracepoint.h (IP_AGENT_EXPORT_FUNC) [!IN_PROCESS_AGENT]:
Define to static.
* tracepoint.c (stop_tracing, flush_trace_buffer,
about_to_request_buffer_space, get_trace_state_variable_value,
set_trace_state_variable_value, gdb_collect): Add declaration.
Change-Id: If9c66151bd00c3b9c5caa27a7c21c5a3a952de2a
These functions are only used in this file, so should be static.
gdb/gdbserver/ChangeLog:
* linux-x86-low.c (x86_linux_regs_info, amd64_emit_eq_goto,
amd64_emit_ne_goto, amd64_emit_lt_goto, amd64_emit_le_goto,
amd64_emit_gt_goto, amd64_emit_ge_goto, amd64_emit_ge_goto,
i386_emit_eq_goto, i386_emit_ne_goto, i386_emit_lt_goto,
i386_emit_le_goto, i386_emit_gt_goto, i386_emit_ge_goto): Make
static.
Change-Id: I703da41867735aefadd49140e80cd60f6ab9ad39
So that the definitions of get_inferior_cwd/set_inferior_cwd see their
declarations.
CXX inferiors.o
/home/smarchi/src/binutils-gdb/gdb/gdbserver/inferiors.c: In function ‘const char* get_inferior_cwd()’:
/home/smarchi/src/binutils-gdb/gdb/gdbserver/inferiors.c:228:1: error: no previous declaration for ‘const char* get_inferior_cwd()’ [-Werror=missing-declarations]
get_inferior_cwd ()
^~~~~~~~~~~~~~~~
/home/smarchi/src/binutils-gdb/gdb/gdbserver/inferiors.c: In function ‘void set_inferior_cwd(const char*)’:
/home/smarchi/src/binutils-gdb/gdb/gdbserver/inferiors.c:236:1: error: no previous declaration for ‘void set_inferior_cwd(const char*)’ [-Werror=missing-declarations]
set_inferior_cwd (const char *cwd)
^~~~~~~~~~~~~~~~
gdb/gdbserver/ChangeLog:
* inferiors.c: Include gdbsupport/common-inferior.h.
Change-Id: Iae5ccb3e1dc37ce79f03f08465f603a0411e7af0
... so that the definition of hostio_last_error_from_errno in hostio-errno.c
sees the declaration in hostio.h.
Fix this error:
CXX hostio-errno.o
/home/smarchi/src/binutils-gdb/gdb/gdbserver/hostio-errno.c: In function ‘void hostio_last_error_from_errno(char*)’:
/home/smarchi/src/binutils-gdb/gdb/gdbserver/hostio-errno.c:28:1: error: no previous declaration for ‘void hostio_last_error_from_errno(char*)’ [-Werror=missing-declarations]
hostio_last_error_from_errno (char *buf)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
gdb/gdbserver/ChangeLog:
* hostio-errno.c: Include hostio.h.
Change-Id: I056308fd4ce12810d0a1b826c423bd0c7eeb8944
When I try to enable -Wmissing-declarations, I get this error:
CXX python/python.o
/home/smarchi/src/binutils-gdb/gdb/python/python.c: In function ‘PyObject* init__gdb_module()’:
/home/smarchi/src/binutils-gdb/gdb/python/python.c:1582:1: error: no previous declaration for ‘PyObject* init__gdb_module()’ [-Werror=missing-declarations]
init__gdb_module (void)
^~~~~~~~~~~~~~~~
Prevent it by providing a declaration just before the definition.
gdb/ChangeLog:
* python/python.c (init__gdb_module): Add declaration.
Change-Id: I394bc691b7db624708cc4cb2cda28a56ab85a82b
When compiling gdbserver for an architecture that uses the regdat.sh
script (such as m68k) and the -Wmissing-declarations compiler flag, I
get:
REGDAT reg-m68k-generated.c
CXX reg-m68k.o
reg-m68k-generated.c:30:1: error: no previous declaration for 'void init_registers_m68k()' [-Werror=missing-declarations]
30 | init_registers_m68k (void)
| ^~~~~~~~~~~~~~~~~~~
The same happens with other architectures, such as s390, but I'll be
using 68k as an example.
The init_registers_m68k function is defined in reg-m68k-generated.c,
which is produced by the regformats/regdat.sh script. This script reads
the regformats/reg-m68k.dat file, containing a register description, and
produces C code that creates a corresponding target description at
runtime.
The init_registers_m68k function is invoked at initialization time in
linux-m68k-low.c. The function must therefore be non-static, but does
not have a declaration at the moment.
The real clean way of fixing this would be to make regdat.sh generate a
.h file (in addition to the .c file) with declarations for whatever is
in the .c file. The generated .c file would include the .h file, and
therefore the definition would have a corresponding declaration. The
linux-m68k-low.c file would also include this .h file, instead of having
its own declaration of init_registers_m68k, like it does now.
However, this would be a quite big change for not much gain. As far as
I understand, some common architectures (i386, x86-64, ARM, AArch64)
have been moved to dynamically building target descriptions based on
features (the linux-*-tdesc.c files in gdbserver) and don't use
regdat.sh anymore. Logically (and given infinite development
resources), the other architectures would be migrated to this system too
and the regdat.sh script would be dropped. A new architecture would
probably not use regdat.sh either. So I therefore propose this simpler
patch instead, which just adds a local declaration in the generated
file.
gdb/ChangeLog:
* regformats/regdat.sh: Generate declaration for init function.
The intent of the rules modified by this patch is that the *-generated.c
files generated by regdat.sh are re-generated in the event that
regdat.sh is modified. However, if I build, touch regdat.sh, and build
again, the files are not re-generated during the second build.
This is because regdat.sh is specified as an order-only dependency [1],
after the pipe. Make therefore only ensures that regdat.sh exists
before generating the target file, it doesn't check the timestamp of
regdat.sh.
This patch changes it to be a regular prerequisite.
The rules use the $< variable, which is substituted by the first
prerequisite only, so the command lines won't change.
[1] https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html
gdb/gdbserver/ChangeLog:
* Makefile.in (%-generated.c): Make $(regdat_sh) a regular
prerequisite.
The remote-sim.c file doesn't build since the main multi-target patch
(5b6d1e4f, "Multi-target support"), this patch is an attempt to fix it.
I have only build-tested it, so I'm not sure it runs fine, but it should
get us close at least.
I made these functions methods of the gdbsim_target, because they need
to pass the target down to some GDB core functions, like
find_inferior_ptid:
- get_sim_inferior_data_by_ptid (renamed to get_inferior_data_by_ptid)
- gdbsim_resume_inferior (renamed to resume_one_inferior)
- gdbsim_close_inferior (renamed to close_one_inferior)
In the last two, I changed iterate_over_inferiors to a range-based for,
since that gives simpler code (no need to pass data through the void
pointer).
The next_pid variable, INITIAL_PID macro and sim_inferior_data structure
are simply moved up in the file, above gdbsim_target.
gdb/ChangeLog:
* remote-sim.c (next_pid, INITIAL_PID, sim_inferior_data): Move
up.
(gdbsim_target) <get_inferior_data_by_ptid, resume_one_inferior,
close_one_inferior>: New methods.
(get_sim_inferior_data_by_ptid): Move to gdbsim_target,
pass down target to find_inferior_pid.
(gdbsim_target::fetch_registers, gdbsim_target::store_registers):
Pass down target to find_inferior_ptid.
(gdbsim_target::create_inferior): Pass down target to
add_thread_silent.
(gdbsim_close_inferior): Move to gdbsim_close_inferior, pass
target down to find_inferior_ptid and switch_to_thread.
(gdbsim_target::close): Update to call close_one_inferior.
(struct resume_data): Remove.
(gdbsim_resume_inferior): Move to gdbsim_target. Take arguments
directly, rather than through a void pointer.
(gdbsim_target::resume): Update to call resume_one_inferior.
There are no instructions under these matrix multiply extensions that
can be used without having SVE enabled.
Since these extensions require SVE, we make that explicit in the options
table.
Tested on aarch64-none-elf without regressions.
gas/ChangeLog:
2020-01-13 Matthew Malcomson <matthew.malcomson@arm.com>
* config/tc-aarch64.c (f64mm, f32mm): Add sve as a feature
dependency.
binutils* objdump.c (visualize_jumps, color_output, extended_color_output)
(detected_jumps): New variables.
(usage): Add the new jump visualization options.
(option_values): Add new option value.
(long_options): Add the new option.
(jump_info_new, jump_info_free): New functions.
(jump_info_min_address, jump_info_max_address): Likewise.
(jump_info_end_address, jump_info_is_start_address): Likewise.
(jump_info_is_end_address, jump_info_size): Likewise.
(jump_info_unlink, jump_info_insert): Likewise.
(jump_info_add_front, jump_info_move_linked): Likewise.
(jump_info_intersect, jump_info_merge): Likewise.
(jump_info_sort, jump_info_visualize_address): Likewise.
(disassemble_jumps): New function - used to locate jumps.
(disassemble_bytes): Add ascii art generation.
(disassemble_section): Add scan to locate jumps.
(main): Parse the new visualization option.
* doc/binutils.texi: Document the new feature.
* NEWS: Mention the new feature.
opcodes * arm-dis.c (print_insn_arm): Fill in insn info fields for control
flow instructions.
(print_insn_thumb16, print_insn_thumb32): Likewise.
(print_insn): Initialize the insn info.
* i386-dis.c (print_insn): Initialize the insn info fields, and
detect jumps.
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* elfarcv2.sc : Allow interrupt vector table to be located at an
arbitrary address. Use DWARF.sc file.
* elfarc.sc: Use DWARF.sc file.
ACCL/ACCH register names are only available for ARCv2 architecture,
leading to a confusion when disassembling for any other ARC
variants. This patch is changing the default names for ACCL/ACCH to
generic r58/r59.
2012-01-13 Claudiu Zissulescu <claziss@gmail.com>
* opcode/arc-dis.c (regnames): Correct ACCL/ACCH naming, fix typo
reserved register name.
index_offset isn't set up for "sfsr", resulting in a random offset
being used when trying to disassemble the following.
.byte 0x3e, 0xf7, 0x07, 0x00
* ns32k-dis.c (Is_gen): Use strchr, add 'f'.
(print_insn_ns32k): Adjust ioffset for 'f' index_offset.
The signed integer overflow occurred when adding one to target_count
for (i = 0; i < target_count + 1; i++)
but that's the least of the worries here. target_count was long and i
int, leading to the possibility of a loop that never ended.
So to avoid this type of vulnerability, this patch uses what I believe
to be the proper types for arguments of various wasm32 opcodes, rather
than using "long" which may change in size.
gas/
* testsuite/gas/wasm32/allinsn.d: Update expected output.
opcodes/
* wasm32-dis.c (print_insn_wasm32): Localise variables. Store
result of wasm_read_leb128 in a uint64_t and check that bits
are not lost when copying to other locals. Use uint32_t for
most locals. Use PRId64 when printing int64_t.
It's always a bad idea to perform arithmetic on an unknown value read
from an object file before comparing against bounds. Code like the
following attempting to bounds check "len", a 64-bit value, isn't
effective because the pointer arithmetic ignores the high 32 bits when
compiled for a 32-bit host.
READ_LEB128 (len, p, end);
if (p + len < p || p + len > end)
goto error_return;
Instead, perform any arithmetic on known values where we don't need to
worry about overflows:
READ_LEB128 (len, p, end);
if (len > (size_t) (end - p))
goto error_return;
I'll note that this check does do things the right way:
READ_LEB128 (symcount, p, end);
/* Sanity check: each symbol has at least two bytes. */
if (symcount > payload_size / 2)
return FALSE;
"symcount * 2 > payload_size" would be wrong since the multiply could
overflow.
* wasm-module.c (wasm_scan_name_function_section): Formatting.
Delete asect name check. Move asect NULL check to wasm_object_p.
Correct bounds check of sizes against end. Replace uses of
bfd_zalloc with bfd_alloc, zeroing only necessary bytes. Use
just one bfd_release.
(wasm_scan): Don't use malloc/strdup for section names,
bfd_alloc instead. Simplify code prefixing section name.
Formatting. Don't attempt to free memory here..
(wasm_object_p): ..do so here. Formatting.
Don't do that. Especially don't use shift counts that assume the type
being shifted is 32 bits when the type is long/unsigned long. Also
reverts part of a change I made on 2019-12-11 to tic4x_print_register
that on closer inspection turns out to be unnecessary.
include/
* opcode/tic4x.h (EXTR): Delete.
(EXTRU, EXTRS, INSERTU, INSERTS): Rewrite without zero/sign
extension using shifts. Do trim INSERTU value to specified bitfield.
opcodes/
* tic4x-dis.c (tic4x_print_register): Remove dead code.
gas/
* config/tc-tic4x.c (tic4x_operands_match): Correct tic3x trap
insertion.