This patch renames a few trace-related functions, so that they adhere to
the de facto standard of naming command entry point functions
<command>_command. I like the ease of looking up a command entry point
if they all follow that rule.
An enum label "tstop_command" conflicts with a new function name, so I
renamed this one trace_stop_command.
In v2:
- Rename functions of the trace_find family, as well as
trace_dump_command.
gdb/ChangeLog:
* tracefile-tfile.c (tfile_write_status): Adjust to renames.
* tracefile.c (trace_save_command): Rename to...
(tsave_command): ...this.
(_initialize_tracefile): Adjust to renames.
* tracepoint.c (trace_actions_command): Rename to...
(actions_command): ...this.
(trace_start_command): Rename to...
(tstart_command): ...this, and adjust to renames..
(trace_stop_command): Rename to...
(tstop_command): ...this.
(trace_status_command): Rename to...
(tstatus_command): ...this, and adjust to renames.
(trace_find_command): Rename to...
(tfind_command): ...this.
(trace_find_pc_command): Rename to...
(tfind_pc_command): ...this.
(trace_find_tracepoint_command): Rename to...
(tfind_tracepoint_command): ...this.
(trace_find_line_command): Rename to...
(tfind_line_command): ...this.
(trace_find_range_command): Rename to...
(tfind_range_command): ...this.
(trace_find_outside_command): Rename to...
(tfind_outside_command): ...this.
(trace_dump_command): Rename to...
(tdump_command): ...this.
(tfind_1): Adjust to renames.
(trace_find_end_command): Rename to...
(tfind_end_command): ...this, and adjust to renames..
(trace_status_mi): Adjust to renames.
(parse_trace_status): Adjust to renames.
(_initialize_tracepoint): Adjust to renames.
* tracepoint.h (enum trace_stop_reason) <tstop_command>: Rename
to...
<trace_stop_command>: ...this.
The suppress_output field of the mi_ui_out_data structure is never actually
set to 1/true. We can therefore remove it, and remove all the
if (suppress_output)
checks.
gdb/ChangeLog:
* mi/mi-out.c (mi_ui_out_data) <suppress_output>: Remove.
(mi_table_body): Remove suppress_output check.
(mi_table_end): Likewise.
(mi_table_header): Likewise.
(mi_begin): Likewise.
(mi_end): Likewise.
(mi_field_int): Likewise.
(mi_field_string): Likewise.
(mi_field_fmt): Likewise.
(mi_out_data_ctor): Likewise.
_bfd_elf_make_section_from_shdr calls elf_parse_notes with an offset
of -1. This argument is used to calculate Elf_Internal_Note.descpos,
which ends up set to a positive but meaningless value. This commit
updates _bfd_elf_make_section_from_shdr to pass the correct offset to
elf_parse_notes, making Elf_Internal_Note.descpos correct in all cases.
bfd/ChangeLog:
* elf.c (_bfd_elf_make_section_from_shdr): Pass offset to
elf_parse_notes.
* configure.ac: Add fuchsia to targets that use ELF.
* configure: Regenerated.
bfd * configure.tgt: Add support for fuchsia (OS).
gas * configure.tgt: Add support for fuchsia (OS).
ld * Makefile.am: Add dependency information for earmelf_fuchsia.c.
* Makefile.in: Regenerate.
* configure.tgt: Add support for aarch64-*-fuchsia, arm*-*-fuchsia*, and
x86_64-*-fuchsia* targets.
* emulparams/armelf_fuchsia.sh: New file.
* emulparams/armelfb_fuchsia.sh: New file.
This patch teaches GDB AArch64 backend to recognize STR instructions
in prologue, like 'str x19, [sp, #-48]!' or 'str w0, [sp, #44]'.
The unit test is added too.
gdb:
2016-12-02 Yao Qi <yao.qi@linaro.org>
Pedro Alves <palves@redhat.com>
* aarch64-tdep.c (aarch64_analyze_prologue): Recognize STR
instruction.
(aarch64_analyze_prologue_test): More tests.
We don't have an effective way to test prologue analyzer which is
highly dependent on instruction patterns in prologue generated by
compiler. GDB prologue analyzer may not handle the new sequences
generated by new compiler, or may still handle some sequences that
generated by very old compilers which are no longer used. The
former is a functionality issue, while the latter is a maintenance
issue.
The input and output of prologue analyzer is quite clear, so it
fits for unit test. The input is series of instructions, and the
output are 1) where prologue end, 2) where registers are saved.
In aarch64, they are represented in 'struct aarch64_prologue_cache'.
This patch refactors aarch64_analyze_prologue so it can read
instructions from either real target or test harness. In unit
test aarch64_analyze_prologue_test, aarch64_analyze_prologue gets
instructions we prepared in the test, as the input of prologue
analyzer. Then, we checked various fields in
'struct aarch64_prologue_cache'.
gdb:
2016-12-02 Yao Qi <yao.qi@linaro.org>
Pedro Alves <palves@redhat.com>
* aarch64-tdep.c: Include "selftest.h".
(abstract_instruction_reader): New class.
(instruction_reader): New class.
(aarch64_analyze_prologue): Add new parameter reader. Call
reader.read instead of read_memory_unsigned_integer.
[GDB_SELF_TEST] (instruction_reader_test): New class.
(aarch64_analyze_prologue_test): New function.
(_initialize_aarch64_tdep) [GDB_SELF_TEST]: Register
selftests::aarch64_analyze_prologue_test.
* trad-frame.c (trad_frame_cache_zalloc):
(trad_frame_alloc_saved_regs): Add a new function.
* trad-frame.h (trad_frame_alloc_saved_regs): Declare.
This fixes a few cases where the testcase is explicitly handling timeouts
inside gdb_test_multiple when it is not necessary.
It also converts two gdb_test_multiple calls to gdb_test_no_output calls
(also removing the timeout handling).
gdb/testsuite/ChangeLog:
2016-12-01 Luis Machado <lgustavo@codesourcery.com>
* gdb.base/maint.exp: Remove timeout handling for gdb_test_multiple.
* gdb.cp/gdb2495.exp: Likewise and convert gdb_test_multiple into
gdb_test_no_output for a couple of cases.
* gdb.cp/ovldbreak.exp: Remove timeout handling for gdb_test_multiple.
If the default starting address is less than the new ABI page size,
we end up misaligning the file header, causing an internal error.
gold/
PR gold/20834
* target.h (Target::default_text_segment_address): Bump default
start address up to ABI page size.
gold/
PR gold/18989
* options.cc (General_options::object_format_to_string): New function.
(General_options::copy_from_posdep_options): New function.
(General_options::parse_push_state): New function.
(General_options::parse_pop_state): New function.
* options.h (--push-state, --pop-state): New options.
(General_options::object_format_to_string): New method.
(General_options::set_incremental_disposition): New method.
(General_options::copy_from_posdep_options): New method.
(General_options::options_stack_): New data member.
This patch makes a class out of the ui_out_table structure, the
structure responsible for managing the generation of an UI table.
To simplify the ui_out_table object, I changed it so that it can only be
used for generating a single object. Instead of clearing the header
list when starting a new table, we an ui_out_table when starting a
table and delete it when we're done. Therefore, the checks:
if (uiout->table->flag)
if (!uiout->table->flag)
are respectively replaced with
if (uiout->table != nullptr)
if (uiout->table == nullptr)
Note: I removed the check at the beginning of ui_out_begin, because
there is an equivalent check at the beginning of verify_field.
New in v2:
- use "enum class" for ui_out_table::state and update references.
gdb/ChangeLog:
* ui-out.c (enum ui_out_table_state): Move to class
ui_out_table as ui_out_table::state.
(struct ui_out_table): Change to ...
(class ui_out_table): ... this.
<flag>: Remove.
<entry_level>: Rename to ...
<m_entry_level>: ... this.
<columns>: Rename to ...
<m_nr_cols>: ... this.
<id>: Rename to ...
<m_id>: ... this.
<headers>: Rename to ...
<m_headers>: ... this.
<headers_iterator>: Rename to ...
<m_headers_iterator>: ... this.
<start_body, append_header, start_row, get_next_header,
query_field, current_state, entry_level>: New methods.
(struct ui_out) <table>: Change type to unique_ptr to
ui_out_table.
(append_header_to_list, get_next_header, clear_header_list,
clear_table): Remove.
(ui_out_table_begin): Instantiate ui_out_table object. Update
table check.
(ui_out_table_body): Update table check, replace code with call
to ui_out_table::start_body.
(ui_out_table_end): Update table check, replace manual cleanup
with assignment of uiout->table unique_ptr to nullptr.
(ui_out_table_header): Update table check, replace call to
append_header_to_list with call to append_header method.
(ui_out_begin): Remove one table state check, update another.
Replace code with call to start_row method.
(verify_field): Update table checks.
(ui_out_query_field): Update table check, replace code with call
to query_field method.
(ui_out_new): Remove table initialization code.
This patch is just a little cleanup, it replaces the body_flag field of
ui_out_table with an enum. It expresses more explicitly the
intent of the field (check that state == TABLE_STATE_HEADERS conveys
more what we want to do than checking for !body_flag).
New in v2:
- Remove unnecessary ui_out_table_state::.
gdb/ChangeLog:
* ui-out.c (enum ui_out_table_state): New enum.
(struct ui_out_table) <body_flag>: Remove field.
<state>: New field.
(ui_out_table_begin): Replace usages of body_flag with state.
(ui_out_table_body): Likewise.
(ui_out_table_end): Likewise.
(ui_out_table_header): Likewise.
(ui_out_begin): Likewise.
(verify_field): Likewise.
(ui_out_new): Likewise.
Now that we use a vector to store the levels, we don't have to keep a
separate level field in ui_out to keep track of the current level. We
can efficiently derive it from the vector size. That causes a little
change in the meaning of the level, as in they are now 1-based instead
of 0-based (the initial level has the "id" 1 now), but it shouldn't
change anything in the behavior.
Additionally, push_level and pop_level don't really need to return the
new level, making them return void simplifies the code a bit.
Finally, the ui_out_begin/ui_out_end callbacks in the ui_out_impl
interface don't need to be passed the level, it's never actually used.
New in v2:
- Remove or update stale comments.
gdb/ChangeLog:
* ui-out.h (ui_out_begin_ftype): Remove level parameter.
(ui_out_end_ftype): Likewise.
* ui-out.c (struct ui_out) <level>: Replace field with a method
that dynamically computes the result.
(current_level): Get vector's back item instead of using
uiout->level.
(push_level): Make return type void.
(pop_level): Make return type void and update access to
ui_out::level.
(uo_begin): Remove level parameter.
(uo_end): Likewise.
(ui_out_table_begin): Update access to uiout::level.
(ui_out_begin): Don't read return value from push_level, call
uiout->level() instead, update call to uo_begin.
(ui_out_end): Don't read return value from pop_level, update
call to uo_end.
(verify_field): Update access to uiout->level.
(ui_out_new): Don't initialize ui_out::level, call push_level
to push the initial level instead of doing it by hand.
* cli-out.c (cli_begin): Remove level parameter.
(cli_end): Likewise.
* mi/mi-out.c (mi_begin): Likewise.
(mi_end): Likewise.
This patch changes struct ui_out_level to be a real C++ class. No
behavioral changes.
gdb/ChangeLog:
* ui-out.c (struct ui_out_level): Replace with ...
(class ui_out_level): ... this.
(current_level): Update.
(push_level): Update.
(pop_level): Update.
(verify_field): Update.
(ui_out_new): Update.
This patch makes ui_out_hdr (the object that represents an ui-out table
header) a proper C++ class. No behavior changes, it's all about
encapsulation.
gdb/ChangeLog:
* ui-out.c (struct ui_out_hdr): Replace with ...
(class ui_out_hdr): ... this.
(append_header_to_list): Update.
(get_next_header): Update.
(ui_out_query_field): Update.
Instead of keeping pointers to first, last and current ui_out_hdr in
ui_out_table, we can use an std::vector and an iterator. Direct random
access of to vector helps make get_next_header a bit nicer by avoiding
iterating on all the headers. append_header_to_list is also a bit
simpler.
Also, using unique_ptr inside the vector allows expressing the ownership
of the ui_out_hdr objects by the ui_out_table object, and it simplifies
the destruction.
gdb/ChangeLog:
* ui-out.c (struct ui_out_hdr) <next>: Remove.
(struct ui_out_table) <header_first, header_last, header_next>: Remove.
<headers, headers_iterator>: New fields.
(ui_out_table_body): Update for the new data structure.
(ui_out_begin): Likewise.
(clear_header_list): Likewise.
(append_header_to_list): Likewise.
(get_next_header): Likewise.
(ui_out_query_field): Likewise.
(ui_out_new): Likewise.
This fixes offender testcases that have test names starting with uppercase
when using gdb_test_multiple in a multi-line construct.
gdb/testsuite/ChangeLog
2016-12-01 Luis Machado <lgustavo@codesourcery.com>
* gdb.cp/gdb2495.exp: Replace gdb_test_multiple
with gdb_test_no_output.
Use command as test name.
This fixes offender testcases that have test names starting with uppercase
when using gdb_test_no_output in a multi-line construct.
gdb/testsuite/ChangeLog
2016-12-01 Luis Machado <lgustavo@codesourcery.com>
Fix test names starting with uppercase throughout the files.
* gdb.ada/assign_1.exp
* gdb.ada/boolean_expr.exp
* gdb.base/arrayidx.exp
* gdb.base/del.exp
* gdb.base/gcore-buffer-overflow.exp
* gdb.base/testenv.exp
* gdb.compile/compile.exp
* gdb.python/py-framefilter-invalidarg.exp
* gdb.python/py-framefilter.exp
This fixes offender testcases that have test names starting with uppercase
when using gdb_test_multiple in a single-line construct.
gdb/testsuite/ChangeLog
2016-12-01 Luis Machado <lgustavo@codesourcery.com>
Fix test names starting with uppercase throughout the files.
* gdb.arch/i386-bp_permanent.exp
* gdb.arch/i386-gnu-cfi.exp
* gdb.base/disasm-end-cu.exp
* gdb.base/macscp.exp
* gdb.base/pending.exp
* gdb.base/watch_thread_num.exp
* gdb.cp/exception.exp
* gdb.cp/gdb2495.exp
* gdb.cp/local.exp
* gdb.python/py-evsignal.exp
* gdb.python/python.exp
* gdb.trace/tracecmd.exp
The attached patch fixes a problem where nm displays bogus information for
synthetic symbol sizes when --size-sort is used.
This happens because the synthetic symbols (dot symbols for ppc64) are
generated based on their non-dot symbols. The generation process doesn't copy
over the ELF-specific bits of the regular non-dot symbols.
When --size-sort is used, the code attempts to access the symbol size from
the ELF-specific bits and ends up reading gargabe, causing the size to be
displayed incorrectly.
With the patch, i can see dot and non-dot symbols having the same size with
--size-sort.
This doesn't fix the fact that we don't display size information for synthetic
symbols without --size-sort, which i may address in the future.
binutils/ChangeLog:
2016-12-01 Luis Machado <lgustavo@codesourcery.com>
* nm.c (sort_symbols_by_size): Don't read symbol size if symbol
is synthetic.
PR ld/20868
bfd * elfnn-aarch64.c (elfNN_aarch64_tls_relax): Use 32-bit accesses
to the GOT when operating in 32-bit mode.
ld * testsuite/ld-aarch64/tls-relax-gd-ie-ilp32.d: New test.
* testsuite/ld-aarch64/relocs-ilp32.ld: Linker script for the new
test.
* testsuite/ld-aarch64/aarch64-elf.exp: Run the new test.
Use std::string for the id field of the ui_out_table object.
I found that all users of ui_out_table_begin passed a non-NULL value to
the tblid parameter, so we don't have to worry about the NULL case. I
changed the tblid parameter to be a std::string while at it.
gdb/ChangeLog:
* ui-out.c (struct ui_out_table) <id>: Change type to
std::string.
(ui_out_table_begin): Change tblid parameter type to
std::string, adapt code.
update following type change.
(clear_table): Update.
(ui_out_new): Update.
Use a standard vector instead of the home-made version. I used a vector
of plain pointers, because the cli_ui_out_data object doesn't own the
streams objects (i.e. they shouldn't be deleted when the vector is
deleted).
gdb/ChangeLog:
* cli-out.h (cli_ui_out_data) <streams>: Change type to
std::vector.
* cli-out.c: Remove vec.h include.
(cli_uiout_dtor): Update.
(cli_field_fmt): Update.
(cli_spaces): Update.
(cli_text): Update.
(cli_message): Update.
(cli_flush): Update.
(cli_redirect): Update.
(out_field_fmt): Update.
(field_separator): Update.
(cli_out_data_ctor): Update.
(cli_out_new): Update.
(cli_out_set_stream): Update.
Use a standard vector instead of the home-made version. I used a vector
of plain pointers, because the mi_ui_out_data object doesn't own the
streams objects (i.e. they shouldn't be deleted when the vector is
deleted).
gdb/ChangeLog:
* mi/mi-out.c: Remove vec.h include.
(mi_ui_out_data) <streams>: Change type to std::vector.
(mi_field_string): Update.
(mi_field_fmt): Update.
(mi_flush): Update.
(mi_redirect): Update.
(field_separator): Update.
(mi_open): Update.
(mi_close): Update.
(mi_out_buffered): Update.
(mi_out_rewind): Update.
(mi_out_put): Update.
(mi_out_data_ctor): Update.
(mi_out_data_dtor): Don't free streams.
Convert the levels field of struct ui_out to be a vector of unique_ptr
to ui_out_level. This way, the ownership of the ui_out_level objects by
the ui_out instance is clear.
gdb/ChangeLog:
* ui-out.c (ui_out_level_p): Remove typedef.
(DEF_VEC_P (ui_out_level_p)): Remove definition.
(struct ui_out) <levels>: Change type to vector of unique_ptr of
ui_out_level.
(current_level): Update.
(push_level): Update.
(pop_level): Update, don't manually delete the ui_out_level
instance.
(ui_out_new): Update.
The following patches introduce C++ vectors and strings as fields of the
various ui_out structures. We therefore need to use new/delete so that
their contructor/destructor is called. I find it simpler to change all
the allocations in a separate preliminary patch, rather than in each
individual patch.
gdb/ChangeLog:
* cli-out.c (cli_uiout_dtor): Use delete instead of xfree.
(cli_out_new): Use new instead of XNEW.
* mi/mi-out.c (mi_out_data_dtor): Use delete instead of xfree.
(mi_out_new): Use new instead of XNEW.
* tui/tui-out.c (tui_out_new): Likewise.
* ui-out.c (push_level): Likewise.
(pop_level): Use delete instead of xfree.
(clear_header_list): Use delete instead of xfree.
(append_header_to_list): Use new instead of XNEW.
(ui_out_new): Likewise.
Since we don't use suffix rules nor implicit rules in gdb, we can
disable them. The advantage is a slightly faster make [1].
Here are some numbers about the speedup. I ran this on my trusty old
Intel Q6600, so the time numbers are probably higher than what you'd get
on any recent hardware. I ran "make" in the gdb/ directory of an
already built repository (configured with --enable-targets=all). I
recorded the time of execution (average of 5). I then ran "make -d" and
recorded the number of printed lines, which gives a rough idea of the
number of operations done.
I compared the following configurations, to see the impact of both the
empty .SUFFIXES target and the empty pattern rules, as well as running
"make -r", which can be considered the "ideal" case.
A - baseline
B - baseline + .SUFFIXES
C - baseline + pattern rules
D - baseline + .SUFFIXES + pattern rules
E - baseline + make -r
config | time (s) | "make -d"
-----------------------------
A | 5.74 | 2396643
B | 1.19 | 298469
C | 2.81 | 1266573
D | 1.13 | 245489
E | 1.01 | 163914
We can see that the empty .SUFFIXES target has a bigger impact than the
empty pattern rules, but still it doesn't hurt to disable the implicit
pattern rules as well.
There are still some mentions of implicit rules I can't get rid of in
the "make -d" output. For example, it's trying to build .c files from
.w files:
Looking for an implicit rule for '/home/simark/src/binutils-gdb/gdb/infrun.c'.
Trying pattern rule with stem 'infrun'.
Trying implicit prerequisite '/home/simark/src/binutils-gdb/gdb/infrun.w'.
and trying to build Makefile.in from a bunch of extensions:
Looking for an implicit rule for 'Makefile.in'.
Trying pattern rule with stem 'Makefile.in'.
Trying implicit prerequisite 'Makefile.in.o'.
Trying pattern rule with stem 'Makefile.in'.
Trying implicit prerequisite 'Makefile.in.c'.
Trying pattern rule with stem 'Makefile.in'.
Trying implicit prerequisite 'Makefile.in.cc'.
... many more ...
If somebody knows how to disable them, we can do it, but at this point
the returns are minimal, so it is not that important.
I verified that both in-tree and out-of-tree builds work.
[1] Switching from explicit rules to pattern rules for files in
subdirectories actually made it slower, so this is kind of a way to
redeem myself. But it the end it's faster than it was previously,
so it was all worth it. :)
gdb/ChangeLog:
* disable-implicit-rules.mk: New file.
* Makefile.in: Include disable-implicit-rules.mk.
* data-directory/Makefile.in: Likewise.
* gnulib/Makefile.in: Likewise.
gdb/doc/ChangeLog:
* Makefile.in: Likewise.
gdb/gdbserver/ChangeLog:
* Makefile.in: Include disable-implicit-rules.mk.
gdb/testsuite/ChangeLog:
* Makefile.in: Include disable-implicit-rules.mk.
When GDB read inferior memory as an address or an instruction,
it should be unsigned.
gdb:
2016-11-30 Yao Qi <yao.qi@linaro.org>
* arm-tdep.c (arm_scan_prologue): Read memory as unsigned integer.
(arm_exidx_unwind_sniffer): Likewise.