Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Introduce find_function_entry_range_from_pc and use it in infrun.c
An earlier version of this patch used the returned block in conjunction
with BLOCK_ENTRY_PC to set stop_func_start in fill_in_stop_func() in
infrun.c. While I think this was the correct thing to do, changes
to find_inferior_partial_function could potentially end up with
stop_func_end < stop_func_start, which is definitely wrong. For
this case, we want to set both stop_func_start and stop_func_end
to the start and end of the range containing the function's entry
pc.
I think that this functionality will be useful in many other places
too - it probably ought to be used in all of the various prologue
analyzers in GDB.
The change to infrun.c was simple: the call to
find_pc_partial_function was replaced with a call to
find_function_entry_range_from_pc. The difference between these two
functions is that find_pc_partial_entry_function will (potentially)
return the start and end address corresponding to the range in which
PC is found, but find_function_entry_range_from_pc will (again,
potentially) return the start and end address of the range containing
the entry pc. find_pc_partial_function has the property that
*ADDRESS <= PC < *ENDADDR. This condition does not necessarily hold
for the outputs of find_function_entry_range_from_pc.
It should be noted that for functions which contain only a single
range, the outputs of find_pc_partial_function and
find_function_entry_range_from_pc are identical.
I think it might happen that find_function_entry_range_from_pc will come
to be used in place of many of the calls to find_pc_partial_function
within GDB. Care must be taken in making this change, however, since
some of this code depends on the *ADDRESS <= PC < *ENDADDR property.
Finally, a note regarding the name: I had initially chosen a different
name with a find_pc_partial_ prefix, but Simon suggested the current
name citing the goal of eventually making naming consistent using
the form find_X_from_Y. In this case X is "function_entry_range" and
Y is "pc". Both the name and rationale made sense to me, so that's
how it came to be.
gdb/ChangeLog:
* infrun.c (fill_in_stop_func): Use find_function_entry_range_from_pc
in place of find_pc_partial_function.
* blockframe.c (find_function_entry_range_from_pc): New function.
* symtab.h (find_function_entry_range_from_pc): Declare and document.
Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Use BLOCK_ENTRY_PC in place of most uses of BLOCK_START
This change/patch substitues BLOCK_ENTRY_PC for BLOCK_START in
places where BLOCK_START is used to obtain the address at which
execution should enter the block. Since blocks can now contain
non-contiguous ranges, the BLOCK_START - which is still be the
very lowest address in the block - might not be the same as
BLOCK_ENTRY_PC.
There is a change to infrun.c which is less obvious and less mechanical.
I'm posting it as a separate patch.
gdb/ChangeLog:
* ax-gdb.c (gen_var_ref): Use BLOCK_ENTRY_PC in place of
BLOCK_START.
* blockframe.c (get_pc_function_start): Likewise.
* compile/compile-c-symbols.c (convert_one_symbol): Likewise.
(gcc_symbol_address): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (get_expr_block_and_pc): Likewise.
* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
(func_addr_to_tail_call_list): Likewise.
* findvar.c (default_read_var_value): Likewise.
* inline-frame.c (inline_frame_this_id): Likewise.
(skip-inline_frames): Likewise.
* infcmd.c (until_next_command): Likewise.
* linespec.c (convert_linespec_to_sals): Likewise.
* parse.c (parse_exp_in_context_1): Likewise.
* printcmd.c (build_address_symbolic): likewise.
(info_address_command): Likewise.
symtab.c (find_function_start_sal): Likewise.
(skip_prologue_sal): Likewise.
(find_function_alias_target): Likewise.
(find_gnu_ifunc): Likewise.
* stack.c (find_frame_funname): Likewise.
* symtab.c (fixup_symbol_section): Likewise.
(find_function_start_sal): Likewise.
(skip_prologue_sal): Likewsie.
(find_function_alias_target): Likewise.
(find_gnu_ifunc): Likewise.
* tracepoint.c (info_scope_command): Likewise.
* value.c (value_fn_field): Likewise.
Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Disassemble blocks with non-contiguous ranges
This patch adds support for disassembly of blocks with non-contiguous
ranges. These blocks are printed as follows:
(gdb) disassemble foo
Dump of assembler code for function foo:
Address range 0x401136 to 0x401151:
0x0000000000401136 <+0>: push %rbp
0x0000000000401137 <+1>: mov %rsp,%rbp
0x000000000040113a <+4>: callq 0x401134 <bar>
0x000000000040113f <+9>: mov 0x2eef(%rip),%eax # 0x404034 <e>
0x0000000000401145 <+15>: test %eax,%eax
0x0000000000401147 <+17>: je 0x40114e <foo+24>
0x0000000000401149 <+19>: callq 0x401128 <foo+
4294967282>
0x000000000040114e <+24>: nop
0x000000000040114f <+25>: pop %rbp
0x0000000000401150 <+26>: retq
Address range 0x401128 to 0x401134:
0x0000000000401128 <+-14>: push %rbp
0x0000000000401129 <+-13>: mov %rsp,%rbp
0x000000000040112c <+-10>: callq 0x401126 <baz>
0x0000000000401131 <+-5>: nop
0x0000000000401132 <+-4>: pop %rbp
0x0000000000401133 <+-3>: retq
End of assembler dump.
This is an actual dump from the test case that I constructed for
this work. The ranges are printed in the order encountered in the
debug info. For the above example, note that the second range occupies
lower addresses than the first range.
Functions with contiguous ranges are still printed as follows:
(gdb) disassemble main
Dump of assembler code for function main:
0x0000000000401151 <+0>: push %rbp
0x0000000000401152 <+1>: mov %rsp,%rbp
0x0000000000401155 <+4>: callq 0x401136 <foo>
0x000000000040115a <+9>: mov $0x0,%eax
0x000000000040115f <+14>: pop %rbp
0x0000000000401160 <+15>: retq
End of assembler dump.
gdb/ChangeLog:
* cli/cli-cmds.c (block.h): Include.
(print_disassembly): Handle printing of non-contiguous blocks.
(disassemble_current_function): Likewise.
(disassemble_command): Likewise.
Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Add support for non-contiguous blocks to find_pc_partial_function
This change adds an optional output parameter BLOCK to
find_pc_partial_function. If BLOCK is non-null, then *BLOCK will be
set to the address of the block corresponding to the function symbol
if such a symbol was found during lookup. Otherwise it's set to the
NULL value. Callers may wish to use the block information to
determine whether the block contains any non-contiguous ranges. The
caller may also iterate over or examine those ranges.
When I first started looking at the broken stepping behavior associated
with functions w/ non-contiguous ranges, I found that I could "fix"
the problem by disabling the find_pc_partial_function cache. It would
sometimes happen that the PC passed in would be between the low and
high cache values, but would be in some other function that happens to
be placed in between the ranges for the cached function. This caused
incorrect values to be returned.
So dealing with this cache turns out to be very important for fixing
this problem. I explored three different ways of dealing with the
cache.
My first approach was to clear the cache when a block was encountered
with more than one range. This would cause the non-cache pathway to
be executed on the next call to find_pc_partial_function.
Another approach, which I suspect is slightly faster, checks to see
whether the PC is within one of the ranges associated with the cached
block. If so, then the cached values can be used. It falls back to
the original behavior if there is no cached block.
The current approach, suggested by Simon Marchi, is to restrict the
low/high pc values recorded for the cache to the beginning and end of
the range containing the PC value under consideration. This allows us
to retain the simple (and fast) test for determining whether the
memoized (cached) values apply to the PC passed to
find_pc_partial_function.
Another choice that had to be made regards setting *ADDRESS and
*ENDADDR. There are three possibilities which might make sense:
1) *ADDRESS and *ENDADDR represent the lowest and highest address
of the function.
2) *ADDRESS and *ENDADDR are set to the start and end address of
the range containing the entry pc.
3) *ADDRESS and *ENDADDR are set to the start and end address of
the range in which PC is found.
An earlier version of this patch implemented option #1. I found out
that it's not very useful though and, in fact, returns results that
are incorrect when used in the context of determining the start and
end of the function for doing prologue analysis. While debugging a
function in which the entry pc was in the second range (of a function
containing two non-contiguous ranges), I noticed that
amd64_skip_prologue called find_pc_partial_function - the returned
start address was set to the beginning of the first range. This is
incorrect for this function. What was also interesting was that this
first invocation of find_pc_partial_function correctly set the cache
for the PC on which it had been invoked, but a slightly later call
from skip_prologue_using_sal could not use this cached value because
it was now being used to lookup the very lowest address of the
function - which is in a range not containing the entry pc.
Option #2 is attractive as it would provide a desirable result
when used in the context of prologue analysis. However, many callers,
including some which do prologue analysis want the condition
*ADDRESS <= PC < *ENDADDR to hold. This will not be the case when
find_pc_partial_function is called on a PC that's in a non-entry-pc
range. A later patch to this series adds
find_function_entry_range_from_pc as a wrapper of
find_pc_partial_function.
Option #3 causes the *ADDRESS <= PC < *ENDADDR property to hold. If
find_pc_partial_function is called with a PC that's within entry pc's
range, then it will correctly return the limits of that range. So, if
the result of a minsym search is passed to find_pc_partial_function
to find the limits, then correct results will be achieved. Returned
limits (for prologue analysis) won't be correct when PC is within some
other (non-entry-pc) range. I don't yet know how big of a problem
this might be; I'm guessing that it won't be a serious problem - if a
compiler generates functions which have non-contiguous ranges, then it
also probably generates DWARF2 CFI which makes a lot of the old
prologue analysis moot.
I've implemented option #3 for this version of the patch. I don't see
any regressions for x86-64. Moreover, I don't expect to see
regressions for other targets either simply because
find_pc_partial_function behaves the same as it did before for the
contiguous address range case. That said, there may be some
adjustments needed if GDB encounters a function requiring prologue
analysis which occupies non-contiguous ranges.
gdb/ChangeLog:
* symtab.h (find_pc_partial_function): Add new parameter `block'.
* blockframe.c (cache_pc_function_block): New static global.
(clear_pc_function_cache): Clear cache_pc_function_block.
(find_pc_partial_function): Move comment to symtab.h. Add
support for non-contiguous blocks.
Kevin Buettner [Thu, 23 Aug 2018 23:00:49 +0000 (16:00 -0700)]
Record explicit block ranges from dwarf2read.c
This change sets BLOCK_RANGES for the block under consideration by
calling make_blockranges(). This action is performed in
dwarf2_record_block_ranges().
It should be noted that dwarf2_record_block_ranges() already does some
recording of the range via a call to record_block_range(). The ranges
recorded in that fashion end up in the address map associated with the
blockvector for the compilation unit's symtab. Given an address, the
addrmap provides a fast way of finding the block containing that
address. The address map does not, however, provide a convenient way
of determining which address ranges make up a particular block.
While reading a set of ranges, a vector of pairs is used to collect
the starting and ending addresses for each range in the block. Once
all of the ranges for a block have been collected, make_blockranges()
is called to fill in BLOCK_RANGES for the block.
The ranges are stored for the block in the order that they're read
from the debug info. For DWARF, the starting address of the first
range of the block will be the entry pc in cases where DW_AT_entry_pc
is not present. (Well, that would ideally be the case. At the moment
DW_AT_entry_pc is not being handled.)
gdb/ChangeLog:
* dwarf2read.c (dwarf2_record_block_ranges): Fill in BLOCK_RANGES
for block.
Kevin Buettner [Thu, 23 Aug 2018 23:00:48 +0000 (16:00 -0700)]
Add block range data structure for blocks with non-contiguous address ranges
This patch does the following:
- Introduces a block range data structure which is accessed via
a new field in struct block.
- Defines several macros for accessing block ranges.
- Defines a new function, make_blockrange, which is responsible for
creating the new data structure.
It should be noted that some support for non-contiguous ranges already
existed in GDB in the form of blockvector addrmaps. This support
allowed GDB to quickly find a block containing a particular address
even when the block consists of non-contiguous addresses. See
find_block_in_blockvector() in block.c, dwarf2_record_block_ranges()
in dwarf2read.c, and record_block_range() in buildsym.c.
Addrmaps do not provide a convenient way to examine address ranges
associated with a particular block. This data structure (and its
interface) is set up for quickly finding the value (which in this case
is a block) associated with a particular address. The interface
does not include a method for doing a reverse mapping from blocks to
addresses. A linear time mapping might be attempted via use of the
addrmap's foreach method, but this is not as straightforward as it
might first appear due to the fact that blocks corresponding to inline
function instances and lexical blocks w/ variables end up getting
interspersed in in the set of transitions.
Note: If this approach is deemed to be too expensive in terms of
space, an alternate approach might be to attempt the linear time
mapping noted above. find_pc_partial_function() needs to be able to
quickly know whether there are discontiguous ranges, so a flag for
this property would have to be added to struct block. Also integral
to this set of changes is the concept of an "entry pc" which might be
different from the block's start address. An entry_pc field would
also need to be added to struct block. This does not result in any
space savings in struct block though since the space for the flag and
entry_pc use more space than the blockranges struct pointer that I've
added. There would, however, be some space savings due to the fact
that the new data structures that I've added for this patch would not
need to be allocated. (I happen to like the approach I've come up
with, but I wanted to mention another possibility just in case someone
does not.)
gdb/ChangeLog:
* block.h (blockrange, blockranges): New struct declarations.
(struct block): Add new field named `ranges'.
(BLOCK_RANGES, BLOCK_NRANGES, BLOCK_RANGE, BLOCK_CONTIGUOUS_P)
(BLOCK_RANGE_START, BLOCK_RANGE_END, BLOCK_ENTRY_PC): New
macros for accessing ranges in struct block.
(make_blockranges): New declaration.
block.c (make_blockranges): New function.
Jim Wilson [Thu, 23 Aug 2018 20:26:48 +0000 (13:26 -0700)]
RISC-V: Reject empty rouding mode and fence operand.
gas/
2018-08-23 Kito Cheng <kito@andestech.com>
* config/tc-riscv.c (arg_lookup): Checking
length before look up.
* testsuite/gas/riscv/fence-fail.d: New file.
* testsuite/gas/riscv/fence-fail.l: Likewise.
* testsuite/gas/riscv/fence-fail.s: Likewise.
* testsuite/gas/riscv/rouding-fail.d: Likewise.
* testsuite/gas/riscv/rouding-fail.l: Likewise.
* testsuite/gas/riscv/rouding-fail.s: Likewise.
Zenith423 [Thu, 23 Aug 2018 15:22:56 +0000 (16:22 +0100)]
Avoid problems with plugins being loaded multiple times.
PR 23460
* plugin.c (struct plugin_list_entry): New structure.
(plugin_list): New variable.
(try_load_plugin): Place opened plugins on a list. Ensure that
the refcount in the dynamic loader is kept at 1.
Xavier Roirand [Thu, 23 Aug 2018 15:17:03 +0000 (11:17 -0400)]
Darwin: fix bad loop incrementation
When reading symbols from the vector of oso files on Mac OS X
Darwin, a previous commit introduce a change in the loop and add
an increment at each loop iteration whereas this incrementation is
not needed since the increment or set of the loop control variable
is already done in the loop.
gdb/ChangeLog:
* machoread.c (macho_symfile_read_all_oso): Remove uneeded
incrementation.
Change-Id: I3a5a6deb4e9d834ee7d4217a62d90c2ffb7241bc
Alan Modra [Thu, 23 Aug 2018 14:50:05 +0000 (00:20 +0930)]
PR23566, false uninitialized warning
PR 23566
* emultempl/elf32.em (before_allocation): Warning fix.
Alan Modra [Thu, 23 Aug 2018 14:45:35 +0000 (00:15 +0930)]
PowerPC64 "call lacks nop"
The "-fPIC" and "-mcmodel=small" parts of these messages isn't always
true, so lets dispense with that and just report the type of stub
causing trouble.
* elf64-ppc.c (ppc64_elf_relocate_section): Revise "call lacks
nop" error message.
Alan Modra [Thu, 23 Aug 2018 08:04:13 +0000 (17:34 +0930)]
PowerPC64 st_other decoding in readelf
localentry:1 is a valid encoding, so display it. The patch also bails
out of get_ppc64_symbol_other when st_other bits besides the three
used for localentry offsets are set, to avoid hiding any such values.
* readelf.c (get_ppc64_symbol_other): Return NULL if st_other
field contains unrecognised or reserved values. Handle
localentry:1 value.
H.J. Lu [Thu, 23 Aug 2018 13:12:37 +0000 (06:12 -0700)]
Prune BFD warnings for unknown GNU properties
When glibc is enabled with the new GNU_PROPERTY_X86_XXX bits:
https://groups.google.com/forum/#!topic/x86-64-abi/-D05GQ3kWrA
BFD will issue an unknown GNU property warning like
warning: tmpdir/ld1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0010001
and ignore such GNU properties. This patch adds prune_warnings_extra to
prune such warnings on release branches and updates prune_warnings to
call prune_warnings_extra.
binutils/
PR ld/23536
* Makefile.am (development.exp): New target.
(EXTRA_DEJAGNU_SITE_CONFIG): New.
(DISTCLEANFILES): Add development.exp.
* Makefile.in: Regenerated.
* testsuite/binutils-all/objcopy.exp (strip_test): Call
prune_warnings to prune BFD output.
(strip_test_with_saving_a_symbol): Likewise.
(objcopy_test_without_global_symbol): Likewise.
* testsuite/lib/binutils-common.exp (prune_warnings_extra):
New proc.
(prune_warnings): Likewise.
gas/
PR ld/23536
* Makefile.am (development.exp): New target.
(EXTRA_DEJAGNU_SITE_CONFIG): New.
(DISTCLEANFILES): Add development.exp.
* Makefile.in: Regenerated.
ld/
PR ld/23536
* Makefile.am (development.exp): New target.
(EXTRA_DEJAGNU_SITE_CONFIG): New.
(DISTCLEANFILES): Add development.exp.
* Makefile.in: Regenerated.
* testsuite/ld-bootstrap/bootstrap.exp: Call prune_warnings to
prune BFD output.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/lib/ld-lib.exp (prune_warnings): Removed.
* testsuite/ld-elf/shared.exp: Allow "\n" in linker warnings.
H.J. Lu [Thu, 23 Aug 2018 12:56:03 +0000 (05:56 -0700)]
Document setting experimental on release branch.
* README-how-to-make-a-release: Document setting "experimental"
to false.
Nick Clifton [Thu, 23 Aug 2018 12:34:14 +0000 (13:34 +0100)]
Replace unworkable code in HPPA relocs handelr with an assertion.
* elf64-hppa.c (elf_hppa_final_link_relocate): Replace unworkable
code with an assertion.
Nick Clifton [Thu, 23 Aug 2018 10:45:38 +0000 (11:45 +0100)]
Prevent illegal memory access when processing COFF auxillary symbol information.
PR 23061
* coffgen.c (coff_pointerize_aux): Add table_end parameter. Use
it to prevent walking off the end of the table.
(coff_get_normalized_symtab): Pass internal_end pointer to
coff_pointerize_aux.
Alan Modra [Thu, 23 Aug 2018 04:04:29 +0000 (13:34 +0930)]
Fix "unresolved reloc" error for NOTOC relocs
* elf64-ppc.c (ppc64_elf_relocate_section): Don't miss clearing
unresolved_reloc on ppc_stub_plt_call_notoc.
GDB Administrator [Thu, 23 Aug 2018 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Wed, 22 Aug 2018 18:18:08 +0000 (14:18 -0400)]
Make read_program_headers_from_bfd return a gdb::byte_vector
This patch makes read_program_headers_from_bfd return a gdb::byte_vector
instead of a plain pointer.
gdb/ChangeLog:
* solib-svr4.c (read_program_headers_from_bfd): Return
gdb::optional<gdb::byte_vector>.
(svr4_exec_displacement): Adjust.
Simon Marchi [Wed, 22 Aug 2018 18:17:57 +0000 (14:17 -0400)]
Make read_program_header return a gdb::byte_vector
While reading a recent patch, I found this spot where a gdb::byte_vector
could be used instead of an allocated buffer returned as a plain
pointer.
gdb/ChangeLog:
* solib-svr4.c (read_program_header): Return
gdb::optional<gdb::byte_vector>, remove p_sect_size param.
(find_program_interpreter): Return
gdb::optional<gdb::byte_vector>.
(scan_dyntag_auxv): Adjust.
(enable_break): Adjust.
(svr4_exec_displacement): Adjust.
Simon Marchi [Wed, 22 Aug 2018 17:37:05 +0000 (13:37 -0400)]
Restore behavior of disabling address randomization by default on GDBserver
Commit
c12a508 ("Add client_state struct.")
inadvertently changed the default behavior of GDBserver wrt address
randomization. The old disable_randomization global variable was
initialized to 1, whereas the corresponding field in the client_state
structure is initialized to 0.
This fixes
make check TESTS="gdb.base/jit-simple.exp" RUNTESTFLAGS="--target_board=native-gdbserver"
make check TESTS="gdb.base/execl-update-breakpoints.exp" RUNTESTFLAGS="--target_board=native-gdbserver"
Note that the execl-update-breakpoints.exp would only fail on systems
where the toolchain emits position-independent executables by default
(otherwise the main executable position is never randomized, so the
value of disable_randomization didn't matter).
gdb/gdbserver/ChangeLog:
PR gdb/23374
PR gdb/23375
* server.h (struct client_state) <disable_randomization>:
Initialize to 1.
H.J. Lu [Wed, 22 Aug 2018 17:32:08 +0000 (10:32 -0700)]
bfd/development.sh: Add experimental
Add experimental to indicate whether this is a release branch.
PR ld/23536
* development.sh (experimental): New.
Simon Marchi [Wed, 22 Aug 2018 15:09:45 +0000 (11:09 -0400)]
Fix restoring of inferior terminal settings
I noticed that the child_terminal_save_inferior function was not used
since the commit
f6ac5f3d63e0 ("Convert struct target_ops to C++"). I
was able to make a little test program to illustrate the problem (see
test case).
I think we're just missing the override of the terminal_save_inferior
method in inf_child_target (along with the other terminal-related
methods).
Instead of creating a new test, I thought that gdb.base/term.exp was a
good candidate for testing that gdb restores properly the inferior's
terminal settings.
gdb/ChangeLog:
* inf-child.h (inf_child_target) <terminal_save_inferior>: New.
* inf-child.c (inf_child_target::terminal_save_inferior): New.
gdb/testsuite/ChangeLog:
* gdb.base/term.exp: Compare terminal settings with values from
the inferior.
* gdb.base/term.c: Get and set terminal settings.
Simon Marchi [Wed, 22 Aug 2018 14:55:28 +0000 (10:55 -0400)]
Replace xstrvprintf usages with string_vprintf
Most usages of xstrvprintf in GDB can be replaced with string_vprintf,
removing some manual memory management.
gdb/ChangeLog:
* guile/scm-string.c (gdbscm_scm_from_printf): Use
string_vprintf.
* guile/scm-utils.c (gdbscm_printf): Likewise.
* serial.c (serial_printf): Likewise.
* xml-support.c (gdb_xml_parser::vdebug): Likewise.
Jan Vrany [Wed, 22 Aug 2018 09:42:38 +0000 (10:42 +0100)]
MI: Print frame architecture when printing frames on an MI channel
When printing frames on an MI channel also print the frame
architecture like in:
(gdb)
-stack-list-frames 3 3
^done,stack=
[frame={level="3",addr="0x000107a4",func="foo",
file="recursive2.c",fullname="/home/foo/bar/recursive2.c",
line="14",arch="i386:x86_64"}]
(gdb)
This is useful for MI clients that need to know the architecture in
order to perform further analysis, for example to use their own
disassembler to analyze machine code.
gdb/Changelog:
2018-08-22 Jan Vrany <jan.vrany@fit.cvut.cz>
* stack.c (print_frame): Print frame architecture when printing on
an MI output.
* NEWS: Mention new "arch" attribute in frame output.
gdb/testsuite/Changelog
2018-08-22 Jan Vrany <jan.vrany@fit.cvut.cz>
* lib/mi-support.exp (mi_expect_stop): Update regexp to
accommodate new "arch" field in frame output.
* gdb.mi/mi-return.exp: Likewise.
* gdb.mi/mi-stack.exp: Likewise.
* gdb.mi/mi-syn-frame.exp: Likewise.
* gdb.mi/user-selected-context-sync.exp: Likewise.
gdb/doc/Changelog
2018-08-22 Jan Vrany <jan.vrany@fit.cvut.cz>
* gdb.texinfo (The -stack-list-frames Command): Update description
to mention "arch".
Update MI examples throughout the document to contain "arch" in
frame output.
Helge Deller [Wed, 22 Aug 2018 09:32:53 +0000 (10:32 +0100)]
Use the correct constants when setting the section type of HPPA unwind sections.
* elf-hppa.h (elf_hppa_fake_sections): Use SHT_PARISC_UNWIND as
the section type of the .PARISC.unwind section on 64-bit binaries
and SHT_PROGBITS for 32-bit binaries. Add a comment about it.
Add comment about the sh_entsize value.
Rafeal Auler [Wed, 22 Aug 2018 09:04:09 +0000 (10:04 +0100)]
Fix AArch64 stub layout algorithm to allow for the fact that section layut might change a stub's target location.
PR 23560
* elfnn-aarch64.c (elfNN_aarch64_size_stubs): Always update the
stub's target, since it may have been changed after the layout.
Nick Clifton [Wed, 22 Aug 2018 08:58:32 +0000 (09:58 +0100)]
Fix typo in changelog entry for handling of undocumnented Z80 SLI instruction.
Alan Hayward [Wed, 22 Aug 2018 08:22:12 +0000 (09:22 +0100)]
Aarch64 SVE VG is Vector Granule
...not Vector Gradient.
See: DWARF for the ARM® 64-bit Architecture (AArch64) with SVE support
gdb/
* arch/aarch64.h (aarch64_regnum): Update comment.
Alan Hayward [Wed, 22 Aug 2018 08:17:24 +0000 (09:17 +0100)]
Add AArch64 SVE to NEWS and GDB manual
gdb/
* NEWS: Add SVE to 8.2 section.
gdb/doc/
* doc/gdb.texinfo (AArch64 SVE): New subsubsection.
Alan Modra [Wed, 22 Aug 2018 07:07:56 +0000 (16:37 +0930)]
Fix changelog entries
Alan Modra [Wed, 22 Aug 2018 04:41:56 +0000 (14:11 +0930)]
Re: Pack reloc_howto_struct
Fix fallout when using gcc-4.
* dw2gencfi.c (emit_expr_encoded, output_fde): Warning fixes.
Alan Modra [Wed, 22 Aug 2018 00:34:58 +0000 (10:04 +0930)]
Correct readelf e_shstrndx range check
Fixes a bogus out of range error:
Number of section headers: 0 (210016)
Section header string table index: 1 <corrupt: out of range>
Caused due to e_shnum remaining as zero rather than being updated to
the value from section_header[0].sh_info at the point where we range
check e_shstrndx.
* readelf.c (process_file_header): Assign updated values from
section_header[0] fields to e_phnum, e_shnum and e_shstrndx
during printing of header. Correct e_shstrndx range check.
Remove unnecessary casts and use %u rather than %ld for
unsigned int header fields. Don't print a random %lx when
reporting an unknown EI_VERSION.
GDB Administrator [Wed, 22 Aug 2018 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in
John Darrington [Sun, 17 Jun 2018 05:04:11 +0000 (07:04 +0200)]
S12Z: Rename reloc R_S12Z_UKNWN_3 to R_S12Z_EXT18 and implement according to recently inferred information about this reloc.
* bfd/elf32-s12z.c: (opru18_reloc): New function.
* bfd/elf32-s12z.c: (elf_s12z_howto_table): Adjust Howto according to new knowledge.
* include/elf/s12z.h: Rename R_S12Z_UKNWN_3 to R_S12Z_EXT18.
Pedro Alves [Tue, 21 Aug 2018 15:48:30 +0000 (16:48 +0100)]
Don't throw Scheme exceptions with live std::vector objects
A complication with the Guile code is that we have two types of
exceptions to consider: GDB/C++ exceptions, and Guile/SJLJ exceptions.
Because Guile exceptions are SJLJ based, we must make sure to not have
live local variables of types with non-trivial dtors when a Guile
exception is thrown, because the dtors won't be run when a Guile
exceptions is thrown.
gdbscm_parse_function_args currently violates this:
void
gdbscm_parse_function_args (const char *func_name,
int beginning_arg_pos,
const SCM *keywords,
const char *format, ...)
{
...
/* Keep track of malloc'd strings. We need to free them upon error. */
std::vector<char *> allocated_strings;
...
for (char *ptr : allocated_strings)
xfree (ptr);
gdbscm_throw (status); /// dtor of "allocated_strings" is not run!
}
This commit fixes the above making using of gdbscm_wrap.
It would be nice if we had a way to make it impossible to write such
code. PR guile/23429 has an idea for that, if someone's interested.
gdb/ChangeLog:
2018-08-21 Pedro Alves <palves@redhat.com>
* guile/scm-utils.c (gdbscm_parse_function_args_1): New, factored
out from gdbscm_parse_function_args.
(gdbscm_parse_function_args): Rework to use gdbscm_wrap and
gdbscm_parse_function_args_1.
mephi42 [Tue, 21 Aug 2018 15:34:56 +0000 (16:34 +0100)]
Fix running objcopy on Mach-O binaries.
PR binutils/23315
* mach-o.c (bfd_mach_o_mangle_symbols): Update n_type even if
data is already considered filled.
Nick Clifton [Tue, 21 Aug 2018 15:15:36 +0000 (16:15 +0100)]
Update the documentation of the linker's --hash-style option.
PR 23426
* ld.texi (--hash-style): Note that the default is configurable
and that for most Linux based systems it will be "both".
Arnold Metselaar [Tue, 21 Aug 2018 14:50:49 +0000 (15:50 +0100)]
Fix handling of undocumented SLL instruction for the Z80 target.
* config/tc-z80.c: Correct treatment of undocumented instruction
sli/sll.
(emit_mr): Add argument unportable.
(emit_bit): Adapt call to emit_mr.
(emit_mr_z80): New function.
(emit_mr_unportable): New function.
(instab[]): Replace emit_mr with emit_mr_z80 or emit_mr_unportable
as appropriate.
Simon Marchi [Tue, 21 Aug 2018 14:47:47 +0000 (10:47 -0400)]
Remove unnecessary ternary operator in m32c-tdep.c
Bug 17816 pointed out a useless use of the ternary operator:
case 0x0: sd.reg = (size == 1 ? &st->r0 : &st->r0); break;
I believe that this is right. If size is 1, the instruction refers to
part of r0, while if size is 2, the instruction refers to the whole of
r0.
gdb/ChangeLog:
PR gdb/17816
* m32c-tdep.c (m32c_decode_srcdest4): Remove unnecessary ternary
operator.
Nick Clifton [Tue, 21 Aug 2018 14:41:59 +0000 (15:41 +0100)]
Note that Arnold Metselaar has retired as the z80 maintainer.
L. Simon [Tue, 21 Aug 2018 14:37:06 +0000 (15:37 +0100)]
Fix a seg-fault in readelf when parsing corrupt HPPA unwind tables.
PR 23531
* readelf.c (hppa_process_unwind): Only dump the unwind table if
the data was successfully read in.
Andreas Schwab [Mon, 20 Aug 2018 14:55:05 +0000 (16:55 +0200)]
Fix invalid strcpy on unterminated buffer
* read.c (do_repeat_with_expander): Use memmove instead of strcpy
on unterminated string buffer.
Alan Modra [Thu, 16 Aug 2018 06:44:12 +0000 (16:14 +0930)]
Use operand->extract to provide defaults for optional PowerPC operands
Most optional operands to powerpc instructions use a default value of
zero, but there are a few exceptions. Those have been handled by
PPC_OPERAND_OPTIONAL_VALUE and an entry in the powerpc_operands table
for the default value, smuggled in the shift field. This patch
changes that to using the operand extract function to provide non-zero
defaults.
I've also moved the code determining whether optional operands are
provided or omitted, to the point the first optional operand is seen,
and allowed for the possibility of optional base register operands
in a future patch.
The patch does change the error you get on invalid assembly like
ld 3,4
You'll now see "missing operand" rather than
"syntax error; end of line, expected `('".
gas/
* config/tc-ppc.c (md_assemble): Delay counting of optional
operands until one is encountered. Allow for the possibility
of optional base regs, ie. PPC_OPERAND_PARENS. Call
ppc_optional_operand_value with extra args.
include/
* opcode/ppc.h (struct powerpc_operand): Correct "insert" comment.
Mention use of "extract" function to provide default value.
(PPC_OPERAND_OPTIONAL_VALUE): Delete.
(ppc_optional_operand_value): Rewrite to use extract function.
opcodes/
* ppc-dis.c (operand_value_powerpc): Init "invalid".
(skip_optional_operands): Count optional operands, and update
ppc_optional_operand_value call.
* ppc-opc.c (extract_dxdn): Remove ATTRIBUTE_UNUSED from used arg.
(extract_vlensi): Likewise.
(extract_fxm): Return default value for missing optional operand.
(extract_ls, extract_raq, extract_tbr): Likewise.
(insert_sxl, extract_sxl): New functions.
(insert_esync, extract_esync): Remove Power9 handling and simplify.
(powerpc_operands <FXM4, TBR>): Delete PPC_OPERAND_OPTIONAL_VALUE
flag and extra entry.
(powerpc_operands <SXL>): Likewise, and use insert_sxl and
extract_sxl.
Alan Modra [Mon, 20 Aug 2018 05:53:38 +0000 (15:23 +0930)]
PowerPC HOWTOs
These take up far too many lines in the files. This patch introduces
a replacement for the HOWTO macro that simplifies the relow howto
initialization. Apart from the two relocs mentioned in the ChangeLog,
no relocation howto is changed.
* elf64-ppc.c (HOW): Define.
(ONES): Delete.
(ppc64_elf_howto_raw): Use HOW to initialize entries.
* elf32-ppc.c (HOW): Define.
(ppc_elf_howto_raw): Use HOW to initialize entries, updating
R_PPC_VLE_REL15 and R_PPC_VLE_REL24 to use bitpos=0.
Alan Modra [Tue, 21 Aug 2018 02:24:29 +0000 (11:54 +0930)]
Pack reloc_howto_struct
This patch uses bitfields in reloc_howto_struct, reducing its size
from 80 to 40 bytes on 64-bit hosts and from 52 to 32 bytes on 32-bit
hosts (with a 32-bit bfd_vma). I've also added a new "negate" field
rather than making the encoded "size" field do double duty as both
a size and a flag.
There was just one use of an encoded size of 8, which according to
bfd_get_reloc_size meant 16 bytes, in vms-alpha.c ALPHA_R_LINKAGE.
See git commit
c3d8e071bf adding ALPHA_R_LINKAGE and git commit
8612a388f7 decoding size 8 in bfd_get_reloc_size. Since no other part
of BFD handles 16 byte relocs, I've removed that encoding and special
cased the ALPHA_R_LINKAGE size in vms-alpha.c.
* reloc.c (reloc_howto_type): Typedef.
(bfd_symbol): Delete forward declaration.
(struct reloc_howto_struct): Add "negate" field. Make "size",
"bitsize", "rightshift", "bitpos", "complain_on_overflow",
"pc_relative", "partial_inplace", and "pcrel_offset" bitfields.
Rearrange for better packing. Revise comments.
(HOWTO): Map to rearranged reloc_howto_struct.
(bfd_get_reloc_size): Delete now unused cases.
(read_reloc, write_reloc): Likewise.
(apply_reloc, _bfd_relocate_contents): Test howto->negate
rather than howto->size < 0 for negated relocation values.
* coff-rs6000.c (xcoff_complain_overflow_bitfield_func): Avoid
signed/unsigned warning.
(xcoff_ppc_relocate_section): Delete "condition is always false"
code.
* coff64-rs6000.c (xcoff64_ppc_relocate_section): Likewise.
* cpu-ns32k.c (do_ns32k_reloc): Adjust to suit reloc_howto_struct
changes.
* vms-alpha.c (_bfd_vms_write_etir, alpha_vms_slurp_relocs): Use
size 16 for ALPHA_R_LINKAGE.
(alpha_howto_table <ALPHA_R_LINKAGE>): Set encoded size and
bitsize to zero.
* bfd-in.h (reloc_howto_type): Delete.
* bfd-in2.h: Regenerate.
Alan Modra [Mon, 20 Aug 2018 10:06:05 +0000 (19:36 +0930)]
Delete NEWHOWTO and tidy some uses of reloc_howto_struct
NEWHOWTO was promised way back in 1991 (git commit
e5683622186).
I doubt it's ever going to be implemented. This patch removes it,
and tidies some reloc howtos. I was going to make some changes to
reloc_howto_struct, so I think it's important that all relocs howtos
are initialized with HOWTO.
* reloc.c (HOWTO): Revise comment.
(NEWHOWTO, HOWTO_PREPARE): Delete.
* coff-arm.c (coff_arm_reloc_type_lookup): Replace const struc
reloc_howto_struct with reloc_howto_type.
* ns32knetbsd.c (MY_bfd_reloc_type_lookup): Likewise.
* vms-alpha.c (alpha_vms_bfd_reloc_type_lookup): Likewise.
* elf-hppa.h (HOW): Define.
(elf_hppa_howto_table): Use it to simplify this table, correcting
name of R_PARISC_LTOFF16WF, R_PARISC_LTOFF_FPTR64, and
R_PARISC_LTOFF_FPTR16DF.
* elf32-mep.c (MEPREL): Use HOWTO.
* bfd-in2.h: Regenerate.
Alan Modra [Mon, 20 Aug 2018 08:46:34 +0000 (18:16 +0930)]
Fix s12z test regexps
Fixes
ERROR: tcl error sourcing .../gas/testsuite/gas/s12z/s12z.exp.
ERROR: couldn't compile regular expression pattern: quantifier operand invalid
run_dump_test expected output lines are regexps.
* testsuite/gas/s12z/bit-manip-invalid.d: Correct regexps.
GDB Administrator [Tue, 21 Aug 2018 00:00:49 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Mon, 20 Aug 2018 02:03:58 +0000 (22:03 -0400)]
Fix formatting in solib-svr4.c
Fix some formatting issues which I have missed during review.
gdb/ChangeLog:
* solib-svr4.c (svr4_exec_displacement): Fix formatting.
Alan Modra [Sun, 19 Aug 2018 23:55:12 +0000 (09:25 +0930)]
Don't init array at run time
When it can be done at compile time.
* mmo.c (valid_mmo_symbol_character_set): Initialize and make
array const.
(mmo_init): Don't init valid_mmo_symbol_character_set.
Alan Modra [Sun, 19 Aug 2018 23:52:28 +0000 (09:22 +0930)]
Tidy bit twiddling
* sh-opc.h (MASK): Simplify.
Alan Modra [Sun, 19 Aug 2018 23:50:11 +0000 (09:20 +0930)]
Balance parentheses in expression
* rs6000-core.c (CORE_COMMONSZ): Balance parentheses in expression.
GDB Administrator [Mon, 20 Aug 2018 00:00:44 +0000 (00:00 +0000)]
Automatic date update in version.in
Michael Spang [Sun, 19 Aug 2018 14:55:58 +0000 (10:55 -0400)]
Fix debugging of stripped PIE executables with padded PT_TLS
Certain PIE executables produced by gold cannot be debugged by gdb after
being stripped. GDB requires program headers of PIE executables to match,
and those checks may fail due to adjustments made during stripping.
One case of this occurs because strip recomputes the memsz of PT_TLS and
does not add alignment, while gold does. This is another variant of PR
11786, so apply the same fix of relaxing the program header matching.
gdb/ChangeLog:
PR gdb/11786
* solib-svr4.c (svr4_exec_displacement): Ignore memsz fields
for PT_TLS segments.
gdb/testsuite/ChangeLog:
PR gdb/11786
* gdb.base/gcore-tls-pie.c: New file.
* gdb.base/gcore-tls-pie.exp: New file.
GDB Administrator [Sun, 19 Aug 2018 00:01:08 +0000 (00:01 +0000)]
Automatic date update in version.in
Kevin Buettner [Tue, 31 Jul 2018 21:45:20 +0000 (14:45 -0700)]
Test case for DW_OP_GNU_variable_value
gdb/testsuite/ChangeLog:
* gdb.dwarf2/varval.c: New file.
* gdb.dwarf2/varval.exp: New file.
Kevin Buettner [Mon, 30 Jul 2018 23:15:34 +0000 (16:15 -0700)]
Add support of DW_OP_GNU_variable_value to DWARF assembler
gdb/testsuite/ChangeLog:
* lib/dwarf.exp: Add support for DW_OP_GNU_variable_value.
Kevin Buettner [Mon, 30 Jul 2018 22:41:56 +0000 (15:41 -0700)]
Add support for DW_OP_GNU_variable_value
This patch adds support for DW_OP_GNU_variable_value to GDB.
Jakub Jelinek provides a fairly expansive discussion of this DWARF
expression opcode in his GCC patch...
https://gcc.gnu.org/ml/gcc-patches/2017-02/msg01499.html
It has also been proposed for addition to the DWARF Standard:
http://www.dwarfstd.org/ShowIssue.php?issue=161109.2
If compiled with a suitable version of GCC, the test case associated
with GCC Bug 77589 uses DW_OP_GNU_variable_value in a DW_AT_byte_stride
expression. Here's a link to the bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77589
This is what the DWARF looks like. Look at the last line, which has
the DW_AT_byte_stride expression:
<2><e1>: Abbrev Number: 12 (DW_TAG_variable)
<e2> DW_AT_name : (indirect string, offset: 0x115): span.0
<e6> DW_AT_type : <0x2e>
<ea> DW_AT_artificial : 1
<ea> DW_AT_location : 3 byte block: 91 b0 7f (DW_OP_fbreg: -80)
...
<2><178>: Abbrev Number: 18 (DW_TAG_subrange_type)
<179> DW_AT_lower_bound : 4 byte block: 97 23 20 6 (DW_OP_push_object_address; DW_OP_plus_uconst: 32; DW_OP_deref)
<17e> DW_AT_upper_bound : 4 byte block: 97 23 28 6 (DW_OP_push_object_address; DW_OP_plus_uconst: 40; DW_OP_deref)
<183> DW_AT_byte_stride : 10 byte block: 97 23 18 6 fd e1 0 0 0 1e (DW_OP_push_object_address; DW_OP_plus_uconst: 24; DW_OP_deref; DW_OP_GNU_variable_value: <0xe1>; DW_OP_mul)
A patch to readelf, which I'm also submitting, is required to do this
decoding.
I found that GDB gave me the correct answer for "p c40pt(2)" once I
(correctly) implemented DW_OP_GNU_variable_value.
I also have test case (later in this series) which uses the DWARF
assembler and, therefore, do not rely on having a compiler with this
support.
gdb/ChangeLog:
* dwarf2expr.h (struct dwarf_expr_context): Add virtual method
dwarf_variable_value.
* dwarf2-frame.c (class dwarf_expr_executor):
Add override for dwarf_variable_value.
* dwarf2loc.c (class dwarf_evaluate_loc_desc): Likewise.
(class symbol_needs_eval_context): Likewise.
(indirect_synthetic_pointer): Add forward declaration.
(sect_variable_value): New function.
(dwarf2_compile_expr_to_ax): Add case for DW_OP_GNU_variable_value.
* dwarf2expr.c (dwarf_expr_context::execute_stack_op): Add case
for DW_OP_GNU_variable_value.
John Darrington [Tue, 24 Jul 2018 11:40:21 +0000 (13:40 +0200)]
Opcodes: (BRCLR / BRSET) Disassemble reserved codes instead of aborting.
Bit manipulation instructions which are not normally generated by the
assembler, should nevertheless be decoded by the disassembler.
opcodes/
* s12z-dis.c: BM_RESERVED1 to behave like BM_OPR_REG, and
BM_RESERVED0 like BM_REG_IMM.
John Darrington [Wed, 11 Jul 2018 08:42:01 +0000 (10:42 +0200)]
S12Z: Move opcode header to public include directory.
opcodes/
* s12z.h: Delete.
* s12z-dis.c: Adjust path of included file.
include/
* opcode/s12z.h: New file.
gas/
* config/tc-s12z.c: Adjust path of included file.
Alan Modra [Fri, 17 Aug 2018 05:36:46 +0000 (15:06 +0930)]
Remove duplicate ld testsuite function
It's in binutils/testsuite/lib/binutils-common.exp
* testsuite/ld-elf/elf.exp (is_elf64): Delete.
Alan Modra [Mon, 13 Aug 2018 04:11:18 +0000 (13:41 +0930)]
binutils testsuite strip-13 test
The strip-13 test runs into difficulty using dc.a on some targets.
dc.a writes a power of 2 number of bytes large enough to contain a
target address. On some targets, eg. avr-elf, this can be 2 bytes but
the ELF format used require words of 4 bytes to make up a relocation
entry. There was a hack in the test, duplicating the reloc type into
what is normally the addend to make the test work when little-endian,
but that hack fails for similar big-endian targets.
This patch fixes that problem by arranging to emit 32-bit and 64-bit
ELF relocs using .4byte and .8byte directives, chosen as appropriate
for the ELF size. I've also bumped the reloc number tested to a
higher unused value, and made the number more easily parameterised by
target should that be necessary in the future. Whether REL or RELA
relocs are used is now chosen by a new is_rela readelf test of an
object file, rather than by lists of targets.
* testsuite/lib/binutils-common.exp (is_elf64): Use directory of
input file for readelf.out.
(is_rela): New proc.
* testsuite/binutils-all/objcopy.exp (elf64): Set new variable
from first result of is_elf64 test.
(reloc_format): Set using is_rela.
(strip-13): Pass RELOC and ELF64 to assembler.
(strip-14, strip-15): Use elf64 rather than calling is_elf64 again.
* testsuite/binutils-all/strip-13.d: Run for more targets.
* testsuite/binutils-all/strip-13mips64.s: Use RELOC and set
addend to zero.
* testsuite/binutils-all/strip-13rel.s: Use RELOC and ELF64.
Don't add _NONE reloc.
* testsuite/binutils-all/strip-13rela.s: Likewise.
GDB Administrator [Sat, 18 Aug 2018 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Thu, 16 Aug 2018 00:37:00 +0000 (18:37 -0600)]
Remove "repeat" argument from command_line_input
After the previous patch, all callers pass 0 as the repeat argument to
command_line_input. So, this patch removes it.
gdb/ChangeLog
2018-08-16 Tom Tromey <tom@tromey.com>
* top.c (read_command_file): Update.
(command_line_input): Remove "repeat" argument.
* ada-lang.c (get_selections): Update.
* linespec.c (decode_line_2): Update.
* defs.h (command_line_input): Remove argument.
* cli/cli-script.c (read_next_line): Update.
* python/py-gdb-readline.c: Update.
Tom Tromey [Thu, 16 Aug 2018 00:37:00 +0000 (18:37 -0600)]
Fix use-after-free in number_or_range_parser
-fsanitize=address showed a use-after-free in number_or_range_parser.
The cause was that handle_line_of_input could stash the input into
"saved_command_line", and then this could be freed by reentrant calls.
This fixes the bug by preventing commands that are read by "commands"
from being eligible for repeating.
gdb/ChangeLog
2018-08-17 Tom Tromey <tom@tromey.com>
* cli/cli-script.c (read_next_line): Pass 0 as repeat argument to
command_line_input.
H.J. Lu [Fri, 17 Aug 2018 10:54:05 +0000 (03:54 -0700)]
x86: Remove empty X86_FEATURE_1_AND property
There is no need to generate .note.gnu.property section with empty
X86_FEATURE_1_AND property. This patch adds fixup_gnu_properties
to ELF linker backend so that x86 backend can remove it.
bfd/
PR ld/23515
* elf-bfd.h (elf_backend_data): Add fixup_gnu_properties.
* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Call
backend fixup_gnu_properties if it isn't NULL. Discard
.note.gnu.property section if all properties have been removed.
* elfxx-target.h (elf_backend_fixup_gnu_properties): New.
(elfNN_bed): Initialize fixup_gnu_properties.
* elfxx-x86.c (_bfd_x86_elf_link_fixup_gnu_properties): New
function.
* elfxx-x86.h (_bfd_x86_elf_link_fixup_gnu_properties): New
prototype.
(elf_backend_fixup_gnu_properties): New.
ld/
PR ld/23515
* testsuite/ld-i386/ibt-plt-2a.d: Updated.
* testsuite/ld-i386/ibt-plt-2b.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2b.d: Likewise.
Alan Hayward [Thu, 16 Aug 2018 14:21:15 +0000 (15:21 +0100)]
Fix asm in testsuite/gdb.arch/aarch64-fp.c
Cannot assume result of first and third ldr will go into x0.
Rewrite asm to be clearer.
gdb/testsuite/
PR gdb/18931:
* gdb.arch/aarch64-fp.c (main): Fix asm registers.
Keith Seitz [Thu, 16 Aug 2018 21:37:49 +0000 (14:37 -0700)]
Use gdb_test_no_output for compile tests expected to pass
There is a small think-o in compile.exp:
if { $srcfile3 != "" } {
gdb_test "p constvar" " = 3"
gdb_test "info addr constvar" {Symbol "constvar" is constant\.}
gdb_test "compile code globalvar = constvar;"; # INCORRECT
gdb_test "print globalvar" " = 3" "print constvar value"
} else {
untested "print constvar value"
}
The line marked INCORRECT runs a simple "compile code" which is expected
to succeed. When this happens, the compile plug-in and GDB will not
output anything. The use of gdb_test matches against anything.
This is certainly not the intent, and this patch corrects the two instances
of this in the file. [The rest of gdb.compile looks okay.]
testsuite/ChangeLog:
* gdb.compile/compile.exp: Use gdb_test_no_output for "compile code"
tests expected to pass.
Alan Modra [Wed, 15 Aug 2018 01:41:59 +0000 (11:11 +0930)]
Correct elf64-ppc.c linkage stub comment and formatting fixes
ppc_stub_long_branch_notoc will never need more than a 32-bit offset
for the r12 offset since the stub target must be in range of a
branch instruction.
* elf64-ppc.c: Correct ppc_stub_long_branch_notoc example.
Formatting.
GDB Administrator [Thu, 16 Aug 2018 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 15 Aug 2018 16:05:01 +0000 (10:05 -0600)]
Use pulongest in aarch64-linux-tdep.c
While testing a patch on the buildbot, I got this error:
../../binutils-gdb/gdb/aarch64-linux-tdep.c: In function uint64_t aarch64_linux_core_read_vq(gdbarch*, bfd*):
../../binutils-gdb/gdb/aarch64-linux-tdep.c:285:29: error: format %ld expects argument of type long int, but argument 2 has type uint64_t {aka long long unsigned int} [-Werror=format=]
This patch avoids the problem by using pulongest rather than %ld.
This seems safe to me because, if aarch64-linux-tdep.c is included in
the build, then ULONGEST must be a 64-bit type.
gdb/ChangeLog
2018-08-15 Tom Tromey <tom@tromey.com>
* aarch64-linux-tdep.c (aarch64_linux_core_read_vq): Use pulongest.
GDB Administrator [Wed, 15 Aug 2018 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 14 Aug 2018 16:55:43 +0000 (09:55 -0700)]
x86-64: Display eiz for address with the addr32 prefix
In 64-bit mode, display eiz for address with the addr32 prefix and without
base nor index registers. For
mov -0xccddef(,%eiz,), %rax
disassembler now displays:
67 48 8b 04 25 11 22 33 ff mov -0xccddef(,%eiz,1),%rax
instead of
67 48 8b 04 25 11 22 33 ff addr32 mov 0xffffffffff332211,%rax
gas/
* testsuite/gas/i386/evex-no-scale-64.d: Updated.
* testsuite/gas/i386/x86-64-addr32-intel.d: Likewise.
* testsuite/gas/i386/x86-64-addr32.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-addr32-intel.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-addr32.d: Likewise.
* testsuite/gas/i386/x86-64-addr32.s: Add %eiz tests.
opcodes/
* i386-dis.c (OP_E_memory): In 64-bit mode, display eiz for
address with the addr32 prefix and without base nor index
registers.
Jan Vrany [Tue, 14 Aug 2018 13:13:28 +0000 (14:13 +0100)]
MI: Add -a option to the "-data-disassemble" command
The CLI "disassemble" command allows specifying a single address - in
that case the function surrounding that address is disassembled.
This commit adds this feature to the equivalent MI command
"-data-disassemble".
gdb/ChangeLog:
2018-08-14 Jan Vrany <jan.vrany@fit.cvut.cz>
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Add -a option.
If used, use find_pc_partial_function to find address range
to disassemble.
* mi/mi-main.c (mi_cmd_list_features): Report
"data-disassemble-a-option" feature.
* NEWS: Mention new -data-disassemble option -a.
gdb/doc/ChangeLog:
2018-08-14 Jan Vrany <jan.vrany@fit.cvut.cz>
* gdb.texinfo (GDB/MI Data Manipulation): Document
"-data-disassemble -a addr".
(GDB/MI Support Commands): Document "data-disassemble-a-option"
feature.
gdb/testsuite/ChangeLog:
2018-08-14 Jan Vrany <jan.vrany@fit.cvut.cz>
* gdb.mi/mi-disassemble.exp (test_disassembly_only): Add tests for
-data-disassemble -a.
(test_disassembly_bogus_args): Likewise.
Andrew Burgess [Fri, 10 Aug 2018 09:16:32 +0000 (10:16 +0100)]
gdb: Fix instability in thread groups test
In the test script gdb.mi/list-thread-groups-available.exp we ask GDB
to list all thread groups, and match the output against a
regexp. Occasionally, I would see this test fail.
The expected output is a list of entries, each entry looking roughly
like this:
{id="<DECIMAL>",type="process",description="<STRING>",
user="<STRING>",cores=["<DECIMAL>","<DECIMAL>",...]}
All the fields after 'id' and 'type' are optional, and the 'cores'
list can contain 1 or more "<DECIMAL>" entries.
On my machine (Running Fedora 27, kernel 4.17.3-100.fc27.x86_64)
usually the 'description' is a non-empty string, and the 'cores' list
has at least one entry in it. But sometimes, very rarely, I'll see an
entry in the process group list where the 'description' is an empty
string, the 'user' is the string "?", and the 'cores' list is empty.
Such an entry looks like this:
{id="19863",type="process",description="",user="?",cores=[]}
I believe that this is caused by the process exiting while GDB is
scanning /proc for process information. The current code in
gdb/nat/linux-osdata.c is not (I think) resilient against exiting
processes.
This commit adjusts the regex that matches the 'cores' list so that an
empty list is acceptable, with this patch in place the test script
gdb.mi/list-thread-groups-available.exp never fails for me now.
I've only adjusted the cores regexp for the occasion when we have GDB
read information about all processes, its only in this case that we
might encounter an exiting process. When we read information about
two known PIDs, that we know will not exit for the duration of the
test, we require that the core list be non-empty.
gdb/testsuite/ChangeLog:
* gdb.mi/list-thread-groups-available.exp: Update test regexp.
Robert Yang [Tue, 14 Aug 2018 11:22:35 +0000 (12:22 +0100)]
When the assembler reports that the input and output are the same, report the file names involved, in order to help debugging. Also do not equate two files are the same if the have the same inode value but reside on different file systems.
* as.c (main): Improve check for input file matching output file.
GDB Administrator [Tue, 14 Aug 2018 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 10 Aug 2018 15:03:47 +0000 (09:03 -0600)]
Define _FORTIFY_SOURCE in common-defs.h
This defines _FORTIFY_SOURCE in common-defs.h. This seems like a
sensible safety measure, and also it may help avoid build problems
with -Wunused-result on distros that already define _FORTIFY_SOURCE by
default.
Tested by the buildbot.
gdb/ChangeLog
2018-08-13 Tom Tromey <tom@tromey.com>
* common/common-defs.h (_FORTIFY_SOURCE): Define.
H.J. Lu [Mon, 13 Aug 2018 14:24:31 +0000 (07:24 -0700)]
bfd: Move elf-properties.lo to BFD32_LIBS
commit
6404ab993797d1d6cd3d9e97cc281e3cb6226c12
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Aug 8 21:00:04 2018 -0700
Convert .note.gnu.property section between ELF32 and ELF64
updated bfd_convert_section_size and bfd_convert_section_contents
in bfd.c to call _bfd_elf_convert_gnu_property_size and
_bfd_elf_convert_gnu_properties, which are defined in elf-properties.c.
It led to
bfd.c:2484: undefined reference to `_bfd_elf_convert_gnu_property_size'
for non-ELF targets. Since elf-properties.c is a generic implementation
and doesn't reference any ELF specific functions directly, this patch
moves elf-properties.lo BFD32_LIBS.
Tested for many ELF and non-ELF targets.
PR binutils/23494
* Makefile.am (BFD32_LIBS): Add elf-properties.lo.
(BFD32_LIBS_CFILES): Add elf-properties.c.
(BFD32_BACKENDS): Remove elf-properties.lo.
(BFD32_BACKENDS_CFILES): Remove elf-properties.c.
* configure.ac (elf): Remove elf-properties.lo.
* Makefile.in: Regenerated.
* configure: Likewise.
Alan Hayward [Mon, 13 Aug 2018 10:02:22 +0000 (11:02 +0100)]
Parse SVE registers in aarch64 core file reading/writing
sve_regmap cannot be global static as the size is dependant on the current
vector length.
gdb/
* aarch64-linux-tdep.c (aarch64_linux_supply_sve_regset): New function.
(aarch64_linux_collect_sve_regset): Likewise.
(aarch64_linux_iterate_over_regset_sections): Check for SVE.
* regcache.h (regcache_map_entry_size): New function.
Alan Hayward [Mon, 13 Aug 2018 09:49:51 +0000 (10:49 +0100)]
Detect SVE when reading aarch64 core files
The SVE section in a core file contains a header followed by the registers.
Add defines to easily access the header fields within a buffer.
gdb/
* aarch64-linux-tdep.c (SVE_HEADER_SIZE_LENGTH): Add define.
(SVE_HEADER_MAX_SIZE_LENGTH): Likewise.
(SVE_HEADER_VL_LENGTH): Likewise.
(SVE_HEADER_MAX_VL_LENGTH): Likewise.
(SVE_HEADER_FLAGS_LENGTH): Likewise.
(SVE_HEADER_RESERVED_LENGTH): Likewise.
(SVE_HEADER_SIZE_OFFSET): Likewise.
(SVE_HEADER_MAX_SIZE_OFFSET): Likewise.
(SVE_HEADER_VL_OFFSET): Likewise.
(SVE_HEADER_MAX_VL_OFFSET): Likewise.
(SVE_HEADER_FLAGS_OFFSET): Likewise.
(SVE_HEADER_RESERVED_OFFSET): Likewise.
(SVE_HEADER_SIZE): Likewise.
(aarch64_linux_core_read_vq): Add function.
(aarch64_linux_core_read_description): Check for SVE section.
Alan Hayward [Mon, 13 Aug 2018 09:04:11 +0000 (10:04 +0100)]
Split size in regset section iterators
In the existing code, when using the regset section iteration functions, the
size parameter is used in different ways.
With collect, size is used to create the buffer in which to write the regset.
(see linux-tdep.c::linux_collect_regset_section_cb).
With supply, size is used to confirm the existing regset is the correct size.
If REGSET_VARIABLE_SIZE is set then the regset can be bigger than size.
Effectively, size is the minimum possible size of the regset.
(see corelow.c::get_core_register_section).
There are currently no targets with both REGSET_VARIABLE_SIZE and a collect
function.
In SVE, a corefile can contain one of two formats after the header, both of
which are different sizes. However, when writing a core file, we always want
to write out the full bigger size.
To allow support of collects for REGSET_VARIABLE_SIZE we need two sizes.
This is done by adding supply_size and collect_size.
gdb/
* aarch64-fbsd-tdep.c
(aarch64_fbsd_iterate_over_regset_sections): Add supply_size and
collect_size.
* aarch64-linux-tdep.c
(aarch64_linux_iterate_over_regset_sections): Likewise.
* alpha-linux-tdep.c
(alpha_linux_iterate_over_regset_sections):
* alpha-nbsd-tdep.c
(alphanbsd_iterate_over_regset_sections): Likewise.
* amd64-fbsd-tdep.c
(amd64fbsd_iterate_over_regset_sections): Likewise.
* amd64-linux-tdep.c
(amd64_linux_iterate_over_regset_sections): Likewise.
* arm-bsd-tdep.c
(armbsd_iterate_over_regset_sections): Likewise.
* arm-fbsd-tdep.c
(arm_fbsd_iterate_over_regset_sections): Likewise.
* arm-linux-tdep.c
(arm_linux_iterate_over_regset_sections): Likewise.
* corelow.c (get_core_registers_cb): Likewise.
(core_target::fetch_registers): Likewise.
* fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise.
* frv-linux-tdep.c (frv_linux_iterate_over_regset_sections): Likewise.
* gdbarch.h (void): Regenerate.
* gdbarch.sh: Add supply_size and collect_size.
* hppa-linux-tdep.c (hppa_linux_iterate_over_regset_sections): Likewise.
* hppa-nbsd-tdep.c (hppanbsd_iterate_over_regset_sections): Likewise.
* hppa-obsd-tdep.c (hppaobsd_iterate_over_regset_sections): Likewise.
* i386-fbsd-tdep.c (i386fbsd_iterate_over_regset_sections): Likewise.
* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections): Likewise.
* i386-tdep.c (i386_iterate_over_regset_sections): Likewise.
* ia64-linux-tdep.c (ia64_linux_iterate_over_regset_sections): Likewise.
* linux-tdep.c (linux_collect_regset_section_cb): Likewise.
* m32r-linux-tdep.c (m32r_linux_iterate_over_regset_sections): Likewise.
* m68k-bsd-tdep.c (m68kbsd_iterate_over_regset_sections): Likewise.
* m68k-linux-tdep.c (m68k_linux_iterate_over_regset_sections): Likewise.
* mips-fbsd-tdep.c (mips_fbsd_iterate_over_regset_sections): Likewise.
* mips-linux-tdep.c (mips_linux_iterate_over_regset_sections): Likewise.
* mips-nbsd-tdep.c (mipsnbsd_iterate_over_regset_sections): Likewise.
* mips64-obsd-tdep.c (mips64obsd_iterate_over_regset_sections): Likewise.
* mn10300-linux-tdep.c (am33_iterate_over_regset_sections): Likewise.
* nios2-linux-tdep.c (nios2_iterate_over_regset_sections): Likewise.
* ppc-fbsd-tdep.c (ppcfbsd_iterate_over_regset_sections): Likewise.
* ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections): Likewise.
* ppc-nbsd-tdep.c (ppcnbsd_iterate_over_regset_sections): Likewise.
* ppc-obsd-tdep.c (ppcobsd_iterate_over_regset_sections): Likewise.
* riscv-linux-tdep.c (riscv_linux_iterate_over_regset_sections): Likewise.
* rs6000-aix-tdep.c (rs6000_aix_iterate_over_regset_sections): Likewise.
* s390-linux-tdep.c (s390_iterate_over_regset_sections): Likewise.
* score-tdep.c (score7_linux_iterate_over_regset_sections): Likewise.
* sh-tdep.c (sh_iterate_over_regset_sections): Likewise.
* sparc-tdep.c (sparc_iterate_over_regset_sections): Likewise.
* tilegx-linux-tdep.c (tilegx_iterate_over_regset_sections): Likewise.
* vax-tdep.c (vax_iterate_over_regset_sections): Likewise.
* xtensa-tdep.c (xtensa_iterate_over_regset_sections): Likewise.
GDB Administrator [Mon, 13 Aug 2018 00:00:51 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 12 Aug 2018 12:39:00 +0000 (05:39 -0700)]
ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s
Swap pr23486a.s and pr23486a.s so that pr23486b.d differs from pr23486a.d.
* testsuite/ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s.
GDB Administrator [Sun, 12 Aug 2018 00:01:17 +0000 (00:01 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 11 Aug 2018 21:37:14 +0000 (14:37 -0700)]
x86: Add CpuCMOV and CpuFXSR
There are separate CPUID feature bits for fxsave/fxrstor and cmovCC
instructions. This patch adds CpuCMOV and CpuFXSR to replace Cpu686
on corresponding instructions.
gas/
* config/tc-i386.c (cpu_arch): Add .cmov and .fxsr.
(cpu_noarch): Add nocmov and nofxsr.
* doc/c-i386.texi: Document cmov and fxsr.
opcodes/
* i386-gen.c (cpu_flag_init): Add CpuCMOV and CpuFXSR to
CPU_I686_FLAGS. Add CPU_CMOV_FLAGS, CPU_FXSR_FLAGS,
CPU_ANY_CMOV_FLAGS and CPU_ANY_FXSR_FLAGS.
(cpu_flags): Add CpuCMOV and CpuFXSR.
* i386-opc.tbl: Replace Cpu686 with CpuFXSR on fxsave, fxsave64,
fxrstor and fxrstor64. Replace Cpu686 with CpuCMOV on cmovCC.
* i386-init.h: Regenerated.
* i386-tbl.h: Likewise.
H.J. Lu [Sat, 11 Aug 2018 13:41:33 +0000 (06:41 -0700)]
x86: Properly add X86_ISA_1_NEEDED property
Existing properties may be removed during property merging. We avoid
adding X86_ISA_1_NEEDED property only if existing properties won't be
removed.
bfd/
PR ld/23428
* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't
add X86_ISA_1_NEEDED property only if existing properties won't
be removed.
ld/
PR ld/23428
* testsuite/ld-elf/dummy.s: New file.
* testsuite/ld-elf/linux-x86.S: Add X86_FEATURE_1_AND property.
* testsuite/ld-elf/linux-x86.exp: Add dummy.s to pr23428.
Alan Modra [Sat, 11 Aug 2018 01:37:07 +0000 (11:07 +0930)]
Factor out common relocation processing
This patch factors out some code common to both bfd_perform_relocation
and bfd_install_relocation, in the process fixing the omission of
"case -1" in bfd_install_relocation.
* reloc.c (bfd_get_reloc_size): Sort switch.
(read_reloc, write_reloc, apply_reloc): New functions.
(bfd_perform_relocation, bfd_install_relocation): Use apply_reloc.
(_bfd_relocate_contents): Use read_reloc and write_reloc.
(_bfd_clear_contents): Likewise.
John Darrington [Thu, 9 Aug 2018 16:46:51 +0000 (18:46 +0200)]
Deal with relocations which are 3 bytes in size
* reloc.c (_bfd_relocate_contents): Handle 3 byte relocs.
(_bfd_clear_contents): Likewise.
(bfd_perform_relocation): Likewise.
(bfd_install_relocation): Likewise.
GDB Administrator [Sat, 11 Aug 2018 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Fri, 10 Aug 2018 22:01:11 +0000 (18:01 -0400)]
Fix forgotten xstrprintf -> string_printf change
The patch
528e157 ("Replace some uses of xstrprintf with string_printf")
forgot to actually change an xstrprintf call to string_printf, this one
fixes it.
gdb/ChangeLog:
* nat/linux-osdata.c (commandline_from_pid): Replace xstrprintf
with string_printf.
H.J. Lu [Fri, 10 Aug 2018 19:21:58 +0000 (12:21 -0700)]
Always clear h->verinfo.verdef when overriding a dynamic definition
When linker defines a symbol to override a dynamic definition, it should
always clear h->verinfo.verdef so that the symbol won't be associated
with the version information from the dynamic object. This happened to
the symbol "_edata" when creating an unversioned dynamic object linking
against:
1. libKF5ConfigCore.so.5.49.0
2. libKF5CoreAddons.so.5.49.0
3. libKF5I18n.so.5.49.0
4. libKF5DBusAddons.so.5.49.0
5. libQt5Xml.so.5.11.1
6. libQt5DBus.so.5.11.1
7. libQt5Core.so.5.11.1
Among them
libQt5Xml.so.5.11.1
299:
000000000003e000 0 NOTYPE GLOBAL DEFAULT 18 _edata@@Qt_5
libQt5DBus.so.5.11.1
597:
0000000000092018 0 NOTYPE GLOBAL DEFAULT 18 _edata@@Qt_5
libQt5Core.so.5.11.1
2292:
00000000004df640 0 NOTYPE GLOBAL DEFAULT 21 _edata@Qt_5
2293:
00000000004df640 0 NOTYPE GLOBAL DEFAULT 21 _edata@Qt_5
The problem is triggered by 2 duplicated entries of _edata@Qt_5 in
libQt5Core.so.5.11.1 which was created by gold. Before this commit,
ld created the dynamic object with "_edata" in its dynamic symbol table
which was linker defined and associated with the version information
from libQt5Core.so.5.11.1. The code in question was there when the
binutils source was imported to sourceware.org. When such a dynamic
object was used later, we got:
/usr/bin/ld: bin/libKF5Service.so.5.49.0: _edata: invalid version 21 (max 0)
/usr/bin/ld: bin/libKF5Service.so.5.49.0: error adding symbols: bad value
Tested with many ELF targets.
PR ld/23499
* elflink.c (bfd_elf_record_link_assignment): Always clear
h->verinfo.verdef when overriding a dynamic definition.
Keith Seitz [Fri, 10 Aug 2018 18:01:24 +0000 (11:01 -0700)]
Use policies for code generation
This patch changes code generation procedures add_code_header,
add_code_footer, and several other language-specific code generation
functions into policies.
gdb/ChangeLog:
* compile/compile-c-support.c (add_code_header, add_code_footer):
Move into policy class.
(c_push_user_expression, pop_user_expression_nop)
(c_add_code_header, c_add_code_footer, c_add_input): New policy class.
(compile_program): New host class.
(c_compile_program): New typedef.
(c_compute_porgram): Use c_compile_program.
Keith Seitz [Fri, 10 Aug 2018 17:53:47 +0000 (10:53 -0700)]
Use unique_ptr for htabs
This patch updates the type-conversion caching in C compile to use
unique pointers. This patch also removes the on-demand allocation of the
symbol error map in favor of initialization, simplifying the code.
gdb/ChangeLog
* compile/compile-internal.h (compile_instance::~compile_instance):
Remove calls to htab_delete.
<m_type_map, m_symbol_err_map>: Switch type to htab_up.
* compile.c (compile_instance::compile_instance): Initialize
htab unique pointers.
(compile_instance::get_cached_type, compile_instance::insert_type)
(compile_instance::error_symbol_once): Update for unique_ptr.
Keith Seitz [Fri, 10 Aug 2018 17:52:13 +0000 (10:52 -0700)]
Move compile_instance to compile.c
This simple patch moves any code related to compile_instance into
compile.c, reserving compile-c-* files strictly for C language support.
gdb/ChangeLog:
* compile/compile-c-symbols.c (struct symbol_error)
(hash_symbol_error, eq_symbol_error, del_symbol_error)
(compile_instance::insert_symbol_error)
(compile_instance::error_symbol_once): Move to ...
* compile/compile.c: ... here.
Keith Seitz [Fri, 10 Aug 2018 17:48:03 +0000 (10:48 -0700)]
Change compile_instance/compile_c_instance into classes
This patch changes structs compile_instance and compile_c_instance into
classes.
Because of the nature of the change, there are a number of unavoidably
mechanical changes buried in here, such as turning variable access of the
POD struct into method calls, removing the struct keyword, and changing
access of the plugin from "c_plugin->operation()" to
"plugin ().operation ()".
There is one "non-trivial" change associated with this patch, though.
The type cache and symbol error maps have been moved into the base class,
believing these facilities would be used other language implementations.
[They are indeed re-used by C++.]
gdb/ChangeLog:
* compile/compile-c-support.c (c_get_compile_context): Use `new'
instead of `new_compile_instance'.
* compile/compile-c-symbols.c (compile_instance::insert_symbol_error):
Update description.
If the symbol error map is not initialized, create it.
(generate_c_for_for_one_symbol): Do not check/initialize
the symbol error map.
* compile/compile-c-types.c (compile_c_instance): Make a class.
Update all callers.
(compile_instance::compile_instance): Initialize the type cache.
(get_cached_type): New function.
(insert_type): Update description.
(compile_c_instance::m_default_cflags): Define.
(convert_type): Update description. Use get_cached_type.
(delete_instance): Moved to destructor.
(new_compile_instance): Moved to constructor.
* compile/compile-c.h (compile_c_instance): Make class inheriting
from compile_instance.
<base>: Remove field.
<type_map, symbol_err_map>: Move to base class.
<c_plugin>: Rename to `m_plugin' and remove pointer type.
* compile/compile-internal.h (compile_instance): Make class.
<type_map_t, symbol_err_map_t>: Define.
<fe>: Rename to `m_gcc_fe'.
<scope, block, gcc_target_options>: Add `m_' prefix.
<m_type_map, m_symbol_err_map>: New fields, moved from
compile_c_instance.
<destroy>: Remove.
(convert_type, new_compile_instance): Remove.
* compile/compile.c (cleanup_compile_instance): Remove.
(compile_to_object): Use unique_ptr to eliminate cleanups.
(compile_instance::set_print_callback, compile_instance::version)
(compile_instance::set_verbose)
(compile_instance::set_driver_filename)
(compile_instance::set_triplet_regexp)
(compile_instance::set_arguments)
(compile_instance::set_source_file)
(compile_instance::compile): Define.
Keith Seitz [Fri, 10 Aug 2018 17:45:36 +0000 (10:45 -0700)]
Add a C++ wrapper for GCC C plug-in
This patch introduces a new class which wraps the GCC C compile plug-in.
It is a little unfortunate that this all happened in between the time that
GCC moved to C++ and GDB moved to C++, leaving us with an ABI promise to
support a C-like interface. The hope is to isolate GDB from some of this
should it change in the future.
Broadly, what this does is replace calls like:
C_CTX (context)->c_ops->operation (C_CTX (context), ...);
with calls that now look like:
context->c_plugin->operation (...);
This API will be further refined in following patches when struct
compile_instance/compile_c_instance are changed into classes.
gdb/ChangeLog:
* Makefile.in (HFILES_NO_SRCDIR): Add compile/gcc-c-plugin.h.
* compile/compile-c-types.c: Define GCC_METHODN macros and include
gcc-c-fe.def to define C plugin.
(delete_instance): Delete `c_plugin'.
(new_compile_instance): Initialize `c_plugin'.
* compile/compile-c.h: Include gcc_c_plugin.h.
(struct compile_c_instance) <c_plugin>: New member.
* gcc-c-plugin.h: New file.
Update all callers with API change.
Keith Seitz [Fri, 10 Aug 2018 17:43:17 +0000 (10:43 -0700)]
Move C-related declarations to compile-c.h
This patch simply moves a bunch of C language-related declarations from
the various compile header files into a new C-specific header, compile-c.h.
gdb/ChangeLog:
* Makefile.in (SUBDIR_GCC_COMPILE_SRCS): Move header files ...
(HFILES_NO_SRCDIR): ... to here.
Add compile-internal.h and compile-c.h.
* compile/compile-c-support.c: Include compile-c.h.
* compile/compile-c-symbols.c: Include compile-c.h.
(generate_c_for_variable_locations): Update comment.
* compile/compile-c-types.c: Include compile-c.h.
* compile/compile-c.h: New file -- moved C language declarations
from other files here.
* compile/compile-internal.h: Do not include hashtab.h or
common/enum-flags.h.
(gcc_qualifiers_flags, struct compile_c_instance, C_CTX)
(gcc_convert_symbol, gcc_symbol_address)
(generate_c_for_variable_locations, c_get_mode_for_size)
(c_get_range_decl_name): Definitions moved to compile-c.h.
* compile/compile-loc2c.c: Include compile-c.h.
Keith Seitz [Fri, 10 Aug 2018 17:41:37 +0000 (10:41 -0700)]
Rename symbol_substitution_name
This patch simply adds a "c_" prefix to symbol_substitution_name to clarify
that this is a C language-related function.
gdb/ChangeLog:
* compile/compile-c-symbols.c (symbol_substitution_name): Rename to ...
(c_symbol_substitution_name): ... this.
Update all callers.