If all sections of a symbol file are loaded with a fixed offset, it
is easier to specify that offset than listing all sections
explicitly. There is also a similar option for "symbol-file".
gdb/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* symfile.c (add_symbol_file_command, _initialize_symfile): Add
option "-o" to add-symbol-file-load to add an offset to each
section's load address.
* symfile.c (set_objfile_default_section_offset): New function.
gdb/doc/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* gdb.texinfo (Files): Document "add-symbol-file -o offset".
gdb/testsuite/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* gdb.base/relocate.exp: Add test for "add-symbol-file -o ".
Symbol files may contain multiple sections with the same name.
Section addresses specified by add-symbol-file are assigned to the
corresponding BFD sections in addr_info_make_relative using sorted
indexes of both vectors. Since the sort algorithm is not inherently
stable, the comparison function uses sectindex to maintain the
original order. However, add_symbol_file_command uses zero for all
sections, so if the user specifies multiple sections with the same
name, they will be assigned randomly to symbol file sections with
the same name.
gdb/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* symfile.c (add_symbol_file_command): Make sure that sections
The (first) .text section must be always specified as the second
non-option argument. The documentation states that GDB cannot
figure out this address by itself. This is true if the object file
was indeed relocated, but it is also confusing, because all other
sections can be omitted and will use the address provided by BFD.
gdb/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* symfile.c (add_symbol_file_command, _initialize_symfile): Do not
require the second argument. If omitted, load sections at the
addresses specified in the file.
gdb/doc/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* gdb.texinfo (Files): The address argument for "add-symbol-file"
is no longer mandatory.
gdb/testsuite/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* gdb.base/relocate.exp: Test add-symbol-file behavior when the
address argument is omitted.
If the main file is relocated at runtime, all symbols are offset by
a fixed amount. Let the user specify this offset when loading a
symbol file.
gdb/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* symfile.c (symbol_file_command, symbol_file_add_main_1)
(_initialize_symfile): Add option "-o" to symbol-file to add an
offset to each section of the symbol file.
gdb/doc/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* gdb.texinfo (Files): Document "symbol-file -o offset".
gdb/testsuite/ChangeLog:
2018-06-28 Petr Tesarik <ptesarik@suse.cz>
* gdb.base/relocate.exp: Add test for "symbol-file -o ".
In my earlier series to change help text to follow the GNU standards
for metasyntactic variables, I missed one: the "func" command. This
patch updates its help text.
Tested by the buildbot.
gdb/ChangeLog
2018-06-27 Tom Tromey <tom@tromey.com>
* stack.c (_initialize_stack): Update "func" help text.
This removes a use of VEC from py-unwind.c, replacing it wit
std::vector. It also changes saved_regs to hold a gdbpy_ref<>,
simplifying the memory management.
Tested against gdb.python on x86-64 Fedora 26.
gdb/ChangeLog
2018-06-27 Tom Tromey <tom@tromey.com>
* python/py-unwind.c (unwind_info_object) <saved_regs>: Now a
std::vector.
(unwind_infopy_str, pyuw_create_unwind_info)
(unwind_infopy_add_saved_register, pyuw_sniffer)
(unwind_infopy_dealloc, unwind_infopy_add_saved_register):
Update.
(struct saved_reg): Add constructor.
<value>: Now a gdbpy_ref<>.
"./gdb ./gdb" was crashing for me on macOS. Investigating showed that
macho_symfile_read was crashing because "symbol_table" was being freed
too soon. This was introduced by my earlier patch to change
macho_symfile_read to use a std::vector.
Tested on macOS 10.13.5 using "./gdb ./gdb". This should un-break
various already existing tests (testsuite/gdb.gdb at least), so no new
test case.
I'm checking this in as obvious.
gdb/ChangeLog
2018-06-27 Tom Tromey <tom@tromey.com>
* machoread.c (macho_symfile_read): Define "symbol_table" earlier.
Add a pretty-printer that prints CORE_ADDR values in hex.
gdb/ChangeLog:
* gdb-gdb.py.in (CoreAddrPrettyPrinter): New class.
(type_lookup_function): Recognize CORE_ADDR values.
Python 3 doesn't use __cmp__ to order objects, it uses __lt__. Because
of this, we get this exception when trying to pretty-print "type"
objects:
I tested it with Python 2.7 as well.
gdb/ChangeLog:
* gdb-gdb.py.in (TypeFlag) <__cmp__>: Remove.
<__lt__>: Add.
I have thought for a long time how nice it would be to have cool pretty
printers for GDB's internal types. Well, turns out there are few
already in gdb-gdb.py! Unfortunately, if you build GDB outside of the
source directory, that file never gets loaded. top-gdb will look for a
file called
../path/to/build/gdb/gdb-gdb.py
but that file is in the source directory at
../path/to/src/gdb/gdb-gdb.py
This patch makes it so we copy it to the build directory, just like we
do for gdb-gdb.gdb. With this, I can at least see the file getting
automatically loaded:
(top-gdb) info pretty-printer
global pretty-printers:
builtin
mpx_bound128
objfile /home/emaisin/build/binutils-gdb/gdb/gdb pretty-printers:
type_lookup_function
I noticed that running "make" didn't re-generate gdb-gdb.py from
gdb-gdb.py.in. That's because it's copied when running the configure
script and that's it. I added a rule in the Makefile for that (and for
gdb-gdb.gdb too) and added them as a dependency to the "all" target.
gdb/ChangeLog:
* gdb-gdb.py: Move to...
* gdb-gdb.py.in: ... here.
* configure.ac (AC_CONFIG_FILES): Add gdb-gdb.py.
* Makefile.in (all): Add gdb-gdb.gdb and gdb-gdb.py as
dependencies.
(distclean): Remove gdb-gdb.py when cleaning.
(gdb-gdb.py, gdb-gdb.gdb): New rules.
* configure: Re-generate.
Commit 00431a78b2 ("Use thread_info and inferior pointers more
throughout") broke Cell multi-arch debugging, because it made the
proc-service routines (ps_lgetregs etc.) access registers using the
SPU architecture if GDB happens to interrupt SPU code. The
proc-service routines must always operate on the "main" (in this case
PowerPC) architecture, because that's the register set libthread_db
expects to be using.
Restore the previous behavior, but wrapped in a new
get_ps_regcache function with a describing comment.
Also, the ps_l*regs routines have an explicit lwpid parameter that
said commit missed; with the commit mentioned above, we started always
reading the registers off of the current thread, which is incorrect.
That is fixed by this commit too.
gdb/ChangeLog:
2018-06-27 Pedro Alves <palves@redhat.com>
* proc-service.c (get_ps_regcache): New.
(ps_lgetregs, ps_lsetregs, ps_lgetfpregs)
(ps_lsetfpregs): Use it.
This patch fixes a unique condition where GDB fails to provide line
information of symbol at address zero when code is compiled with text
address zero but loaded at an offset > 0.
For example lets compile following code snippet:
int main() {
return 0;
}
gcc -O0 -g3 -nostdlib -emain -Wl,-Ttext=0x00 -o file.out file.c
Start gdb and run:
add-symbol-file file.out 0xffff0000
info line main
GDB will return error saying no line info is available for the symbol.
This is a direct consequence of the fix for PR 12528 where GDB tries to ignore
line table for a function which has been garbage collected by the linker.
As the garbage collected symbols are sent to address zero GDB assumes a symbol
actually placed at address zero as garbage collected.
This was fixed with an additional check address < lowpc. But when symbol is
loaded at an offset lowpc becomes lowpc + offset while no offset is added to
address rather final symbol address is calculated based on baseaddr and address
added together. So in case where symbols are loaded at an offset the condition
address < lowpc will always return true.
This patch fixes this by comparing address against a non offset lowpc.
This patch also adds a GDB test case to replicate this behavior.
gdb:
2018-06-27 Omair Javaid <omair.javaid@linaro.org>
PR gdb/21695
* dwarf2read.c (lnp_state_machine::check_line_address): Update declaration.
(dwarf_decode_lines_1): Adjust.
gdb/testsuite:
2018-06-27 Omair Javaid <omair.javaid@linaro.org>
PR gdb/21695
* gdb.base/infoline-reloc-main-from-zero.exp: New test.
* gdb.base/infoline-reloc-main-from-zero.c: New file.
Fix this:
CXX fbsd-nat.o
In file included from fbsd-nat.c:44:
./fbsd-nat.h:40:7: error: 'find_memory_regions' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
int find_memory_regions (find_memory_region_ftype func, void *data);
^
./target.h:702:17: note: overridden virtual function is here
virtual int find_memory_regions (find_memory_region_ftype func, void *data)
^
In file included from fbsd-nat.c:44:
./fbsd-nat.h:42:8: error: 'info_proc' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
bool info_proc (const char *, enum info_proc_what);
^
./target.h:950:18: note: overridden virtual function is here
virtual bool info_proc (const char *, enum info_proc_what);
^
gdb/ChangeLog:
* fbsd-nat.h (class fbsd_nat_target) <find_memory_regions>: Add
override.
<info_proc>: Likewise.
With the update to newer autotools, some gas object files are now
built in config/, breaking xtensa-elf and ia64-vms. This patch fixes
the dependencies.
* configure.ac: Specify extra_objects with leading "config/"
for xtensa-relax.o and te-vms.o. Use case statements to unique
extra_objects. Formatting.
* configure: Regenerate.
This patch is a small reorganizational patch that splits
do_windows_fetch_inferior_registers into two parts:
(a) One part that first reloads the thread's context when needed,
and then decides based on the given register number whether
one register needs to be fetched or all of them.
This part is moved to windows_nat_target::fetch_registers.
(b) The rest of the code, which actually fetches the register value
and supplies it to the regcache.
A similar treatment is applied to do_windows_store_inferior_registers.
This change is preparation work for changing the way we calculate
the location of a given register in the thread context structure,
and should be a no op.
gdb/ChangeLog:
* windows-nat.c (do_windows_fetch_inferior_registers): Rename
to windows_fetch_one_register, and only handle the case of
fetching one register. Move the code that reloads the context
and iterates over all registers if R is negative to...
(windows_nat_target::fetch_registers): ... here.
(do_windows_store_inferior_registers): Rename to
windows_store_one_register, and only handle the case of storing
one register. Move the code that handles the case where r is
negative to...
(windows_nat_target::store_registers) ... here.
Tested on x86-windows and x86_64-windows using AdaCore's testsuite.
This adds support for ptype/o to the Rust language code.
By default, the Rust compiler reorders fields to reduce padding. So,
the Rust language code sorts the fields by offset before printing.
This may yield somewhat odd-looking results, but it is faithful to
"what really happens", and might be useful when doing lower-level
debugging.
The reordering can be disabled using #[repr(c)]; ptype/o might be more
useful in this case.
gdb/ChangeLog
2018-06-26 Tom Tromey <tom@tromey.com>
PR rust/22574:
* typeprint.c (whatis_exp): Allow ptype/o for Rust.
* rust-lang.c (rust_print_struct_def): Add podata parameter.
Update.
(rust_internal_print_type): Add podata parameter.
(rust_print_type): Update.
gdb/testsuite/ChangeLog
2018-06-26 Tom Tromey <tom@tromey.com>
PR rust/22574:
* gdb.rust/simple.exp (test_one_slice): Add ptype/o tests.
* gdb.rust/simple.rs (struct SimpleLayout): New.
This moves the hole-printing support code for ptype/o from
c-typeprint.c to be methods on print_offset_data. This allows the
code to be used from non-C languages.
gdb/ChangeLog
2018-06-26 Tom Tromey <tom@tromey.com>
* typeprint.h (struct print_offset_data) <update, finish,
maybe_print_hole>: New methods.
<indentation>: New constant.
* typeprint.c (print_offset_data::indentation): Define.
(print_offset_data::maybe_print_hole, print_offset_data::update)
(print_offset_data::finish): Move from c-typeprint.c and rename.
* c-typeprint.c (OFFSET_SPC_LEN): Remove.
(print_spaces_filtered_with_print_options): Update.
(c_print_type_union_field_offset, maybe_print_hole)
(c_print_type_struct_field_offset): Move to typeprint.c and
rename.
(c_type_print_base_struct_union): Update.
PR 23335
* config/tc-msp430.c (check_reg): Only accept register name
strings that do not end in an alphanumeric character.
* testsuite/gas/msp430/msp430x.d: Update expected disassembly.
The testcase isn't valid. If it happens to run on your target, you're
lucky.
PR 23169
* testsuite/ld-ifunc/ifunc.exp: Don't run pr23169 tests on
powerpc. Comment.
The macOS build currently fails with several instances of this problem:
In file included from ../../src/gdb/darwin-nat.h:22:0,
from ../../src/gdb/i386-darwin-nat.c:37:
../../src/gdb/gdbthread.h:376:59: error: type/value mismatch at argument 1 in template parameter list for 'template<class T, class Policy> class gdb::ref_ptr'
= gdb::ref_ptr<thread_info, refcounted_object_ref_policy>;
^
../../src/gdb/gdbthread.h:376:59: note: expected a type, got 'thread_info'
../../src/gdb/gdbthread.h:396:28: error: variable or field 'delete_thread' declared void
extern void delete_thread (thread_info *thread);
^
(...)
This is because there's a thread_info function in the Darwin/XNU/mach API:
http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/thread_info.html
Fix this in the same way it had been fixed in commit 7aabaf9d4a
("Create private_thread_info hierarchy"), by adding an explicit
"struct" keyword.
gdb/ChangeLog:
2018-06-25 Pedro Alves <palves@redhat.com>
* gdbthread.h (thread_info_ref, delete_thread)
(delete_thread_silent, first_thread_of_inferior)
(any_thread_of_inferior, switch_to_thread)
(enable_thread_stack_temporaries)
(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
(get_last_thread_stack_temporary)
(value_in_thread_stack_temporaries, can_access_registers_thread):
Spell out "struct thread_info" instead of just "thread_info".
* inferior.h (notice_new_inferior): Likewise.
Commit 00431a78b2 ("Use thread_info and inferior pointers more
throughout") missed updating some callers, like e.g.,:
gdb/remote-sim.c: In member function 'virtual void gdbsim_target::mourn_inferior()':
gdb/remote-sim.c:1198:50: error: cannot convert 'ptid_t' to 'thread_info*' for argument '1' to 'void delete_thread_silent(thread_info*)'
delete_thread_silent (sim_data->remote_sim_ptid);
gdb/mygit/src/gdb/procfs.c: In member function ‘virtual void procfs_target::detach(inferior*, int)’:
gdb/mygit/src/gdb/procfs.c:1931:23: error: invalid conversion from ‘int’ to ‘inferior*’ [-fpermissive]
detach_inferior (pid);
^
In file included from gdb/mygit/src/gdb/procfs.c:24:0:
gdb/mygit/src/gdb/inferior.h:476:13: note: initializing argument 1 of ‘void detach_inferior(inferior*)’
etc.
This fixes it.
The delete_thread_silent calls in both go32-nat.c and remote-sim.c are
unnecessary because generic_mourn_inferior calls exit_inferior, which
deletes the inferior's threads.
gdb/ChangeLog:
2018-06-25 Pedro Alves <palves@redhat.com>
* windows-nat.c (windows_delete_thread): Use find_thread_ptid and
pass thread_info pointer to delete_thread.
(windows_nat_target::detach): Pass inferior pointer to
detach_inferior.
* aix-thread.c (sync_threadlists): Pass thread_info pointer to
delete_thread.
* bsd-kvm.c (bsd_kvm_target::close): Use discard_all_inferiors.
* darwin-nat.c (darwin_check_new_threads): Use find_thread_ptid
and pass a thread_info pointer to delete_thread.
* fbsd-nat.c (fbsd_nat_target::wait): Use find_thread_ptid and
pass thread_info pointer to delete_thread.
* go32-nat.c (go32_nat_target::mourn_inferior): Remove
delete_thread_silent call.
* procfs.c (procfs_target::detach): Pass inferior pointer to
detach_inferior.
(procfs_target::wait): Pass thread_info pointer to delete_thread.
* remote-sim.c (gdbsim_target::mourn_inferior): Remove
delete_thread_silent call.
* windows-nat.c (windows_delete_thread): Use find_thread_ptid and
pass thread_info pointer to delete_thread.
(windows_nat_target::detach): Pass inferior pointer to
delete_inferior.
This adds a syntax table for dwarf-mode to dwarf-mode.el. I noticed
the need for this when trying to use mark-sexp (C-M-SPC) on a hex
number -- it copied the trailing ">" as well, which isn't desirable.
I've also bumped the version number to make this simpler to install
via the Emacs package system.
Tested locally. I'm checking this in.
binutils/ChangeLog
2018-06-25 Tom Tromey <tom@tromey.com>
* dwarf-mode.el (dwarf-mode-syntax-table): New variable.
Bump version number.
gold/
PR gold/22915
* x86_64.cc (Output_data_plt_x86_64_ibt): New class.
(Target_x86_64::do_make_data_plt): (All instantiations) Check for
IBT feature bit and create IBT PLTs.
The original patch did not give the target enough hooks to discover that
an input object file does not have a particular property. For the
GNU_PROPERTY_X86_FEATURE_1_AND property, for example, where a missing
property should be assumed to be all zeroes, and ANDed with other
object modules, this is essential. We now store the target-specific
properties locally in the Target structure as native uint32_t fields,
then AND the per-object feature bits with the program's feature bits
when we're finished processing each input object file. The target-specific
properties are then added back to the output note section during
finalization.
gold/
PR gold/22914
* layout.cc (read_sized_value): Fix spelling of section name.
(Layout::layout_gnu_property): Call Sized_target::record_gnu_property
for target-specific properties;
don't store them with target-independent properties yet.
(Layout::merge_gnu_properties): New method.
(Layout::add_gnu_property): New method.
(Layout::create_gnu_properties_note): Call target to finalize
target-specific properties. Fix spelling of output section name.
* layout.h (Layout::merge_gnu_properties): New method.
(Layout::add_gnu_property): New method.
* object.cc (Sized_relobj_file::do_layout): Call
Layout::merge_gnu_properties.
* target.h (Target::merge_gnu_property): Remove.
(Target::finalize_gnu_properties): New method.
(Target::do_merge_gnu_property): Move to Sized_target and rename.
(Target::do_finalize_gnu_properties): New virtual method.
(Sized_target::record_gnu_property): Moved and renamed from
Target::do_merge_gnu_property.
(Sized_target::merge_gnu_properties): New virtual method.
* x86_64.cc (Target_x86_64::isa_1_used_, isa_1_needed_)
(feature_1_, object_feature_1_, seen_first_object_): New data members.
(Target_x86_64::do_merge_gnu_property): Rename to ...
(Target_x86_64::record_gnu_property): ... this. Save target-specific
properties in Target class object.
(Target_x86_64::merge_gnu_properties): New method.
(add_property): New static inline function.
(Target_x86_64::do_finalize_gnu_properties): New method.
* testsuite/Makefile.am (gnu_property_test): Remove C source file;
link directly without compiler driver.
* testsuite/Makefile.in: Regenerate.
* testsuite/gnu_property_a.S: Add _start.
Replacing push_back() with emplace_back() eliminates the calls to the
copy constructor, but I still had to provide explicit copy constructors
because of the call to vector::reserve(), which tries to instantiate them
even though they'll never actually be called when reserve() is called
on an empty vector.
gold/
* incremental.cc (Sized_incremental_binary::setup_readers): Use
emplace_back for GCC 5 and later.
* incremental.h (Incremental_binary::Input_reader): Provide copy
constructor.
(Sized_incremental_binary::Sized_input_reader): Likewise.
Commit
e813d34 ("Align natural-format register values to the same column")
changed the output of "info registers" (tabs to spaces), but didn't
update gdb.base/jit-reader.exp. Update the regexes to expect spaces
instead.
gdb/testsuite/ChangeLog:
* gdb.base/jit-reader.exp (jit_reader_test): Expect spaces in
"info registers" output.
elfcpp/
PR gold/22914
* elfcpp.h (NT_GNU_PROPERTY_TYPE_0): New note type.
(GNU_PROPERTY_*): New Gnu property types.
* x86_64.h (GNU_PROPERTY_X86_FEATURE_1_IBT)
(GNU_PROPERTY_X86_FEATURE_1_SHSTK): New x86 feature bits.
gold/
PR gold/22914
* layout.cc (Layout::Layout): Initialize gnu_properties_.
(read_sized_value, write_sized_value): New functions.
(Layout::layout_gnu_property): New method.
(Layout::create_notes): Call create_gnu_properties_note.
(Layout::create_gnu_properties_note): New method.
* layout.h (Layout::layout_gnu_property): New method.
(Layout::create_gnu_properties_note): New method.
(Layout::Gnu_property, Layout::Gnu_properties): New types.
(Layout::gnu_properties_): New data member.
* object.cc (Sized_relobj_file::layout_gnu_property_section): New
method.
(Sized_relobj_file::do_layout): Handle .note.gnu.property sections.
* object.h (Sized_relobj_file::layout_gnu_property_section): New
method.
* target.h (Target::merge_gnu_property): New method.
(Target::do_merge_gnu_property): New virtual method.
* x86_64.cc (Target_x86_64::do_merge_gnu_property): New method.
* testsuite/Makefile.am (gnu_property_test): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/gnu_property_a.S: New source file.
* testsuite/gnu_property_b.S: New source file.
* testsuite/gnu_property_c.S: New source file.
* testsuite/gnu_property_main.c: New source file.
* testsuite/gnu_property_test.sh: New test script.
This avoids assert failures when the register is bigger than the
slot size. This happens on Aarch64 when truncating Z registers
into an fpsimd structure. This can be triggered by running
gdb command "generate-core-file".
Also, when the register is smaller then the slot size, then
zero pad when writing to the slot, and truncate when writing
to the regcache. This happens on Aarch64 with the CPSR register.
Continue to ensure registers are invalidated when both buffers
are null.
gdb/
* regcache.c (readable_regcache::read_part): Fix asserts.
(reg_buffer::raw_collect_part): New function.
(regcache::write_part): Fix asserts.
(reg_buffer::raw_supply_part): New function.
(regcache::transfer_regset_register): New helper function.
(regcache::transfer_regset): Call new functions.
(regcache_supply_regset): Use gdb_byte*.
(regcache::supply_regset): Likewise.
(regcache_collect_regset): Likewise.
(regcache::collect_regset): Likewise.
* regcache.h (reg_buffer::raw_collect_part): New declaration.
(reg_buffer::raw_supply_part): Likewise.
(regcache::transfer_regset_register): Likewise.
(regcache::transfer_regset): Use gdb_byte*.
This patch fixes a disassembly issue with the aliases to subs with a shifted
register. The subs instruction with the zero register as destination is
supposed to alias to cmp and when the first input register is the zero register
the subs is supposed to be aliased to negs.
This means that a subs with destination and first input registers the zero
register is supposed to be a cmp.
This is done by raising the priority of the cmp alias.
opcodes/
* aarch64-tbl.h (aarch64_opcode_table): Fix alias flag for negs
* aarch64-asm-2.c: Regenerate.
* aarch64-dis-2.c: Likewise.
gas/
* testsuite/gas/aarch64/addsub.s: Add negs to zero reg test.
* testsuite/gas/aarch64/addsub.d: Likewise.