For GNU_PROPERTY_STACK_SIZE, pr_datasz is the same as align_size, which
is 8 bytes for 64-bit ELF binaries and 4 bytes for 32-bit ELF binaries,
Use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE to convert
.note.gnu.property section.
bfd/
PR binutils/23494
* elf-properties.c (elf_get_gnu_property_section_size): Always
use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE.
(elf_write_gnu_properties): Likewise.
binutils/
PR binutils/23494
* testsuite/binutils-all/x86-64/pr23494c.s: New file.
* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
Make it clearer that the size field indicates the size of the section.
gdb/
* corelow.c (core_target::get_core_register_section): Rename
min_size to section_min_size.
This adds the target and native configure support, and the NEWS entries for
the new target and native configurations.
gdb/
* Makefile.in (ALL_TARGET_OBS): Add riscv-linux-tdep.c.
(ALLDEPFILES): Add riscv-linux-nat.c, and riscv-linux-tdep.c.
* NEWS: Mention new GNU/Linux RISC-V target.
* configure.host: Add riscv*-*-linux*.
* configure.nat: Add riscv*.
* configure.tgt: Add riscv*-*-linux*.
Make the infrun.c:resume function static, and update the header
comment on the infrun.c:proceed function. There should be no user
visible change after this commit.
gdb/ChangeLog:
* infrun.c (resume): Make static, add forward declaration.
(proceed): Update header comment.
* infrun.h (resume): Delete declaration.
This fixes some minor formatting issues in riscv-tdep.h, including one
pointed out by ARI.
ChangeLog
2018-08-09 Tom Tromey <tom@tromey.com>
* riscv-tdep.h: Minor formatting fixes.
ARI produces this warning for the lines touched in this patch:
warning: gettext: All messages should be marked up with _.
However, in these cases, the message is not translatable (they are
syscall names). Adding an extra set of parentheses silences the
warning.
gdb/ChangeLog:
* common/scoped_mmap.c (mmap_file): Silence ARI warning.
* dwarf-index-cache.c (create_dir_and_check): Likewise.
(test_mkdir_recursive): Likewise.
* dwarf-index-write.c (write_psymtabs_to_index): Likewise.
If a vla is not in memory, and the upper bound is not defined, then we
can't know that an array element exists or not, and we should not try
to access the array element. One case where this happens is for
arrays that have been optimised out, the array will then have
VALUE_LVAL of not_lval, and an undefined upper bound, if we then try
to access an element of this array we will index into random GDB
memory.
An argument could be made that even for arrays that are in inferior
memory, if the upper bound is not defined then we should not try to
access the array element, however, in some of the Fortran tests, it
seems as though we do rely indexing from a base address into an array
which has no bounds defined. In this case GDBs standard protection
for detecting unreadable target memory prevents bad thing happening.
gdb/ChangeLog:
* valarith.c (value_subscripted_rvalue): If an array is not in
memory, and we don't know the upper bound, then we can't know that
the requested element exists or not.
gdb/testsuite/ChangeLog:
* gdb.base/vla-optimized-out.exp: Add new test.
The three test scripts:
gdb/testsuite/gdb.base/vla-optimized-out.exp
gdb/testsuite/gdb.base/vla-optimized-out-o3.exp
gdb/testsuite/gdb.base/vla-optimized-out-o3-strict.exp
are all pretty similar, with differences in the compile flags used,
and some of the expected results.
Instead of maintaining 3 files, merge them into a single test script,
and use parameters to control the test behaviour.
gdb/testsuite/ChangeLog:
* gdb.base/vla-optimized-out-o3.exp: Delete.
* gdb.base/vla-optimized-out-o3-strict.exp: Delete.
* gdb.base/vla-optimized-out.exp: Extend to cover all of the
deleted tests.
This patch adds a few comments to include/elf/arm.h to clarify which
versions of the ARM ELF specification defined which headers. Given
that the EABI is pretty ubiquitous these days, I've marked anything
not based on that as deprecated.
There are no plans to remove any deprecated definitions at this time,
but any new development shouldn't be building upon support for
deprecated definitions remaining in the long term.
* elf/arm.h: Updated comments for e_flags definitions.
Fix a typo and add a missing one.
gdb/ChangeLog:
* target.c (str_comma_list_concat_elem): Fix typo in comment.
(target_options_to_string): Add comment.
Some distros enable _FORTIFY_SOURCE by default, which caught a failure
to check the result of "write" in scoped_mmap-selftests.c. This patch
fixes the problem.
ChangeLog
2018-08-08 Tom Tromey <tom@tromey.com>
* unittests/scoped_mmap-selftests.c: Check result of "write".
This adds software single step support that is needed by the linux native port.
This is modeled after equivalent code in the MIPS port.
This also fixes a few bugs in the compressed instruction decode support. Some
instructions are RV32/RV64 specific, and this wasn't being checked. Also, a
few instructions were accidentally using the non-compressed is_* function.
This has been tested on a HiFive Unleashed running Fedora, by putting a
breakpoint on start, typing stepi, and then holding down the return key until
it finishes, and observing that I see everything I expect to see along the way.
There is a problem in _dl_addr where I get into an infinite loop, but it seems
to be some synchronization code that doesn't agree with single step, so I have
to find the end of the loop, put a breakpoint there, continue, and then single
step again until the end.
gdb/
* riscv-tdep.c (enum opcode): Add jump, branch, lr, and sc opcodes.
(decode_register_index_short): New.
(decode_j_type_insn, decode_cj_type_insn): New.
(decode_b_type_insn, decode_cb_type_insn): New.
(riscv_insn::decode): Add support for jumps, branches, lr, and sc. New
local xlen. Check xlen when decoding ambiguous compressed insns. In
compressed decode, use is_c_lui_insn instead of is_lui_insn, and
is_c_sw_insn instead of is_sw_insn.
(riscv_next_pc, riscv_next_pc_atomic_sequence): New.
(riscv_software_single_step): New.
* riscv-tdep.h (riscv_software_single_step): Declare.
This allows the function to be used from riscv OS files, which also need to
depend on XLEN size.
gdb/
* riscv-tdep.c (riscv_isa_xlen): Drop static.
* riscv-tdep.h (riscv_isa_xlen): Add extern declaration.
As indicated by the subject, this patch adds support for the DWARF
expression opcode DW_OP_GNU_variable_value to readelf.
It's pretty much a copy/paste of DW_OP_call_ref with the obvious name
changes for the printf statements. The FIXME comment comes from that
copy/paste.
binutils/ChangeLog:
* dwarf.c (decode_location_expresion): Add case for
DW_OP_GNU_variable_value.
Without the GNU_PROPERTY_X86_ISA_1_USED property, all ISAs may be used.
If a bit in the GNU_PROPERTY_X86_ISA_1_USED property is unset, the
corresponding x86 instruction set isn’t used. When merging properties
from 2 input files and one input file doesn't have the
GNU_PROPERTY_X86_ISA_1_USED property, the output file shouldn't have
it neither. This patch removes the GNU_PROPERTY_X86_ISA_1_USED
property if an input file doesn't have it.
This patch replaces the GNU_PROPERTY_X86_ISA_1_USED property with the
GNU_PROPERTY_X86_ISA_1_NEEDED property which is the minimum ISA
requirement.
bfd/
PR ld/23486
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove
GNU_PROPERTY_X86_ISA_1_USED if an input file doesn't have it.
(_bfd_x86_elf_link_setup_gnu_properties): Adding the
GNU_PROPERTY_X86_ISA_1_NEEDED, instead of
GNU_PROPERTY_X86_ISA_1_USED, property.
ld/
PR ld/23486
* testsuite/ld-i386/i386.exp: Run PR ld/23486 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr23486a.d: New file.
* testsuite/ld-i386/pr23486b.d: Likewise.
* testsuite/ld-x86-64/pr23486a-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486a.d: Likewise.
* testsuite/ld-x86-64/pr23486a.s: Likewise.
* testsuite/ld-x86-64/pr23486b-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486b.d: Likewise.
* testsuite/ld-x86-64/pr23486b.s: Likewise.
* testsuite/ld-i386/property-3.r: Remove "x86 ISA used".
* testsuite/ld-i386/property-4.r: Likewise.
* testsuite/ld-i386/property-5.r: Likewise.
* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
* testsuite/ld-x86-64/property-3.r: Likewise.
* testsuite/ld-x86-64/property-4.r: Likewise.
* testsuite/ld-x86-64/property-5.r: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
Consider the following GDB session:
(gdb) target extended-remote :2347
(gdb) file /path/to/exe
(gdb) set remote exec-file /path/to/exe
(gdb) set detach-on-fork off
(gdb) break breakpt
(gdb) run
# ... hits breakpoint
(gdb) info inferiors
Num Description Executable
* 1 process 17001 /path/to/exe
2 process 17002 /path/to/exe
(gdb) kill
(gdb) info inferiors
Num Description Executable
* 1 <null> /path/to/exe
2 process 17002 /path/to/exe
(gdb) target extended-remote :2348
../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Or, from bug PR gdb/18050:
(gdb) start
(gdb) add-inferior -exec /path/to/exe
(gdb) target extended-remote :2347
../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
The issue is calling target.c:dispose_inferior with a killed inferior in
the inferior list. This assertion is fixed in this commit.
The new test for this issue only runs on platforms that support
'detach-on-fork', and when using
'--target_board=native-extended-gdbserver'.
gdb/ChangeLog:
PR gdb/18050:
* target.c (dispose_inferior): Don't dispose of inferiors that are
already killed.
gdb/testsuite/ChangeLog:
PR gdb/18050:
* gdb.server/extended-remote-restart.c: New file.
* gdb.server/extended-remote-restart.exp: New file.
Commit 87d6a7aa93 ("Add DWARF index cache") broke
gdb.fortran/nested-funcs.exp. Because of the new "set index-cache"
command, the expression "set index = 42" now fails:
set index = 42
Undefined set index-cache command: "= 42". Try "help set index-cache".
(gdb) PASS: gdb.fortran/nested-funcs.exp: set index = 42
Fix it by changing it to "set variable index = 42". Also, use
gdb_test_no_output to confirm that it worked (since that particular test
wrongfully passed).
gdb/testsuite/ChangeLog:
* gdb.fortran/nested-funcs.exp: Replace "set index = 42" with
"set variable index = 42".
Return an std::string instead of a char *, saving some manual freeing.
I only manually tested with "set debug target 1" and "set debug lin-lwp
1", since this only deals with debug output.
gdb/ChangeLog:
* target.h (target_options_to_string): Return an std::string.
* target.c (str_comma_list_concat_elem): Return void, use
std::string.
(do_option): Likewise.
(target_options_to_string): Return an std::string.
* linux-nat.c (linux_nat_target::wait): Adjust.
* target-debug.h (target_debug_print_options): Adjust.
While looking into PR build/8751 (which seems to be fixed), I noticed
that it's not possible to change CPPFLAGS for gdb on the "make"
command line. It's reasonable to want to do this sometimes, and I
think this patch should suffice.
gdb/ChangeLog
2018-08-07 Tom Tromey <tom@tromey.com>
* Makefile.in (CPPFLAGS): New variable.
(INTERNAL_CPPFLAGS): Use it.
New in v3:
- Address Eli's comments.
This patch adds doc and news for the feature introduced by the previous
patch.
gdb/ChangeLog:
* NEWS: Mention the index cache.
gdb/doc/ChangeLog:
* gdb.texinfo (Index Files Speed Up GDB): Add section about
symbol index cache.
New in v3:
- Remove things related to the dwarf-5 format.
- Fix compilation on mingw (scoped_mmap.c).
GDB can generate indexes for DWARF debug information, which, when
integrated in the original binary, can speed up loading object files.
This can be done using the gdb-add-index script or directly by the
linker itself. However, not many people know about this. And even
among those who do, because it requires additional steps, I don't know a
lot of people who actually go through that trouble.
To help make using the DWARF index more transparent, this patch
introduces a DWARF index cache. When enabled, loading an index-less
binary in GDB will automatically save an index file in ~/.cache/gdb.
When loading that same object file again, the index file will be looked
up and used to load the DWARF index. You therefore get the benefit of
the DWARF index without having to do additional manual steps or
modifying your build system. When an index section is already present
in the file, GDB will prefer that one over looking up the cache.
When doing my edit-compile-debug cycle, I often debug multiple times the
same build, so the cache helps reducing the load time of the debug
sessions after the first one.
- The saved index file is exactly the same as the output of the "save
gdb-index" command. It is therefore the exact same content that would
be found in the .gdb_index or .debug_names section. We just leave it
as a standalone file instead of merging it in the binary.
- The cache is just a directory with files named after the object
file's build-id. It is not possible to save/load the index for an
object file without build-id in the cache.
- The cache uses the gdb index format. The problem with the dwarf-5
format is that we can generate an addendum to the .debug_str section
that you're supposed to integrate to the original binary. This
complicates a little bit loading the data from the cached index files,
so I would leave this for later.
- The size taken up by ~/.cache/gdb is not limited. I was thinking we
could add configurable limit (like ccache does), but that would come
after. Also, maybe a command to flush the cache.
- The cache is disabled by default. I think once it's been out there
and tested for a while, it could be turned on by default, so that
everybody can enjoy it.
- The code was made to follow the XDG specification: if the
XDG_CACHE_HOME environment variable, it is used, otherwise it falls
back to ~/.cache/gdb. It is possible to change it using "set
index-cache directory". On other OSes than GNU/Linux, ~/.cache may
not be the best place to put such data. On macOS it should probably
default to ~/Library/Caches/... On Windows, %LocalAppData%/... I
don't intend to do this part, but further patches are welcome.
- I think that we need to be careful that multiple instances of GDB
don't interfere with each other (not far fetched at all if you run GDB
in some automated script) and the cache is always coherent (either the
file is not found, or it is found and entirely valid). Writing the
file directly to its final location seems like a recipe for failure.
One GDB could read a file in the index while it is being written by
another GDB. To mitigate this, I made write_psymtabs_to_index write
to temporary files and rename them once it's done. Two GDB instances
writing the index for the same file should not step on each other's
toes (the last file to be renamed will stay). A GDB looking up a file
will only see a complete file or no file. Also, if GDB crashes while
generating the index file, it will leave a work-in-progress file, but
it won't be picked up by other instances looking up in the cache.
gdb/ChangeLog:
* common/pathstuff.h (get_standard_cache_dir): New.
* common/pathstuff.c (get_standard_cache_dir): New.
* build-id.h (build_id_to_string): New.
* dwarf-index-common.h (INDEX4_SUFFIX, INDEX5_SUFFIX,
DEBUG_STR_SUFFIX): Move to here.
* dwarf-index-write.c (INDEX4_SUFFIX, INDEX5_SUFFIX,
DEBUG_STR_SUFFIX): Move from there.
(write_psymtabs_to_index): Make non-static, add basename
parameter. Write to temporary files, rename when done.
(save_gdb_index_command): Adjust call to
write_psymtabs_to_index.
* dwarf2read.h (dwarf2_per_objfile) <index_cache_res>: New
field.
* dwarf2read.c (dwz_file) <index_cache_res>: New field.
(get_gdb_index_contents_from_cache): New.
(get_gdb_index_contents_from_cache_dwz): New.
(dwarf2_initialize_objfile): Read index from cache.
(dwarf2_build_psymtabs): Save to index.
* dwarf-index-cache.h: New file.
* dwarf-index-cache.c: New file.
* dwarf-index-write.h: New file.
gdb/testsuite/ChangeLog:
* boards/index-cache-gdb.exp: New file.
* gdb.dwarf2/index-cache.exp: New file.
* gdb.dwarf2/index-cache.c: New file.
* gdb.base/maint.exp: Check if we are using the index cache.
The following patch makes use of the mkdir function. Import the mkdir
gnulib module to ensure proper operation on all platforms.
gdb/ChangeLog:
* gnulib/aclocal.m4: Re-generate.
* gnulib/config.in: Re-generate.
* gnulib/configure: Re-generate.
* gnulib/import/Makefile.am: Re-generate.
* gnulib/import/Makefile.in: Re-generate.
* gnulib/import/m4/gnulib-cache.m4: Re-generate.
* gnulib/import/m4/gnulib-comp.m4: Re-generate.
* gnulib/import/m4/mkdir.m4: New file.
* gnulib/import/mkdir.c: New file.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add mkdir
module.
New in v2:
- As Tom pointed out, we don't need to keep the fd around after
mmapping. This simplifies things quite a bit, since we don't need a
new class. It's now just a function that returns a scoped_mmap.
We already have scoped_mmap, which is a thin RAII layer over mmap. If
one simply wants to mmap an entire file for reading, it takes a bit of
boilerplate. This patch introduces the mmap_file function to make this
easier.
gdb/ChangeLog:
* Makefile.in (COMMON_SFILES): Add common/scoped_mmap.c.
* common/scoped_mmap.c: New file.
* common/scoped_mmap.h (destroy): New method.
(~scoped_mmap, reset): Use destroy.
(scoped_mmap): New move constructor.
(mmap_file): New declaration.
* unittests/scoped_mmap-selftests.c (test_normal,
test_invalid_filename, run_tests): New functions.
(_initialize_scoped_mmap_selftests): Register selftest.
New in v3:
- Remove changed to dwarf-5 functions.
The read_gdb_index_from_section and read_debug_names_from_section
functions read the index content, as their names state, from sections of
object files. A following patch will make it possible to read index
content from standalone files.
This patch therefore decouples the code that reads the index content
from the code that processes that content. Functions
dwarf2_read_gdb_index and dwarf2_read_debug_names receive callbacks that
are responsible for providing the index contents (for both the main file
and the potential dwz file).
gdb/ChangeLog:
* dwarf2read.c (read_gdb_index_from_section): Rename to...
(read_gdb_index_from_buffer): ... this. Remove section
parameter, add buffer parameter.
(get_gdb_index_contents_ftype,
get_gdb_index_contents_dwz_ftype): New typedefs.
(dwarf2_read_gdb_index): Add callback parameters to get the
index contents.
(get_gdb_index_contents_from_section): New.
(dwarf2_initialize_objfile): Update call to
dwarf2_read_gdb_index.
I noticed that make -jN check would run make check-single when using GNU
make 4.2.1.
In the end, it turned out that this is due to this change from the make
4.2 NEWS file:
* The amount of parallelism can be determined by querying MAKEFLAGS, even when
the job server is enabled (previously MAKEFLAGS would always contain only
"-j", with no number, when job server was enabled).
The fix is trivial: just accept an optional arg to -j in Makefile.in
(saw_dash_j). Tested on i386-pc-solaris2.11 with just make and make
-j/-jN with both make 3.82 and 4.2.1.
* Makefile.in (saw_dash_j): Allow for GNU make 4.2+ passing -jN in
MAKEFLAGS.
This patch generates EH info for the new _notoc linkage stubs, to
support unwinding from asynchronous signal handlers. Unwinding
through the __tls_get_addr_opt stub was already supported, but that
was just a single stub. With multiple stubs the EH opcodes need to be
emitted and sized when iterating over stubs, so this is done when
emitting and sizing the stub code. Emitting the CIEs and FDEs is done
when sizing the stubs, as we did before in order to have the linker
generated FDEs indexed in .eh_frame_hdr. I moved the final tweaks to
FDEs from ppc64_elf_finish_dynamic_sections to ppc64_elf_build_stubs
simply because it's tidier to be done with them at that point.
bfd/
* elf64-ppc.c (struct map_stub): Delete tls_get_addr_opt_bctrl.
Add lr_restore, eh_size and eh_base.
(eh_advance, eh_advance_size): New functions.
(build_tls_get_addr_stub): Emit EH info for stub.
(ppc_build_one_stub): Likewise for _notoc stubs.
(ppc_size_one_stub): Size EH info for stub.
(group_sections): Init new map_stub fields.
(stub_eh_frame_size): Delete.
(ppc64_elf_size_stubs): Size EH info for stubs. Set up dummy EH
program for stubs.
(ppc64_elf_build_stubs): Reinit new map_stub fields. Set FDE
offset to stub section here..
(ppc64_elf_finish_dynamic_sections): ..rather than here.
ld/
* testsuite/ld-powerpc/notoc.s: Generate some cfi.
* testsuite/ld-powerpc/notoc.d: Adjust.
* testsuite/ld-powerpc/notoc.wf: New file.
* testsuite/ld-powerpc/powerpc.exp: Run "ext" and "notoc" tests
as run_ld_link_tests rather than run_dump_test.
This patch fixes a bug in the handling of the __tls_get_addr_opt
stub. Calls via this stub don't have a toc restoring instruction
following the "bl", and the stub itself doesn't have an initial toc
save instruction. Thus it is incorrect to skip over the first
instruction when a __tls_get_addr call is marked with a tocsave
reloc.
* elf64-ppc.c (ppc64_elf_relocate_section): Don't skip first
instruction of __tls_get_addr_opt stub.
(plt_stub_size): Omit ALWAYS_EMIT_R2SAVE condition when
dealing with __tls_get_addr_opt stub.
(build_tls_get_addr_stub, ppc_size_one_stub): Likewise.
PR 23481
* config/tc-pdp11.c (parse_op_noreg): Check for deferred register
addressing before assuming non-deferred addressing.
* testsuite/gas/pdp11/pr23481.s: New test source file.
* testsuite/gas/pdp11/pr23481.d: New test driver file.
* testsuite/gas/pdp11/pdp11.exp: Run the new test.
A recent patch introduced a few of these:
/home/emaisin/src/binutils-gdb/gdb/remote.c:12862:19: error: format not a string literal and no format arguments [-Werror=format-security]
error (err_msg);
^
Fix them by replacing the call to error with
error ("%s", err_msg);
gdb/ChangeLog:
* remote.c (remote_target::download_tracepoint): Fix format
string errors.
gold/
* target.h (Sized_target::record_gnu_property): Change first two
parameters to unsigned int.
* x86_64.cc (Target_x86_64::record_gnu_property): Likewise.
The tracefile.c:trace_save function assumes trace_regblock_size won't
be larger than the MAX_TRACE_UPLOAD constant, used to size the buffer
which holds trace data. This can cause buffer overruns when this is
not the case. This patch changes this function so that the larger
size is used to size the buffer.
gdb/ChangeLog:
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* tracefile.c: Include common/byte-vector.h.
(trace_save): Change type of buf to gdb::byte_vector. Initialize
with trace_regblock_size if needed. Update uses of buf.
This patch changes collection_list to allow larger register masks.
The mask is changed from an array to a vector and is initialized to
hold the maximum possible remote register number. The stringify
method is updated to resize temp_buf if needed.
gdb/ChangeLog:
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* tracepoint.h (collection_list) <m_regs_mask>: Change type to
std::vector<unsigned char>.
* tracepoint.c (collection_list::collection_list): Remove
m_regs_mask initializer from initializer list. Resize
m_regs_mask using the largest remote register number.
(collection_list::add_remote_register): Remove size check on
m_regs_mask. Use at to access element.
(collection_list::stringify): Change type of temp_buf to
gdb::char_vector. Update uses of temp_buf. Resize if needed to
stringify the register mask. Use pack_hex_byte for the register
mask.
Currently, tracepoint register masks in the QTDP packets include both
internal and remote register numbers, as well as pseudo-register
numbers.
This patch changes this so that the mask only includes remote register
numbers.
Register numbers from agent expressions are already set in the mask
using remote numbers. Other tracepoint actions used internal numbers,
e.g. "collect $regs" or "collect $<pseudoreg>". To handle pseudoreg
numbers, an empty agent expression is created and ax_reg_mask is
called for this expression and the pseudoreg. This will cause the ax
to set its mask with the corresponding remote raw register
numbers (using ax_regs_mask, which calls
gdbarch_ax_pseudo_register_collect).
If ax_regs_mask and gdbarch_ax_pseudo_register_collect also generate
more ax bytecode, the ax is also appended to the collection list. It
isn't clear that this was the original intent for
gdbarch_ax_pseudo_register_collect, and none of the arches seem to do
this, but if this changes in the future, it should work.
The patch also refactors the code used by validate_action line to
validate axs into a function that is now called from every place that
generates axs. Previously, some parts of tracepoint.c that generated
axs didn't check if the ax length was greater than MAX_AGENT_EXPR_LEN.
gdb/ChangeLog:
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* tracepoint.h (class collection_list) <add_register>: Remove.
<add_remote_register, add_ax_registers, add_local_register>:
Declare.
<add_memrange>: Add scope parameter.
* tracepoint.c (encode_actions_1): Likewise.
(collection_list::add_register): Rename to ...
(collection_list::add_remote_register): ... this. Update
comment.
(collection_list::add_ax_registers, add_local_register): New
methods.
(collection_list::add_memrange): Add scope parameter. Call
add_local_register instead of add_register.
(finalize_tracepoint_aexpr): New function.
(collection_list::collect_symbol): Update calls to add_memrange.
Call add_local_register instead of add_register. Call
add_ax_registers. Call finalize_tracepoint_aexpr.
(encode_actions_1): Get remote regnos for $reg action. Call
add_remote_register, add_ax_registers, and add_local_register.
Update call to add_memrange. Call finalize_tracepoint_aexpr.
(validate_actionline): Call finalize_tracepoint_aexpr.