Alan Modra [Thu, 4 Apr 2019 22:50:16 +0000 (09:20 +1030)]
PowerPC disassembler: Don't emit trailing spaces
When an instruction has operands, the PowerPC disassembler prints
spaces after the opcode so as to line up operands. If the operands
are all optional and all default value, then no operands are printed,
leaving trailing spaces. This patch fixes that.
opcodes/
* ppc-dis.c (print_insn_powerpc): Delay printing spaces after
opcode until first operand is output.
gas/
* testsuite/gas/ppc/476.d: Remove trailing spaces.
* testsuite/gas/ppc/a2.d: Likewise.
* testsuite/gas/ppc/booke.d: Likewise.
* testsuite/gas/ppc/booke_xcoff.d: Likewise.
* testsuite/gas/ppc/e500.d: Likewise.
* testsuite/gas/ppc/e500mc.d: Likewise.
* testsuite/gas/ppc/e6500.d: Likewise.
* testsuite/gas/ppc/htm.d: Likewise.
* testsuite/gas/ppc/power6.d: Likewise.
* testsuite/gas/ppc/power8.d: Likewise.
* testsuite/gas/ppc/power9.d: Likewise.
* testsuite/gas/ppc/vle.d: Likewise.
ld/
* testsuite/ld-powerpc/tlsexe32.d: Remove trailing spaces.
* testsuite/ld-powerpc/tlsopt5.d: Likewise.
* testsuite/ld-powerpc/tlsopt5_32.d: Likewise.
GDB Administrator [Fri, 5 Apr 2019 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in
Peter Bergner [Thu, 4 Apr 2019 14:00:29 +0000 (09:00 -0500)]
Add extended mnemonics for bctar. Fix setting of 'at' branch hints.
opcodes/
PR gas/24349
* ppc-opc.c (valid_bo_pre_v2): Add comments.
(valid_bo_post_v2): Add support for 'at' branch hints.
(insert_bo): Only error on branch on ctr.
(get_bo_hint_mask): New function.
(insert_boe): Add new 'branch_taken' formal argument. Add support
for inserting 'at' branch hints.
(extract_boe): Add new 'branch_taken' formal argument. Add support
for extracting 'at' branch hints.
(insert_bom, extract_bom, insert_bop, extract_bop): New functions.
(BOE): Delete operand.
(BOM, BOP): New operands.
(RM): Update value.
(XLYLK, XLYLK_MASK, XLYBB_MASK): Delete.
(powerpc_opcodes) <bc-, bcl-, bca-, bcla-, bclr-, bclrl-, bcctr-,
bcctrl-, bctar-, bctarl->: Replace BOE with BOM.
(powerpc_opcodes) <bc+, bcl+, bca+, bcla+, bclr+, bclrl+, bcctr+,
bcctrl+, bctar+, bctarl+>: Replace BOE with BOP.
<bdnztar, bdnztarl, bdztar, bdztarl, btar, btarl, bdnztar-, bdnztarl-,
bdnztar+, bdnztarl+, bdztar-, bdztarl-, bdztar+, bdztarl+, bgetar,
bnltar, bgetarl, bnltarl, bletar, bngtar, bletarl, bngtarl, bnetar,
bnetarl, bnstar, bnutar, bnstarl, bnutarl, bgetar-, bnltar-, bgetarl-,
bnltarl-, bletar-, bngtar-, bletarl-, bngtarl-, bnetar-, bnetarl-,
bnstar-, bnutar-, bnstarl-, bnutarl-, bgetar+, bnltar+, bgetarl+,
bnltarl+, bletar+, bngtar+, bletarl+, bngtarl+, bnetar+, bnetarl+,
bnstar+, bnutar+, bnstarl+, bnutarl+, blttar, blttarl, bgttar, bgttarl,
beqtar, beqtarl, bsotar, buntar, bsotarl, buntarl, blttar-, blttarl-,
bgttar-, bgttarl-, beqtar-, beqtarl-, bsotar-, buntar-, bsotarl-,
buntarl-, blttar+, blttarl+, bgttar+, bgttarl+, beqtar+, beqtarl+,
bsotar+, buntar+, bsotarl+, buntarl+, bdnzftar, bdnzftarl, bdzftar,
bdzftarl, bftar, bftarl, bftar-, bftarl-, bftar+, bftarl+, bdnzttar,
bdnzttarl, bdzttar, bdzttarl, bttar, bttarl, bttar-, bttarl-, bttar+,
bttarl+>: New extended mnemonics.
gas/
PR gas/24349
* testsuite/gas/ppc/power8.s: (bdnztar, bdnztarl, bdztar, bdztarl,
btar, btarl, bdnztar-, bdnztarl-, bdnztar+, bdnztarl+, bdztar-,
bdztarl-, bdztar+, bdztarl+, bgetar, bnltar, bgetarl, bnltarl,
bletar, bngtar, bletarl, bngtarl, bnetar, bnetarl, bnstar, bnutar,
bnstarl, bnutarl, bgetar-, bnltar-, bgetarl-, bnltarl-, bletar-,
bngtar-, bletarl-, bngtarl-, bnetar-, bnetarl-, bnstar-, bnutar-,
bnstarl-, bnutarl-, bgetar+, bnltar+, bgetarl+, bnltarl+, bletar+,
bngtar+, bletarl+, bngtarl+, bnetar+, bnetarl+, bnstar+, bnutar+,
bnstarl+, bnutarl+, blttar, blttarl, bgttar, bgttarl, beqtar,
beqtarl, bsotar, buntar, bsotarl, buntarl, blttar-, blttarl-,
bgttar-, bgttarl-, beqtar-, beqtarl-, bsotar-, buntar-, bsotarl-,
buntarl-, blttar+, blttarl+, bgttar+, bgttarl+, beqtar+, beqtarl+,
bsotar+, buntar+, bsotarl+, buntarl+, bdnzftar, bdnzftarl, bdzftar,
bdzftarl, bftar, bftarl, bftar-, bftarl-, bftar+, bftarl+, bdnzttar,
bdnzttarl, bdzttar, bdzttarl, bttar, bttarl, bttar-, bttarl-, bttar+,
bttarl+): Add tests of extended mnemonics.
* testsuite/gas/ppc/power8.d: Likewise. Update previous bctar tests
to expect new extended mnemonics.
* testsuite/gas/ppc/a2.s: <bc, bc-, bc+, bcl, bcl-, bcl+>: Update test
to not use illegal BO value. Use a more convenient BI value.
* testsuite/gas/ppc/a2.d: Update tests for new expect output.
Thomas Schwinge [Thu, 4 Apr 2019 09:20:09 +0000 (11:20 +0200)]
[GDB, Hurd] Fix build; 'target_waitstatus_to_string' call
Recent commit
c29705b71a8ec966478c0dc4712194a95291c6de removed an incomplete
local implementation in favor of 'target_waitstatus_to_string' (thanks!), but
introduced a small typing error:
In file included from [...]/gdb/gnu-nat.c:24:0:
[...]/gdb/gnu-nat.c: In member function 'virtual ptid_t gnu_nat_target::wait(ptid_t, target_waitstatus*, int)':
[...]/gdb/gnu-nat.c:1652:43: error: cannot convert 'target_waitstatus**' to 'const target_waitstatus*' for argument '1' to 'std::__cxx11::string target_waitstatus_to_string(const target_waitstatus*)'
target_waitstatus_to_string (&status).c_str ());
^
[...]/gdb/gnu-nat.h:119:32: note: in definition of macro 'debug'
__FILE__ , __LINE__ , ##args); } while (0)
^~~~
[...]/gdb/gnu-nat.c:1650:3: note: in expansion of macro 'inf_debug'
inf_debug (inf, "returning ptid = %s, %s",
^~~~~~~~~
gdb/
* gnu-nat.c (gnu_nat_target::wait): Fix
target_waitstatus_to_string call.
GDB Administrator [Thu, 4 Apr 2019 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Max Filippov [Tue, 2 Apr 2019 21:32:42 +0000 (14:32 -0700)]
gas: use literals/const16 for xtensa loop relaxation
Loop opcode relaxation that uses addi/addmi doesn't work well with other
relaxations that may cause code movement. Instead of encoding fixed loop
end offset in the relaxed sequence use l32r or a pair of const16 to load
loop end address. This way the address of the loop end gets a relocation
record and it gets updated appropriately.
gas/
2019-04-03 Max Filippov <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (convert_frag_immed): Drop
convert_frag_immed_finish_loop invocation.
(convert_frag_immed_finish_loop): Drop declaration and
definition.
* config/xtensa-relax.c (widen_spec_list): Replace loop
widening that uses addi/addmi with widening that uses l32r
and const16.
Alan Modra [Wed, 3 Apr 2019 00:51:36 +0000 (11:21 +1030)]
PR24411, Division is not accepted in MEMORY length expression
Let's hope no one has section names starting with '/' in scripts. If
they do, this change to fix parsing of '/' in expressiongs will break
their project.
PR 24411
ldlex.l (SYMBOLNAMECHAR1): Don't match '/'.
(<EXPRESSION>"/DISCARD/"): New.
Alan Modra [Wed, 3 Apr 2019 00:58:17 +0000 (11:28 +1030)]
ldlex.l tidy
Underscore was specified twice in all these patterns, and backslash
twice in some. Flex warned about the $SYSROOT rule, which is covered
by earlier rules: "ldlex.l:386: warning, rule cannot be matched".
* ldlex.l: Formatting.
(CMDFILENAMECHAR, CMDFILENAMECHAR1): Delete.
(FILENAMECHAR1, SYMBOLNAMECHAR1, FILENAMECHAR, WILDCHAR),
(NOCFILENAMECHAR): Remove duplicate chars. Reorder.
(SYMBOLCHARN): Likewise. Rename to SYMBOLNAMECHAR.
(<INPUTLIST>"$SYSROOT"..): Delete rule.
Alan Modra [Tue, 2 Apr 2019 06:08:20 +0000 (16:38 +1030)]
BFD whitespace fixes
* coff-i386.c, * coff-x86_64.c, * coffgen.c, * dwarf2.c,
* elf-m10200.c, * elf.c, * elf32-arm.c, * elf32-bfin.c,
* elf32-csky.c, * elf32-m32r.c, * elf32-microblaze.c, * elf32-pru.c,
* elf32-rx.c, * elf32-xgate.c, * elf64-sparc.c, * elfnn-ia64.c,
* elfxx-riscv.c, * elfxx-sparc.c, * linker.c, * mach-o.c,
* pe-x86_64.c, * pei-x86_64.c, * plugin.c: Whitespace fixes.
GDB Administrator [Wed, 3 Apr 2019 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Tue, 2 Apr 2019 20:30:07 +0000 (13:30 -0700)]
RISC-V: Don't check ABI flags if no code section.
This fixes a glib build failure reported in PR 24389. Using ld -b binary
creates an object file with no elf header flags set which has the wrong ABI
info for riscv64-linux. But the file also has no code sections, so I added
code borrowed from the arm port that only checks the ELF header ABI flags if
there is a code section.
bfd/
PR 24389
* elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Move read of
ELF header flags to after check for ELF object file. Loop through
sections looking for code sections, if none, then skip ABI checks.
GDB Administrator [Tue, 2 Apr 2019 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Thu, 14 Feb 2019 15:49:39 +0000 (15:49 +0000)]
gdb/fortran: Handle internal function calls
If an convenience function is defined in python (or guile), then
currently this will not work in Fortran, instead the user is given
this message:
(gdb) set language fortran
(gdb) p $myfunc (3)
Cannot perform substring on this type
Compare this to C:
(gdb) set language c
(gdb) p $myfunc (3)
$1 = 1
After this patch we see the same behaviour in both C and Fortran.
I've extended the test to check that all languages can call the
convenience functions - only Fortran was broken.
When calling convenience functions in Fortran we don't need to perform
the same value preparation (passing by pointer) that we would for
calling a native function - passing the real value is fine.
gdb/ChangeLog:
* eval.c (evaluate_subexp_standard): Handle internal functions
during Fortran function call handling.
gdb/testsuite/ChangeLog:
* gdb.python/py-function.exp: Check calling helper function from
all languages.
* lib/gdb.exp (gdb_supported_languages): New proc.
Andrew Burgess [Thu, 14 Mar 2019 13:58:58 +0000 (13:58 +0000)]
gdb: Add $_cimag and $_creal internal functions
Add two new internal functions $_cimag and $_creal that extract the
imaginary and real parts of a complex value.
These internal functions can take a complex value of any type 'float
complex', 'double complex', or 'long double complex' and return a
suitable floating point value 'float', 'double', or 'long double'.
So we can now do this:
(gdb) p z1
$1 = 1.5 + 4.5 * I
(gdb) p $_cimag (z1)
$4 = 4.5
(gdb) p $_creal (z1)
$4 = 1.5
The components of a complex value are not strictly named types in
DWARF, as the complex type is itself the base type. However, once we
are able to extract the components it makes sense to be able to ask
what the type of these components is and get a sensible answer back,
rather than the error we would currently get. Currently GDB says:
(gdb) ptype z1
type = complex double
(gdb) p $_cimag (z1)
$4 = 4.5
(gdb) ptype $
type = <invalid type code 9>
With the changes in dwarf2read.c, GDB now says:
(gdb) ptype z1
type = complex double
(gdb) p $_cimag (z1)
$4 = 4.5
(gdb) ptype $
type = double
Which seems to make more sense.
gdb/ChangeLog:
* NEWS: Mention new internal functions.
* dwarf2read.c (dwarf2_init_complex_target_type): New function.
(read_base_type): Use dwarf2_init_complex_target_type.
* value.c (creal_internal_fn): New function.
(cimag_internal_fn): New function.
(_initialize_values): Register new internal functions.
gdb/doc/ChangeLog:
* gdb.texinfo (Convenience Funs): Document '$_creal' and
'$_cimag'.
gdb/testsuite/ChangeLog:
* gdb.base/complex-parts.c: New file.
* gdb.base/complex-parts.exp: New file.
Philippe Waroquiers [Sun, 24 Mar 2019 14:14:55 +0000 (15:14 +0100)]
Fix internal error and improve 'set debug infrun 1'/target wait kind trace
The test gdb.threads/watchthreads-reorder.exp verifies that the
'set debug infrun 1' debug output does not crash GDB.
Under high load, the test can still cause a GDB internal error (see details
below).
This patch fixes this crash, and improves/factorises some wait kind traces.
Tested on debian/amd64 + run one test with 'set debug infrun 1'.
Changes compared to the first version:
* Handles the suggestions of Kevin to trace the relevant elements
of the wait status (this is done by calling target_waitstatus_to_string).
* Some other changes to factorise wait status tracing.
Note that using target_waitstatus_to_string instead of the 'locally printed'
status kind strings means that debug trace that was using strings such as:
"EXITED" or "TARGET_WAITKIND_EXITED"
will now use what is printed by target_waitstatus_to_string e.g.
"exited".
gdb/ChangeLog
2019-04-01 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* infrun.c (stop_all_threads): If debug_infrun, always
trace the wait status after wait_one, using
target_waitstatus_to_string and target_pid_to_str.
(handle_inferior_event): Replace various trace of
wait status kind by a single trace.
* gdb/gnu-nat.c (gnu_nat_target::wait): Replace local
wait status kind image by target_waitstatus_to_string.
* target/waitstatus.c (target_waitstatus_to_string): Fix
obsolete comment.
(top-gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007f3d54a0642a in __GI_abort () at abort.c:89
#2 0x0000555c24c60e66 in dump_core () at ../../fixleaks/gdb/utils.c:201
#3 0x0000555c24c63d49 in internal_vproblem(internal_problem *, const char *, int, const char *, typedef __va_list_tag __va_list_tag *) (problem=problem@entry=0x555c25338d40 <internal_error_problem>, file=<optimized out>, line=287,
fmt=<optimized out>, ap=<optimized out>) at ../../fixleaks/gdb/utils.c:411
#4 0x0000555c24c63eab in internal_verror (file=<optimized out>, line=<optimized out>, fmt=<optimized out>,
ap=<optimized out>) at ../../fixleaks/gdb/utils.c:436
#5 0x0000555c249e8c22 in internal_error (file=file@entry=0x555c24e0f2ad "../../fixleaks/gdb/inferior.c",
line=line@entry=287, fmt=<optimized out>) at ../../fixleaks/gdb/common/errors.c:55
#6 0x0000555c247d3f5c in find_inferior_pid (pid=<optimized out>) at ../../fixleaks/gdb/inferior.c:287
#7 0x0000555c24ad2248 in find_inferior_pid (pid=<optimized out>) at ../../fixleaks/gdb/inferior.c:302
#8 find_inferior_ptid (ptid=...) at ../../fixleaks/gdb/inferior.c:301
#9 0x0000555c24c35f25 in find_thread_ptid (ptid=...) at ../../fixleaks/gdb/thread.c:522
#10 0x0000555c24b0ab4d in thread_db_target::pid_to_str[abi:cxx11](ptid_t) (
this=0x555c2532e3e0 <the_thread_db_target>, ptid=...) at ../../fixleaks/gdb/linux-thread-db.c:1637
#11 0x0000555c24c2f420 in target_pid_to_str[abi:cxx11](ptid_t) (ptid=...) at ../../fixleaks/gdb/target.c:2083
#12 0x0000555c24ad9cab in stop_all_threads () at ../../fixleaks/gdb/infrun.c:4373
#13 0x0000555c24ada00f in stop_waiting (ecs=<optimized out>) at ../../fixleaks/gdb/infrun.c:7464
#14 0x0000555c24adc401 in process_event_stop_test (ecs=ecs@entry=0x7ffc9402d9d0) at ../../fixleaks/gdb/infrun.c:6181
...
(top-gdb) fr 12
#12 0x0000555c24ad9cab in stop_all_threads () at ../../fixleaks/gdb/infrun.c:4373
(top-gdb) p event_ptid
$5 = {m_pid = 25419, m_lwp = 25427, m_tid = 0}
(top-gdb) p ptid
$6 = {m_pid = 0, m_lwp = 0, m_tid = 0}
(top-gdb) p ws
$7 = {kind = TARGET_WAITKIND_THREAD_EXITED, value = {integer = 0, sig = GDB_SIGNAL_0, related_pid = {m_pid = 0,
m_lwp = 0, m_tid = 0}, execd_pathname = 0x0, syscall_number = 0}}
(top-gdb)
The gdb.log corresponding to the above crash is:
(gdb) PASS: gdb.threads/watchthreads-reorder.exp: reorder1: set debug infrun 1
continue
Continuing.
infrun: clear_proceed_status_thread (Thread 0x7ffff7fcfb40 (LWP 25419))
infrun: clear_proceed_status_thread (Thread 0x7ffff7310700 (LWP 25427))
infrun: clear_proceed_status_thread (Thread 0x7ffff6b0f700 (LWP 25428))
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming Thread 0x7ffff7fcfb40 (LWP 25419)
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7fcfb40 (LWP 25419)] at 0x7ffff7344317
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: proceed: resuming Thread 0x7ffff7310700 (LWP 25427)
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff7310700 (LWP 25427)] at 0x5555555553d7
infrun: prepare_to_wait
infrun: proceed: resuming Thread 0x7ffff6b0f700 (LWP 25428)
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0x7ffff6b0f700 (LWP 25428)] at 0x5555555554c8
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: -1.0.0 [process -1],
infrun: status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
Joining the threads.
[Thread 0x7ffff6b0f700 (LWP 25428) exited]
infrun: target_wait (-1.0.0, status) =
infrun: -1.0.0 [process -1],
infrun: status->kind = ignore
infrun: TARGET_WAITKIND_IGNORE
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 25419.25419.0 [Thread 0x7ffff7fcfb40 (LWP 25419)],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x555555555e50
infrun: context switch
infrun: Switching context from Thread 0x7ffff6b0f700 (LWP 25428) to Thread 0x7ffff7fcfb40 (LWP 25419)
infrun: BPSTAT_WHAT_STOP_NOISY
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun: Thread 0x7ffff7fcfb40 (LWP 25419) not executing
infrun: Thread 0x7ffff7310700 (LWP 25427) executing, need stop
[Thread 0x7ffff7310700 (LWP 25427) exited]
infrun: target_wait (-1.0.0, status) =
infrun: 25419.25427.0 [LWP 25427],
infrun: status->kind = thread exited, status = 0
infrun: infrun_async(0)
../../fixleaks/gdb/inferior.c:287: internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.threads/watchthreads-reorder.exp: reorder1: continue to breakpoint: break-at-exit (GDB internal error)
Resyncing due to internal error.
n
infrun: infrun_async(1)
This is a bug, please report it. For instructions, see:
<http://www.gnu.org/software/gdb/bugs/>.
infrun: infrun_async(0)
../../fixleaks/gdb/inferior.c:287: internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) y
Tom Tromey [Wed, 27 Mar 2019 19:21:24 +0000 (13:21 -0600)]
Handle DW_AT_ranges when reading partial symtabs
add_partial_subprogram does not handle DW_AT_ranges, while the full
symtab reader does. This can lead to discrepancies where a function
is not put into a partial symtab, and so is not available to "break"
and the like -- but is available if the full symtab has somehow been
read.
This patch fixes the bug by arranging to read DW_AT_ranges when
reading partial DIEs.
This is PR symtab/23331.
The new test case is derived from dw2-ranges-func.exp, which is why I
kept the copyright dates.
gdb/ChangeLog
2019-04-01 Tom Tromey <tromey@adacore.com>
PR symtab/23331:
* dwarf2read.c (partial_die_info::read): Handle DW_AT_ranges.
gdb/testsuite/ChangeLog
2019-04-01 Tom Tromey <tromey@adacore.com>
PR symtab/23331:
* gdb.dwarf2/dw2-ranges-main.c: New file.
* gdb.dwarf2/dw2-ranges-psym.c: New file.
* gdb.dwarf2/dw2-ranges-psym.exp: New file.
Sergio Durigan Junior [Fri, 29 Mar 2019 21:34:54 +0000 (17:34 -0400)]
Destroy allocated values when exiting GDB
When the user exits GDB, we might still have some allocated values in
the chain, which, in specific scenarios, can cause problems when GDB
attempts to destroy them in "quit_force". For example, see the bug
reported at:
https://bugzilla.redhat.com/show_bug.cgi?id=
1690120
And the thread starting at:
https://sourceware.org/ml/gdb-patches/2019-03/msg00475.html
Message-ID: <87r2azkhmq.fsf@redhat.com>
In order to avoid that, and to be more aware of our allocated
resources, this commit implements a new function "finalize_values" and
calls it from inside "quit_force".
Tested by the BuildBot.
2019-04-01 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* top.c (quit_force): Call 'finalize_values'.
* value.c (finalize_values): New function.
* value.h (finalize_values): Declare.
Andre Vieira [Mon, 1 Apr 2019 09:43:32 +0000 (10:43 +0100)]
[GAS, Arm] CLI with architecture sensitive extensions
This patch adds a new framework to add architecture sensitive extensions, like
GCC does. This patch also implements all architecture extensions currently
available in GCC.
This framework works as follows. To enable architecture sensitive extensions
for a particular architecture, that architecture must contain an ARM_ARCH_OPT2
entry in the 'arm_archs' table. All fields here are the same as previous, with
the addition of a new extra field at the end to <name> it's extension table.
This <name>, corresponds to a <name>_ext_table of type 'struct arm_ext_table'.
This struct can be filled with three types of entries:
ARM_ADD (string <ext>, arm_feature_set <enable_bits>), which means +<ext> will
enable <enable_bits>
ARM_REMOVE (string <ext>, arm_feature_set <disable_bits>), which means
+no<ext> will disable <disable_bits>
ARM_EXT (string <ext>, arm_feature_set <enable_bits>, arm_feature_set
<disable_bits>), which means +<ext> will enable <enable_bits> and +no<ext>
will disable <disable_bits> (this is to be used instead of adding an
ARM_ADD and ARM_REMOVE for the same <ext>)
This patch does not disable the use of the old extensions, even if some of them
are duplicated in the new tables. This is a "in-between-step" as we may want to
deprecate the old table of extensions in later patches. For now, GAS will first
look for the +<ext> or +no<ext> in the new table and if no entry is found it
will continue searching in the old table, following old behaviour. If only an
ARM_ADD or an ARM_REMOVE is defined for <ext> and +no<ext> or +<ext> resp. is
used then it also continues to search the old table for it.
A couple of caveats:
- This patch does not enable the use of these architecture extensions with the
'.arch_extension' directive. This is future work that I will tend to later.
- This patch does not enable the use of these architecture extensions with the
-mcpu option. This is future work that I will tend to later.
- This patch does not change the current behaviour when combining an
architecture extension and using -mfpu on the command-line. The current
behaviour of GAS is to stage the union of feature bits enabled by both -march
and -mfpu. GCC behaves differently here, so this is something we may want to
revisit on a later date.
Marco Barisione [Mon, 1 Apr 2019 07:59:53 +0000 (09:59 +0200)]
Add gdb.Value.format_string ()
The str () function, called on a gdb.Value instance, produces a string
representation similar to what can be achieved with the print command,
but it doesn't allow to specify additional formatting settings, for
instance disabling pretty printers.
This patch introduces a new format_string () method to gdb.Value which
allows specifying more formatting options, thus giving access to more
features provided by the internal C function common_val_print ().
gdb/ChangeLog:
2019-04-01 Marco Barisione <mbarisione@undo.io>
Add gdb.Value.format_string ().
* python/py-value.c (copy_py_bool_obj):
(valpy_format_string): Add gdb.Value.format_string ().
* NEWS: Document the addition of gdb.Value.format_string ().
gdb/doc/ChangeLog:
2019-04-01 Marco Barisione <mbarisione@undo.io>
* python.texi (Values From Inferior): Document
gdb.Value.format_string ().
gdb/testsuite/ChangeLog:
2019-04-01 Marco Barisione <mbarisione@undo.io>
Test gdb.Value.format_string ().
* gdb.python/py-format-string.exp: New test.
* gdb.python/py-format-string.c: New file.
* gdb.python/py-format-string.py: New file.
Marco Barisione [Mon, 1 Apr 2019 07:43:54 +0000 (09:43 +0200)]
Add myself to gdb/MAINTAINERS
gdb/ChangeLog:
2019-04-01 Marco Barisione <mbarisione@undo.io>
* MAINTAINERS (Write After Approval): Add Marco Barisione.
Alan Modra [Mon, 1 Apr 2019 01:30:09 +0000 (12:00 +1030)]
PR24402, global buffer overflow in symtab_finalize
PR 24402
* symtab.c (symtab_finalize): Init prev_addr to one less than
first symbol address, not one more. Correct test for symbols
with leading underscores.
GDB Administrator [Mon, 1 Apr 2019 00:00:44 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 31 Mar 2019 00:01:22 +0000 (00:01 +0000)]
Automatic date update in version.in
Jim Wilson [Sat, 30 Mar 2019 17:12:12 +0000 (10:12 -0700)]
RISC-V: Relax tail/j to c.j for RV64.
2019-03-30 Andrew Waterman <andrew@sifive.com>
bfd/
* elfnn-riscv.c (_bfd_riscv_relax_call): Only check ARCH_SIZE for
rd == X_RA case.
Eli Zaretskii [Sat, 30 Mar 2019 09:58:33 +0000 (12:58 +0300)]
Introduce new convenience variables $_gdb_major and $_gdb_minor
gdb/ChangeLog:
2019-03-30 Eli Zaretskii <eliz@gnu.org>
* NEWS: Announce $_gdb_major and $_gdb_minor.
* top.c (init_gdb_version_vars): New function.
(gdb_init): Call init_gdb_version_vars.
gdb/testsuite/ChangeLog:
2019-03-30 Simon Marchi <simark@simark.ca>
* gdb.base/default.exp: Add values for $_gdb_major and
$_gdb_minor.
gdb/doc/ChangeLog:
2019-03-30 Eli Zaretskii <eliz@gnu.org>
* gdb.texinfo (Convenience Vars): Document $_gdb_major and
$_gdb_minor.
GDB Administrator [Sat, 30 Mar 2019 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 20 Mar 2019 20:52:24 +0000 (14:52 -0600)]
Add usage for commands in printcmd.c
I noticed that the help for "info addr" did not include a "usage"
line; and when adding it I went through and fixed a few minor issues
in printcmd.c:
* Added usage lines to all commands
* Updated the help text for some commands
* Changed some help to use upper case metasyntactic variables
* Removed some dead code
Regression tested on x86-64 Fedora 29.
gdb/ChangeLog
2019-03-29 Tom Tromey <tromey@adacore.com>
* printcmd.c (_initialize_printcmd): Add usage lines. Update some
help text. Remove dead code.
gdb/testsuite/ChangeLog
2019-03-29 Tom Tromey <tromey@adacore.com>
* gdb.base/help.exp: Tighten apropos regexp.
Keith Seitz [Fri, 29 Mar 2019 17:15:38 +0000 (10:15 -0700)]
Allow really large fortran array bounds: fortran type/value printers
This is the fortran part of the patch, including tests, which
are essentially unchanged from Siddhesh's original 2012 submission:
https://sourceware.org/ml/gdb-patches/2012-08/msg00562.html
There is, however, one large departure. In the above thread,
Jan pointed out problems with GCC debuginfo for -m32 builds
(filed usptream as gcc/54934). After investigating the issue,
I am dropping the hand-tweaked assembler source file to workaround
this case.
While I would normally do something to accommodate this, in
this case, given the ubiquity of 64-bit systems today (where
the tests pass) and the apparent lack of urgency on the compiler
side (by users), I don't think the additional complexity and
maintenance costs are worth it. It will be very routinely tested
on 64-bit systems. [For example, at Red Hat, we always
test -m64 and -m32 configurations for all GDB releases.]
gdb/ChangeLog:
From Siddhesh Poyarekar:
* f-lang.h (f77_get_upperbound): Return LONGEST.
(f77_get_lowerbound): Likewise.
* f-typeprint.c (f_type_print_varspec_suffix): Expand
UPPER_BOUND and LOWER_BOUND to LONGEST. Use plongest to format
print them.
(f_type_print_base): Expand UPPER_BOUND to LONGEST. Use
plongest to format print it.
* f-valprint.c (f77_get_lowerbound): Return LONGEST.
(f77_get_upperbound): Likewise.
(f77_get_dynamic_length_of_aggregate): Expand UPPER_BOUND,
LOWER_BOUND to LONGEST.
(f77_create_arrayprint_offset_tbl): Likewise.
gdb/testsuite/ChangeLog:
* gdb.fortran/array-bounds.exp: New file.
* gdb.fortran/array-bounds.f90: New file.
Keith Seitz [Fri, 29 Mar 2019 17:15:38 +0000 (10:15 -0700)]
Allow really large fortran array bounds: TYPE_LENGTH to ULONGEST
This series is revisit of Siddhesh Poyarekar's patch from back in
2012. The last status on the patch is in the following gdb-patches
thread:
https://sourceware.org/ml/gdb-patches/2012-08/msg00562.html
It appears that Tom approved the patch, but Jan had some issues
with a compiler error that made the test fail on -m32 test runs.
He wrote up a hand-tweaked .S file to deal with it. Siddesh said
he would update tests. Then nothing.
Siddesh and Jan have both moved on since.
The patch originally required a large precursor patch to work.
I have whittled this down to/rewritten the bare minimum, and this
first patch is the result, changing the type of TYPE_LENGTH
to ULONGEST from unsigned int.
The majority of the changes involve changing printf format
strings to use %s and pulongest instead of %d.
gdb/ChangeLog:
* ada-lang.c (ada_template_to_fixed_record_type_1): Use
%s/pulongest for TYPE_LENGTH instead of %d in format
strings.
* ada-typerint.c (ada_print_type): Likewise.
* amd64-windows-tdep.c (amd64_windows_store_arg_in_reg): Likewise.
* compile/compile-c-support.c (generate_register_struct): Likewise.
* gdbtypes.c (recursive_dump_type): Likewise.
* gdbtypes.h (struct type) <length>: Change type to ULONGEST.
* m2-typeprint.c (m2_array): Use %s/pulongest for TYPE_LENGTH
instead of %d in format strings.
* riscv-tdep.c (riscv_type_alignment): Cast second argument
to std::min to ULONGEST.
* symmisc.c (print_symbol): Use %s/pulongest for TYPE_LENGTH
instead of %d in format strings.
* tracepoint.c (info_scope_command): Likewise.
* typeprint.c (print_offset_data::update)
(print_offset_data::finish): Likewise.
* xtensa-tdep.c (xtensa_store_return_value)
(xtensa_push_dummy_call): Likewise.
Max Filippov [Fri, 29 Mar 2019 00:03:57 +0000 (17:03 -0700)]
bfd: xtensa: fix shrink_dynamic_reloc_sections for export-dynamic
shrink_dynamic_reloc_sections must remove PLT entry that was created for
an undefined weak symbol in the presence of --export-dynamic option when
relaxation coalesces literals pointing to that symbol. This fixes the
following assertion:
ld: BFD (GNU Binutils) 2.31.1 internal error, aborting at
elf32-xtensa.c:3292 in elf_xtensa_finish_dynamic_sections
2019-03-29 Max Filippov <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (shrink_dynamic_reloc_sections): Add
info->export_dynamic to the conditional.
ld/
* testsuite/ld-xtensa/relax-undef-weak-pie-export-dynamic.d: New
test definition.
* testsuite/ld-xtensa/xtensa.exp
(relax-undef-weak-pie-export-dynamic): Add new test.
GDB Administrator [Fri, 29 Mar 2019 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Thu, 28 Mar 2019 22:33:29 +0000 (22:33 +0000)]
sim: fix all sim builds
This commit:
commit
ef9866970ce6683d40465fb7c3168f87a1dcd1b7
Date: Thu Mar 28 06:40:30 2019 +0900
sim/common: convert sim-arange to use sim-inline
broke many simulator targets. I fixed aarch64 in a previous commit
without realising how many other target were also broken.
This commit adds the missing includes (sim-assert.h and libiberty.h),
which seem to be needed by many simulator targets, in a central
location, this should fix most builds.
sim/common/ChangeLog:
* sim-base.h: Add 'sim-assert.h' include.
* sim-basics.h: Add 'libiberty.h' include.
Jon Turney [Thu, 28 Mar 2019 14:02:25 +0000 (14:02 +0000)]
Fix format specification in display_selector() (again)
DWORD type is not a long on 64-bit Cygwin, because that it is LP64.
Explicitly cast DWORD values to unsigned long and use an appropriate
format.
gdb/ChangeLog:
2019-03-28 Jon Turney <jon.turney@dronecode.org.uk>
* windows-nat.c (display_selector): Fixed format specifications
for 64-bit Cygwin.
Philippe Waroquiers [Sat, 9 Feb 2019 10:50:10 +0000 (11:50 +0100)]
Fix gdb.multi/multi-term-settings.exp blocking under high load/slow gdb
Similarly to multi-arch-exec.exp, increase the alarm timer to avoid
test blocking under high load or with a slow gdb.
2019-03-28 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.multi/multi-term-settings.c (main): Increase alarm timer.
Philippe Waroquiers [Sat, 9 Feb 2019 10:43:35 +0000 (11:43 +0100)]
Fix gdb.multi/multi-arch-exec.exp blocking under high load/slow gdb
When running multi-arch-exec.exp under valgrind, the test succeeds
when the machine is not loaded, but blocks when the machine is highly
loaded (e.g. when running the testsuite with valgrind with -j X
where X is one more than the nr of available cores).
The problem is that the hello program dies too early due to the alarm (30).
So, increase the alarm timer.
Note that this does not make the test take longer (it takes about
3.5 seconds on my system). As I understand, the alarm is just there
to avoid hello staying there forever in case of another problem.
2019-03-28 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.multi/hello.c (main): Increase alarm timer.
Philippe Waroquiers [Tue, 5 Feb 2019 22:47:53 +0000 (23:47 +0100)]
Fix GDB being suspended SIGTTOU when running gdb.multi/multi-arch-exec.exp
When running under valgrind, multi-arch-exec.exp blocks forever.
Some (painful) investigation shows this is due to valgrind slowing
down GDB, and GDB has to output some messages at a different time,
when GDB does not have the terminal for output.
To reproduce the problem, you need to slow down GDB.
It can be reproduced by:
cd gdb/testsuite/outputs/gdb.multi/multi-arch-exec/
../../../../gdb -ex 'set debug lin-lwp 1' -ex 'break all_started' -ex 'run' ./2-multi-arch-exec
The above stops at a breakpoint. Do continue.
GDB is then suspended because of SIGTTOU.
The stacktrace that leads to the hanging GDB is:
(top-gdb) bt
at ../../binutils-gdb/gdb/exceptions.c:130
....
Alternatively, the same happens when doing
strace -o s.out ../../../../gdb -ex 'break all_started' -ex 'run' ./2-multi-arch-exec
And of course, valgrind is also sufficiently slowing down GDB to
reproduce this :).
Fix this by calling target_terminal::ours_for_output ();
at the beginning of follow_exec.
Note that all this terminal handling is not very clear to me:
* Some code takes the terminal, and then takes care to give it back to the inferior
if the terminal was belonging to the inferior.
(e.g. annotate_breakpoints_invalid).
* some code takes the terminal, but does not give it back
(e.g. update_inserted_breakpoint_locations).
* some code takes it, and unconditionally gives it back
(e.g. handle_jit_event)
* here and there, we also find
gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
before a (sometimes optional) call to ours_for_output.
And such calls to ours_for_output is sometimes protected by:
if (target_supports_terminal_ours ())
(e.g. exceptions.c: print_flush).
but most of the code calls it without checking if the target supports it.
* some code is outputting some errors, but only takes the terminal
after. E.g. infcmd.c: prepare_one_step
gdb/ChangeLog
2019-03-28 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* infrun.c (follow_exec): Call target_terminal::ours_for_output.
Sandra Loosemore [Thu, 28 Mar 2019 16:29:22 +0000 (09:29 -0700)]
Fix stepping past unwritable kernel helper on nios2-linux-gnu.
This patch fixes a problem on nios2-linux-gnu with stepping past the
kernel helper __kuser_cmpxchg, which was exposed by the testcase
gdb.threads/watchpoint-fork.exp. The kernel maps this function into
user space on an unwritable page. In this testcase, the cmpxchg
helper is invoked indirectly from the setbuf call in the test program.
Since this target lacks hardware breakpoint/watchpoint support, GDB
tries to single-step through the program by setting software
breakpoints, and was just giving an error when it reached the function
on the unwritable page.
The solution here is to always step over the call instead of stepping
into it; cmpxchg is supposed to be an atomic operation so this
behavior seems reasonable. The hook in nios2_get_next_pc is somewhat
generic, but at present cmpxchg is the only helper provided by the
Linux kernel that is invoked by an ordinary function call. (Signal
return trampolines also go through the unwritable page but not by a
function call.)
Fixing this issue also revealed that the testcase needs a much larger
timeout factor when software single-stepping is used. That has also
been fixed in this patch.
gdb/ChangeLog
2019-03-28 Sandra Loosemore <sandra@codesourcery.com>
* nios2-tdep.h (struct gdbarch_tdep): Add is_kernel_helper.
* nios2-tdep.c (nios2_get_next_pc): Skip over kernel helpers.
* nios2-linux-tdep.c (nios2_linux_is_kernel_helper): New.
(nios2_linux_init_abi): Install it.
gdb/testsuite/ChangeLog
2019-03-28 Sandra Loosemore <sandra@codesourcery.com>
* gdb.threads/watchpoint-fork.exp (test): Use large timeout
factor when no hardware watchpoint support.
Alan Hayward [Thu, 28 Mar 2019 12:33:29 +0000 (12:33 +0000)]
Testsuite: set sysroot when using gdbserver
When testing using native-gdbserver and native-extended-gdbserver, the sysroot
is not set. This results in a warning from GDB and files are sent via the
remote protocol, which can be slow.
On Ubuntu 18.04 (unlike most distros) the debug versions of the standard
libraries are included by default in /usr/lib/debug/.
These file reads are causing a complete native-gdbserver run on the AArch64
buildbot slave to timeout after 2.5 hours. This is also causing the builds
to back up on the slave.
The solution is to ensure the sysroot is set to / for all local boards.
This drastically reduces the time of a test. For example, gdb.base/sigall.exp
drops from 23 seconds to 4 seconds.
A full native-gdbserver run on the AArch64 slave now takes 8 minutes.
gdb/testsuite/ChangeLog:
* boards/local-board.exp: set sysroot to /.
Andrew Burgess [Thu, 28 Mar 2019 13:42:07 +0000 (13:42 +0000)]
sim: fix aarch64 sim build
This commit:
commit
ef9866970ce6683d40465fb7c3168f87a1dcd1b7
Date: Thu Mar 28 06:40:30 2019 +0900
sim/common: convert sim-arange to use sim-inline
Broke the simulator build for aarch64 - some required macros are no
longer included where needed, fixed in this commit.
sim/aarch64/ChangeLog:
* cpustate.c: Add 'libiberty.h' include.
* interp.c: Add 'sim-assert.h' include.
Alan Hayward [Thu, 28 Mar 2019 12:27:30 +0000 (12:27 +0000)]
AArch64: View the pseudo V registers as vectors
When SVE is enabled, the V registers become pseudo registers based
on the Z registers. They should look the same as they do when
there is no SVE.
The existing code viewed them as single value registers. Switch
this to a vector.
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_vnv_type): Use vector types.
Alan Hayward [Thu, 28 Mar 2019 12:14:09 +0000 (12:14 +0000)]
AArch64: 128bit views for SVE registers
SVE can view Z registers as 128bit values using .q prefix.
Add this view to the SVE feature.
gdb/ChangeLog:
* features/aarch64-sve.c (create_feature_aarch64_sve): Add q view.
Alan Hayward [Thu, 28 Mar 2019 11:23:25 +0000 (11:23 +0000)]
gdbserver: Ensure AT_HWCAP2 is defined
When using older compilers, AT_HWCAP2 may not be be defined.
It is defined in elf/common.h, however including this in
gdbserver/linux-low.c causes conflicts.
Manually add the define if it does not exist.
gdb/gdbserver/ChangeLog:
* linux-low.c (AT_HWCAP2): Add define if not already included.
Alan Modra [Thu, 28 Mar 2019 06:23:32 +0000 (16:53 +1030)]
PR24392, Clang warning Wtautological-constant-out-of-range-compare
PR 24392
* configure.ac: Invoke AC_CHECK_SIZEOF(int).
* configure: Regenerate.
* coffgen.c (coff_get_reloc_upper_bound): Replace gcc diagnostic
workaround with SIZEOF_LONG vs. SIZEOF_INT check.
* elf.c (_bfd_elf_get_reloc_upper_bound): Likewise.
* elf64-sparc.c (elf64_sparc_get_reloc_upper_bound): Likewise.
* mach-o.c (bfd_mach_o_get_reloc_upper_bound): Likewise.
Alan Modra [Thu, 28 Mar 2019 00:06:55 +0000 (10:36 +1030)]
PR24390, Don't decode mtfsb field as a cr field
"mtfsb0 4*cr7+lt" doesn't make all that much sense, but unfortunately
glibc uses just that instead of "mtfsb0 28" to clear the fpscr xe bit.
So for backwards compatibility accept cr field expressions when
assembling mtfsb operands, but disassemble to a plain number.
PR 24390
include/
* opcode/ppc.h (PPC_OPERAND_CR_REG): Comment.
opcodes/
* ppc-opc.c (BTF): Define.
(powerpc_opcodes): Use for mtfsb*.
* ppc-dis.c (print_insn_powerpc): Print fields with both
PPC_OPERAND_CR_REG and PPC_OPERAND_CR_BIT as a plain number.
gas/
* testsuite/gas/ppc/476.d: Update mtfsb*.
* testsuite/gas/ppc/a2.d: Likewise.
GDB Administrator [Thu, 28 Mar 2019 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in
Stafford Horne [Wed, 27 Mar 2019 21:40:30 +0000 (06:40 +0900)]
sim/common: Fix warnings: "warning: implicit declaration of function..."
During building of several cgen simulator's I notices the below
warnings. Adding includes fixes these.
Including config.h allows stdio.h to properly configure itself to expose
asprintf().
The other warnings for abort, free, memset, strlen are trivial.
Warnings:
../../../binutils-gdb/sim/or1k/../common/sim-watch.c: In function ‘sim_watchpoint_install’:
../../../binutils-gdb/sim/or1k/../common/sim-watch.c:415:10: warning: implicit declaration of function ‘asprintf’; did you mean ‘vasprintf’? [-Wimplicit-function-declaration]
if (asprintf (&name, "watch-%s-%s",
^~~~~~~~
vasprintf
../../../binutils-gdb/sim/lm32/../common/hw-device.c: In function ‘hw_strdup’:
../../../binutils-gdb/sim/lm32/../common/hw-device.c:59:34: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
char *dup = hw_zalloc (me, strlen (str) + 1);
^~~~~~
../../../binutils-gdb/sim/lm32/../common/hw-events.c: In function ‘hw_event_queue_schedule’:
../../../binutils-gdb/sim/lm32/../common/hw-events.c:92:3: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration]
memset (&dummy, 0, sizeof dummy);
^~~~~~
../../../binutils-gdb/sim/lm32/../common/hw-handles.c: In function ‘hw_handle_remove_ihandle’:
../../../binutils-gdb/sim/lm32/../common/hw-handles.c:211:4: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
free (delete);
^~~~
../../../binutils-gdb/sim/lm32/../common/sim-fpu.c: In function ‘pack_fpu’:
../../../binutils-gdb/sim/lm32/../common/sim-fpu.c:292:7: warning: implicit declaration of function ‘abort’ [-Wimplicit-function-declaration]
abort ();
^~~~~
sim/common/ChangeLog:
* sim-options.c: Include "config.h".
Include <stdio.h>.
* sim-watch.c: Include "config.h".
Include <stdio.h>.
* hw-device.c: Include <string.h>.
* hw-events.c: Include <string.h>.
* hw-handles.c: Include <stdlib.h>.
* sim-fpu.c: Include <stdlib.h>.
Stafford Horne [Wed, 27 Mar 2019 21:40:30 +0000 (06:40 +0900)]
sim/common: convert sim-arange to use sim-inline
This fixes a TODO item and also fixes an error which we get when
building with no optimizations (-O0) in at least gcc 8.2.1.
Tested with sims that use cgen code lm32, or1k, cris, m32r and inlining
is working corretly.
Reference Error:
gcc -DHAVE_CONFIG_H -DWITH_DEFAULT_MODEL='"or1200"' -DWITH_ALIGNMENT=STRICT_ALIGNMENT \
-DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31 -DWITH_TARGET_ADDRESS_BITSIZE=32 \
-DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG -DDEFAULT_INLINE=0 -DWITH_SCACHE=16384 \
-I. -I../../../binutils-gdb/sim/or1k -I../common -I../../../binutils-gdb/sim/or1k/../common \
-I../../include -I../../../binutils-gdb/sim/or1k/../../include -I../../bfd \
-I../../../binutils-gdb/sim/or1k/../../bfd -I../../opcodes -I../../../binutils-gdb/sim/or1k/../../opcodes \
-g -o run nrun.o libsim.a ../../bfd/libbfd.a ../../opcodes/libopcodes.a ../../libiberty/libiberty.a \
-ldl -lz -lm
/usr/bin/ld: libsim.a(mloop.o): in function `extract':
/home/shorne/work/openrisc/gdb-musl/sim/or1k/mloop.c:82: undefined reference to `sim_addr_range_hit_p'
/usr/bin/ld: /home/shorne/work/openrisc/gdb-musl/sim/or1k/mloop.c:83: undefined reference to `sim_addr_range_hit_p'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:305: run] Error 1
sim/common/ChangeLog:
* Make-common.in (sim-arange_h): Remove sim-arange.c
* sim-arange.c: Remove SIM_ARANGE_C.
Add ifdef for _SIM_ARANGE_C_.
Include "sim-arange.h".
Remove include for unused "sim-assert.h".
Remove DEFINE_INLINE_P. Remove DEFINE_NON_INLINE_P.
(sim_addr_range_add): Declare as INLINE_SIM_ARANGE.
(sim_addr_range_delete): Declare as INLINE_SIM_ARANGE.
(sim_addr_range_hit_p): Change from SIM_ARANGE_INLINE to
INLINE_SIM_ARANGE.
* sim-arange.h (sim_addr_range_add): Declare as
INLINE_SIM_ARANGE.
(sim_addr_range_delete): Declare as INLINE_SIM_ARANGE.
(sim_addr_range_hit_p) Declare as INLINE_SIM_ARANGE.
Remove definition of SIM_ARANGE_INLINE.
Remove [HAVE_INLINE].
Wrap include "sim-arange.c" in H_REVEALS_MODULE_P.
* sim-base.h: Include "sim-arange.h"
* sim-basics.h: Remove include of "sim-arange.h"
* sim-inline.c: Include "sim-arange.c"
* sim-inline.h: Define INLINE_SIM_ARANGE.
Define SIM_ARANGE_INLINE. Define EXTERN_SIM_ARANGE_P.
Define STATIC_INLINE_SIM_ARANGE. Define STATIC_SIM_ARANGE.
Philippe Waroquiers [Wed, 27 Mar 2019 15:38:34 +0000 (09:38 -0600)]
Fix buffer overflow regression due to minsym malloc-ed instead of obstack-ed.
Valgrind detects the following error in a bunch of tests,
e.g. in gdb.base/foll-fork.exp.
==15155== VALGRIND_GDB_ERROR_BEGIN
==15155== Invalid read of size 8
==15155== at 0x55BE04: minimal_symbol_upper_bound(bound_minimal_symbol) (minsyms.c:1504)
==15155== by 0x3B2E9C: find_pc_partial_function(unsigned long, char const**, unsigned long*, unsigned long*, block const**) (blockframe.c:340)
==15155== by 0x3B3135: find_function_entry_range_from_pc(unsigned long, char const**, unsigned long*, unsigned long*) (blockframe.c:385)
==15155== by 0x4F5597: fill_in_stop_func(gdbarch*, execution_control_state*) [clone .part.16] (infrun.c:4124)
==15155== by 0x4FBE01: fill_in_stop_func (infrun.c:7636)
==15155== by 0x4FBE01: process_event_stop_test(execution_control_state*) (infrun.c:6279)
...
==15155== Address 0x715bec8 is 0 bytes after a block of size 2,952 alloc'd
==15155== at 0x4C2E2B3: realloc (vg_replace_malloc.c:836)
==15155== by 0x405F2C: xrealloc (common-utils.c:62)
==15155== by 0x55BA4E: xresizevec<minimal_symbol> (poison.h:170)
==15155== by 0x55BA4E: minimal_symbol_reader::install() (minsyms.c:1399)
==15155== by 0x4981C7: elf_read_minimal_symbols (elfread.c:1165)
...
This seems to be a regression created by:
commit
042d75e42c5572f333e0e06dabd3c5c4afab486c
Author: Tom Tromey <tom@tromey.com>
AuthorDate: Sat Mar 2 12:29:48 2019 -0700
Commit: Tom Tromey <tom@tromey.com>
CommitDate: Fri Mar 15 16:02:10 2019 -0600
Allocate minimal symbols with malloc
Before this commit, the array of 'struct minimal_symbol'
contained a last element that was a "null symbol". The comment in
minimal_symbol_reader::install was:
/* We also terminate the minimal symbol table with a "null symbol",
which is *not* included in the size of the table. This makes it
easier to find the end of the table when we are handed a pointer
to some symbol in the middle of it. Zero out the fields in the
"null symbol" allocated at the end of the array. Note that the
symbol count does *not* include this null symbol, which is why it
is indexed by mcount and not mcount-1. */
memset (&msymbols[mcount], 0, sizeof (struct minimal_symbol));
However, minimal_symbol_upper_bound was still based on the assumption
that the array of minsym is terminated by a minsym with a null symbol:
it is looping with:
for (i = 1; MSYMBOL_LINKAGE_NAME (msymbol + i) != NULL; i++)
Replace this NULL comparison by a logic that calculates how
many msymbol are following the msymbols from which we are starting from.
(Re-)tested on debian/amd64, natively and under valgrind.
gdb/ChangeLog
2019-03-24 Philippe Waroquiers <philippe.waroquiers@skynet.be>
Tom Tromey <tromey@adacore.com>
* minsyms.c (minimal_symbol_upper_bound): Fix buffer overflow.
Alan Hayward [Wed, 27 Mar 2019 10:58:57 +0000 (10:58 +0000)]
Testsuite: Ensure interrupt-daemon-attach doesn't run forever
Looking at the AArch64 buildbot, I noticed about two dozen old instances of
interrupt-daemon-attach taking up a full 100% cpu each.
If the test fails then the test binary relies on an alarm to ensure it dies
after 60 seconds.
As per the Linux man page for alarm:
Alarms created by alarm() ... are not inherited by children created via fork.
Update the test to add an alarm in the child and also put a sleep in the
child loop so it does not constantly consume cpu.
Note I haven't managed to re-create why the test failed. This fix will just
stop it hanging and consuming cpu when it does.
gdb/testsuite/ChangeLog:
* gdb.base/interrupt-daemon-attach.c (main): Add alarm and sleep
in child.
GDB Administrator [Wed, 27 Mar 2019 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
Joel Brobecker [Tue, 26 Mar 2019 22:30:21 +0000 (17:30 -0500)]
gdb-gdb.py.in: Fix error when printing range type
I noticed that trying to print the contents of a struct main_type
would fail when the type was a TYPE_CODE_RANGE:
(gdb) p *type.main_type
$1 = Python Exception <class 'gdb.error'> There is no member named low_undefined.:
And indeed, Python is right, fields "low_undefined" has been removed
from struct range_bounds back in ... 2014! It was done when we introduced
dynamic bounds handling. This patch fixes gdb-gdb.py.in according to
the new structure.
gdb/ChangeLog:
* gdb-gdb.py.in (StructMainTypePrettyPrinter.bound_img): New method.
(StructMainTypePrettyPrinter.bounds_img): Use new "bound_img"
method to compute the bounds of range types. Also print "[evaluated]"
if the bounds' values come from a dynamic evaluation.
Andrew Burgess [Thu, 21 Mar 2019 16:29:14 +0000 (16:29 +0000)]
gdb: Make python display_hint None handling defined behaviour
The documentation say that the display_hint method must return a
string to serve as a display hint, and then goes on to list some
acceptable strings.
However, if we don't supply the display_hint method then we get a
default display style behaviour and there's currently no way (in the
python api) to force this default behaviour.
The guile api allows #f to be used in order to force the default
display style behaviour, and this is documented.
Currently, using None in the python api also forces the default
display behaviour.
This commit extends the documentation to make returning None from the
display_hint method an official mechanism by which the user can get
the default display style.
I've extended one of the existing tests to cover this case.
gdb/doc/ChangeLog:
* python.texi (Pretty Printing API): Document use of None for the
display_hint.
gdb/testsuite/ChangeLog:
* gdb.python/py-prettyprint.c (struct container) <is_map_p>: New
field.
(make_container): Initialise new field.
* gdb.python/py-prettyprint.exp: Add new tests.
* gdb.python/py-prettyprint.py (class ContainerPrinter)
<display_hint>: New method.
Andrew Burgess [Sat, 23 Mar 2019 22:49:09 +0000 (22:49 +0000)]
gdb/testsuite: Make test names unique in gdb.python/py-prettyprint.exp
This makes the test names unique in gdb.python/py-prettyprint.exp, it
also switches to use gdb_breakpoint and gdb_continue_to_breakpoint
more so that we avoid test names with the source line number in - this
is bad if the test source ever changes as the test names will then
change.
One final change is to switch from using gdb_py_test_silent_cmd to use
gdb_test_no_output, the former should be used for running python
commands and can catch any thrown exception. However, in this case
the command being run is not a python command, its just a normal GDB
CLI command that produces no output, so lets use the appropriate
wrapper function.
gdb/testsuite/ChangeLog:
* gdb.python/py-prettyprint.exp: Use gdb_breakpoint and
gdb_continue_to_breakpoint more throughout this test.
(run_lang_tests) Supply unique test names, and use
gdb_test_no_output.
Andrew Burgess [Thu, 21 Mar 2019 12:25:47 +0000 (12:25 +0000)]
gdb: Avoid trailing whitespace when pretty printing
While writing a new test for 'set print pretty on' I spotted that GDB
will sometimes add a trailing whitespace character when pretty
printing. This commit removes the trailing whitespace and updates the
expected results in one tests where this was an issue.
I've added an extra test for 'set print pretty on' as it doesn't seem
to have much testing.
gdb/ChangeLog:
* cp-valprint.c (cp_print_value_fields): Don't print trailing
whitespace when pretty printing is on.
gdb/testsuite/ChangeLog:
* gdb.base/finish-pretty.exp: Update expected results.
* gdb.base/pretty-print.c: New file.
* gdb.base/pretty-print.exp: New file.
Alan Hayward [Tue, 26 Mar 2019 17:11:32 +0000 (17:11 +0000)]
Fix Powerpc build
gdb/ChangeLog:
* ppc-linux-nat.c: Add include.
Alan Hayward [Tue, 26 Mar 2019 16:44:04 +0000 (16:44 +0000)]
Add AArch64 Pointer Authentication to the NEWS file
gdb/ChangeLog:
* NEWS: Mention AArch64 Pointer Authentication.
Tamar Christina [Tue, 26 Mar 2019 16:46:42 +0000 (16:46 +0000)]
AArch64/Arm: Update testcases fixing endiannes and linux targets
This fixes the testcases that are failing due to my recent patch.
It turns out that the start address across baremetal and linux builds
isn't entirely predictable without a linker script. Since the address
themselves are not the important thing I am ignoring them now.
Secondly I was encoding data using .word using non 0 values, however
because .word is subjected to endiannes these non-zero values under
big-endian happen to fall into the encoding space of instructions which
changes the disassembly. Using 0 fixes this problem and the purpose of
the test still holds, though objdump will dump ... for data only sections,
which is ok as the data/insn mixed sections will test the patch.
The ARM Attributes sections is not important and is ignored.
binutils/ChangeLog:
* testsuite/binutils-all/aarch64/in-order.d: Likewise.
* testsuite/binutils-all/aarch64/out-of-order-all.d: Likewise.
* testsuite/binutils-all/aarch64/out-of-order.d: Likewise.
* testsuite/binutils-all/aarch64/out-of-order.s: Likewise.
* testsuite/binutils-all/arm/in-order-all.d: Likewise.
* testsuite/binutils-all/arm/in-order.d: Likewise.
* testsuite/binutils-all/arm/out-of-order-all.d: Likewise.
* testsuite/binutils-all/arm/out-of-order.d: Likewise.
* testsuite/binutils-all/arm/out-of-order.s: Likewise.
Alan Hayward [Mon, 25 Mar 2019 10:44:11 +0000 (10:44 +0000)]
gdbserver: Add linux_get_hwcap
In gdbserver, Tidy up calls to read HWCAP (and HWCAP2) by adding common
functions, removing the Arm, AArch64, PPC and S390 specific versions.
No functionality differences.
gdb/gdbserver/ChangeLog:
* linux-aarch64-low.c (aarch64_get_hwcap): Remove function.
(aarch64_arch_setup): Call linux_get_hwcap.
* linux-arm-low.c (arm_get_hwcap): Remove function.
(arm_read_description): Call linux_get_hwcap.
* linux-low.c (linux_get_auxv): New function.
(linux_get_hwcap): Likewise.
(linux_get_hwcap2): Likewise.
* linux-low.h (linux_get_hwcap): New declaration.
(linux_get_hwcap2): Likewise.
* linux-ppc-low.c (ppc_get_auxv): Remove function.
(ppc_arch_setup): Call linux_get_hwcap.
* linux-s390-low.c (s390_get_hwcap): Remove function.
(s390_arch_setup): Call linux_get_hwcap.
marxin [Tue, 26 Mar 2019 09:40:04 +0000 (10:40 +0100)]
Provide string description of definition, visibility and resolution in LTO plug-in.
ld/ChangeLog:
2019-02-26 Martin Liska <mliska@suse.cz>
* plugin.c (get_symbols): Add lto_kind_str, lto_resolution_str,
lto_visibility_str and use then to inform about plugin-symbols.
* testsuite/ld-plugin/plugin-12.d: Adjust expected pattern.
Nick Clifton [Tue, 26 Mar 2019 12:48:13 +0000 (12:48 +0000)]
Take over Dave Brolley's maintainerships for FR30, FRV and MEP.
* MAINTAINERS: Take over Dave Brolley's maintainerships for FR30,
FRV and MEP.
Alan Hayward [Tue, 26 Mar 2019 11:35:23 +0000 (11:35 +0000)]
Fix Arm build
Add missing include.
2019-03-26 Alan Hayward <alan.hayward@arm.com>
* arm-linux-nat.c: Add include.
Simon Marchi [Tue, 26 Mar 2019 00:29:18 +0000 (20:29 -0400)]
Fix use-after-free in source_cache::get_source_lines
Commit
ab42892fb7d2 ("Fix vertical scrolling of TUI source window")
introduced a use-after-free in source_cache::get_source_lines.
At the beginning of the method, we get the fullname of the symtab:
const char *fullname = symtab_to_fullname (s);
fullname points to the string owned by the symtab (s.fullname). When we
later do
scoped_fd desc = open_source_file (s);
s.fullname gets reallocated (even though the string contents may not
change). The fullname local variable now points to freed memory.
To avoid it, refresh the value of fullname after calling
open_source_file.
Here is the ASan report:
$ ./gdb -nx --data-directory=data-directory ./a.out
(gdb) start
Temporary breakpoint 1 at 0x1130: file test.cpp, line 12.
Starting program: /home/simark/build/binutils-gdb/gdb/a.out
Temporary breakpoint 1, main () at test.cpp:12
=================================================================
==26068==ERROR: AddressSanitizer: heap-use-after-free on address 0x6210003d4100 at pc 0x7fed89a34681 bp 0x7ffd8d185d80 sp 0x7ffd8d185528
READ of size 2 at 0x6210003d4100 thread T0
#0 0x7fed89a34680 in __interceptor_strlen /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:301
#1 0x55b6edf6c2f7 in std::char_traits<char>::length(char const*) /usr/include/c++/8.2.1/bits/char_traits.h:320
#2 0x55b6edf6c9b2 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) /usr/include/c++/8.2.1/bits/basic_string.h:516
#3 0x55b6ef09121b in source_cache::get_source_lines(symtab*, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) /home/simark/src/binutils-gdb/gdb/source-cache.c:214
#4 0x55b6ef0a15cb in print_source_lines_base /home/simark/src/binutils-gdb/gdb/source.c:1340
#5 0x55b6ef0a2045 in print_source_lines(symtab*, int, int, enum_flags<print_source_lines_flag>) /home/simark/src/binutils-gdb/gdb/source.c:1415
#6 0x55b6ef112c87 in print_frame_info(frame_info*, int, print_what, int, int) /home/simark/src/binutils-gdb/gdb/stack.c:914
#7 0x55b6ef10e90d in print_stack_frame(frame_info*, int, print_what, int) /home/simark/src/binutils-gdb/gdb/stack.c:180
#8 0x55b6ee9592f8 in print_stop_location /home/simark/src/binutils-gdb/gdb/infrun.c:7853
#9 0x55b6ee95948f in print_stop_event(ui_out*) /home/simark/src/binutils-gdb/gdb/infrun.c:7870
#10 0x55b6ef34b962 in tui_on_normal_stop /home/simark/src/binutils-gdb/gdb/tui/tui-interp.c:98
#11 0x55b6ee01a14d in std::_Function_handler<void (bpstats*, int), void (*)(bpstats*, int)>::_M_invoke(std::_Any_data const&, bpstats*&&, int&&) /usr/include/c++/8.2.1/bits/std_function.h:297
#12 0x55b6ee965415 in std::function<void (bpstats*, int)>::operator()(bpstats*, int) const /usr/include/c++/8.2.1/bits/std_function.h:687
#13 0x55b6ee962f1b in gdb::observers::observable<bpstats*, int>::notify(bpstats*, int) const /home/simark/src/binutils-gdb/gdb/common/observable.h:106
#14 0x55b6ee95a6e7 in normal_stop() /home/simark/src/binutils-gdb/gdb/infrun.c:8142
#15 0x55b6ee93f236 in fetch_inferior_event(void*) /home/simark/src/binutils-gdb/gdb/infrun.c:3782
#16 0x55b6ee8f2641 in inferior_event_handler(inferior_event_type, void*) /home/simark/src/binutils-gdb/gdb/inf-loop.c:43
#17 0x55b6eea2a1f0 in handle_target_event /home/simark/src/binutils-gdb/gdb/linux-nat.c:4358
#18 0x55b6ee7045f1 in handle_file_event /home/simark/src/binutils-gdb/gdb/event-loop.c:733
#19 0x55b6ee704e89 in gdb_wait_for_event /home/simark/src/binutils-gdb/gdb/event-loop.c:859
#20 0x55b6ee7027b5 in gdb_do_one_event() /home/simark/src/binutils-gdb/gdb/event-loop.c:322
#21 0x55b6ee702907 in start_event_loop() /home/simark/src/binutils-gdb/gdb/event-loop.c:371
#22 0x55b6eeadfc16 in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:331
#23 0x55b6eeae2ef9 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1174
#24 0x55b6eeae30c2 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1190
#25 0x55b6edf4fa89 in main /home/simark/src/binutils-gdb/gdb/gdb.c:32
#26 0x7fed88ad8222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)
#27 0x55b6edf4f86d in _start (/home/simark/build/binutils-gdb/gdb/gdb+0x197186d)
0x6210003d4100 is located 0 bytes inside of 4096-byte region [0x6210003d4100,0x6210003d5100)
freed by thread T0 here:
#0 0x7fed89a8ac19 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:66
#1 0x55b6edfe12df in xfree<char> /home/simark/src/binutils-gdb/gdb/common/common-utils.h:60
#2 0x55b6edfea675 in gdb::xfree_deleter<char>::operator()(char*) const /home/simark/src/binutils-gdb/gdb/common/gdb_unique_ptr.h:34
#3 0x55b6edfe532c in std::unique_ptr<char, gdb::xfree_deleter<char> >::reset(char*) /usr/include/c++/8.2.1/bits/unique_ptr.h:382
#4 0x55b6edfe7329 in std::unique_ptr<char, gdb::xfree_deleter<char> >::operator=(std::unique_ptr<char, gdb::xfree_deleter<char> >&&) /usr/include/c++/8.2.1/bits/unique_ptr.h:289
#5 0x55b6ef09ec2b in find_and_open_source(char const*, char const*, std::unique_ptr<char, gdb::xfree_deleter<char> >*) /home/simark/src/binutils-gdb/gdb/source.c:990
#6 0x55b6ef09f56a in open_source_file(symtab*) /home/simark/src/binutils-gdb/gdb/source.c:1069
#7 0x55b6ef090f78 in source_cache::get_source_lines(symtab*, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) /home/simark/src/binutils-gdb/gdb/source-cache.c:205
#8 0x55b6ef0a15cb in print_source_lines_base /home/simark/src/binutils-gdb/gdb/source.c:1340
#9 0x55b6ef0a2045 in print_source_lines(symtab*, int, int, enum_flags<print_source_lines_flag>) /home/simark/src/binutils-gdb/gdb/source.c:1415
#10 0x55b6ef112c87 in print_frame_info(frame_info*, int, print_what, int, int) /home/simark/src/binutils-gdb/gdb/stack.c:914
#11 0x55b6ef10e90d in print_stack_frame(frame_info*, int, print_what, int) /home/simark/src/binutils-gdb/gdb/stack.c:180
#12 0x55b6ee9592f8 in print_stop_location /home/simark/src/binutils-gdb/gdb/infrun.c:7853
#13 0x55b6ee95948f in print_stop_event(ui_out*) /home/simark/src/binutils-gdb/gdb/infrun.c:7870
#14 0x55b6ef34b962 in tui_on_normal_stop /home/simark/src/binutils-gdb/gdb/tui/tui-interp.c:98
#15 0x55b6ee01a14d in std::_Function_handler<void (bpstats*, int), void (*)(bpstats*, int)>::_M_invoke(std::_Any_data const&, bpstats*&&, int&&) /usr/include/c++/8.2.1/bits/std_function.h:297
#16 0x55b6ee965415 in std::function<void (bpstats*, int)>::operator()(bpstats*, int) const /usr/include/c++/8.2.1/bits/std_function.h:687
#17 0x55b6ee962f1b in gdb::observers::observable<bpstats*, int>::notify(bpstats*, int) const /home/simark/src/binutils-gdb/gdb/common/observable.h:106
#18 0x55b6ee95a6e7 in normal_stop() /home/simark/src/binutils-gdb/gdb/infrun.c:8142
#19 0x55b6ee93f236 in fetch_inferior_event(void*) /home/simark/src/binutils-gdb/gdb/infrun.c:3782
#20 0x55b6ee8f2641 in inferior_event_handler(inferior_event_type, void*) /home/simark/src/binutils-gdb/gdb/inf-loop.c:43
#21 0x55b6eea2a1f0 in handle_target_event /home/simark/src/binutils-gdb/gdb/linux-nat.c:4358
#22 0x55b6ee7045f1 in handle_file_event /home/simark/src/binutils-gdb/gdb/event-loop.c:733
#23 0x55b6ee704e89 in gdb_wait_for_event /home/simark/src/binutils-gdb/gdb/event-loop.c:859
#24 0x55b6ee7027b5 in gdb_do_one_event() /home/simark/src/binutils-gdb/gdb/event-loop.c:322
#25 0x55b6ee702907 in start_event_loop() /home/simark/src/binutils-gdb/gdb/event-loop.c:371
#26 0x55b6eeadfc16 in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:331
#27 0x55b6eeae2ef9 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1174
#28 0x55b6eeae30c2 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1190
#29 0x55b6edf4fa89 in main /home/simark/src/binutils-gdb/gdb/gdb.c:32
previously allocated by thread T0 here:
#0 0x7fed89a8b019 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:86
#1 0x7fed88af983f in realpath@@GLIBC_2.3 (/usr/lib/libc.so.6+0x4583f)
#2 0x7fed899dbbbc in __interceptor_canonicalize_file_name /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:3297
#3 0x55b6ee376a03 in gdb_realpath(char const*) /home/simark/src/binutils-gdb/gdb/common/pathstuff.c:72
#4 0x55b6ef09ec12 in find_and_open_source(char const*, char const*, std::unique_ptr<char, gdb::xfree_deleter<char> >*) /home/simark/src/binutils-gdb/gdb/source.c:990
#5 0x55b6ef09f56a in open_source_file(symtab*) /home/simark/src/binutils-gdb/gdb/source.c:1069
#6 0x55b6ef0a0f12 in print_source_lines_base /home/simark/src/binutils-gdb/gdb/source.c:1270
#7 0x55b6ef0a2045 in print_source_lines(symtab*, int, int, enum_flags<print_source_lines_flag>) /home/simark/src/binutils-gdb/gdb/source.c:1415
#8 0x55b6ef112c87 in print_frame_info(frame_info*, int, print_what, int, int) /home/simark/src/binutils-gdb/gdb/stack.c:914
#9 0x55b6ef10e90d in print_stack_frame(frame_info*, int, print_what, int) /home/simark/src/binutils-gdb/gdb/stack.c:180
#10 0x55b6ee9592f8 in print_stop_location /home/simark/src/binutils-gdb/gdb/infrun.c:7853
#11 0x55b6ee95948f in print_stop_event(ui_out*) /home/simark/src/binutils-gdb/gdb/infrun.c:7870
#12 0x55b6ef34b962 in tui_on_normal_stop /home/simark/src/binutils-gdb/gdb/tui/tui-interp.c:98
#13 0x55b6ee01a14d in std::_Function_handler<void (bpstats*, int), void (*)(bpstats*, int)>::_M_invoke(std::_Any_data const&, bpstats*&&, int&&) /usr/include/c++/8.2.1/bits/std_function.h:297
#14 0x55b6ee965415 in std::function<void (bpstats*, int)>::operator()(bpstats*, int) const /usr/include/c++/8.2.1/bits/std_function.h:687
#15 0x55b6ee962f1b in gdb::observers::observable<bpstats*, int>::notify(bpstats*, int) const /home/simark/src/binutils-gdb/gdb/common/observable.h:106
#16 0x55b6ee95a6e7 in normal_stop() /home/simark/src/binutils-gdb/gdb/infrun.c:8142
#17 0x55b6ee93f236 in fetch_inferior_event(void*) /home/simark/src/binutils-gdb/gdb/infrun.c:3782
#18 0x55b6ee8f2641 in inferior_event_handler(inferior_event_type, void*) /home/simark/src/binutils-gdb/gdb/inf-loop.c:43
#19 0x55b6eea2a1f0 in handle_target_event /home/simark/src/binutils-gdb/gdb/linux-nat.c:4358
#20 0x55b6ee7045f1 in handle_file_event /home/simark/src/binutils-gdb/gdb/event-loop.c:733
#21 0x55b6ee704e89 in gdb_wait_for_event /home/simark/src/binutils-gdb/gdb/event-loop.c:859
#22 0x55b6ee7027b5 in gdb_do_one_event() /home/simark/src/binutils-gdb/gdb/event-loop.c:322
#23 0x55b6ee702907 in start_event_loop() /home/simark/src/binutils-gdb/gdb/event-loop.c:371
#24 0x55b6eeadfc16 in captured_command_loop /home/simark/src/binutils-gdb/gdb/main.c:331
#25 0x55b6eeae2ef9 in captured_main /home/simark/src/binutils-gdb/gdb/main.c:1174
#26 0x55b6eeae30c2 in gdb_main(captured_main_args*) /home/simark/src/binutils-gdb/gdb/main.c:1190
#27 0x55b6edf4fa89 in main /home/simark/src/binutils-gdb/gdb/gdb.c:32
#28 0x7fed88ad8222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)
gdb/ChangeLog:
* source-cache.c (source_cache::get_source_lines): Re-read
fullname after calling open_source_file.
GDB Administrator [Tue, 26 Mar 2019 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Mon, 25 Mar 2019 22:29:11 +0000 (08:59 +1030)]
Fix relpp may be used uninitialized
* objdump.c (dump_relocs_in_section): Warning fix.
John Baldwin [Mon, 25 Mar 2019 20:23:26 +0000 (13:23 -0700)]
Note support for TLS variables on FreeBSD.
gdb/ChangeLog:
* NEWS: Mention TLS support for FreeBSD.
Tom Tromey [Mon, 25 Mar 2019 19:45:57 +0000 (13:45 -0600)]
Clean up some comments in minsyms.c
Philippe pointed out that some comments in minsyms.c still referred to
obstack allocation. This patch fixes these up.
In most cases here, my view is that the comments were more misleading
than helpful. So, I've generally removed text.
gdb/ChangeLog
2019-03-25 Tom Tromey <tromey@adacore.com>
* minsyms.c (BUNCH_SIZE): Update comment.
(~minimal_symbol_reader): Remove old comment.
(compact_minimal_symbols): Update comment.
(minimal_symbol_reader::install): Remove old comment. Update
other comments.
Alan Hayward [Mon, 25 Mar 2019 17:02:28 +0000 (17:02 +0000)]
Fix s390 build
Add missing include.
2019-03-25 Alan Hayward <alan.hayward@arm.com>
* s390-linux-nat.c: Add include.
Alan Hayward [Mon, 25 Mar 2019 16:48:03 +0000 (16:48 +0000)]
Add linux_get_hwcap
Tidy up calls to read HWCAP (and HWCAP2) by adding common functions,
removing the PPC and AArch64 specific versions.
The only function difference is in aarch64_linux_core_read_description - if
the hwcap read fails it now return a valid description instead of nullptr.
gdb/ChangeLog:
2019-03-25 Alan Hayward <alan.hayward@arm.com>
* aarch64-linux-nat.c (aarch64_linux_nat_target::read_description):
Call linux_get_hwcap.
* aarch64-linux-tdep.c (aarch64_linux_core_read_description):
Likewise.
(aarch64_linux_get_hwcap): Remove function.
* aarch64-linux-tdep.h (aarch64_linux_get_hwcap): Remove
declaration.
* arm-linux-nat.c (arm_linux_nat_target::read_description):Call
linux_get_hwcap.
* arm-linux-tdep.c (arm_linux_core_read_description): Likewise.
* linux-tdep.c (linux_get_hwcap): Add function.
(linux_get_hwcap2): Likewise.
* linux-tdep.h (linux_get_hwcap): Add declaration.
(linux_get_hwcap2): Likewise.
* ppc-linux-nat.c (ppc_linux_get_hwcap): Remove function.
(ppc_linux_get_hwcap2): Likewise.
(ppc_linux_nat_target::region_ok_for_hw_watchpoint): Call
linux_get_hwcap.
(ppc_linux_nat_target::insert_watchpoint): Likewise.
(ppc_linux_nat_target::watchpoint_addr_within_range): Likewise.
(ppc_linux_nat_target::read_description): Likewise.
* ppc-linux-tdep.c (ppc_linux_core_read_description): Likewise.
* s390-linux-nat.c: Likewise.
* s390-linux-tdep.c (s390_core_read_description): Likewise.
Tamar Christina [Mon, 25 Mar 2019 12:16:17 +0000 (12:16 +0000)]
Arm: Fix Arm disassembler mapping symbol search.
Similar to the AArch64 patches the Arm disassembler has the same issues with
out of order sections but also a few short comings.
For one thing there are multiple code blocks to determine mapping symbols, and
they all work slightly different, and neither fully correct. The first thing
this patch does is centralise the mapping symbols search into one function
mapping_symbol_for_insn. This function is then updated to perform a search in
a similar way as AArch64.
Their used to be a value has_mapping_symbols which was used to determine the
default disassembly for objects that have no mapping symbols. The problem with
the approach was that it was determining this value in the same loop that needed
it, which is why this field could take on the states -1, 0, 1 where -1 means
"don't know". However this means that until you actually find a mapping symbol
or reach the end of the disassembly glob, you don't know if you did the right
action or not, and if you didn't you can't correct it anymore.
This is why the two jump-reloc-veneers-* testcases end up disassembling some
insn as data when they shouldn't.
Out of order here refers to an object file where sections are not listed in a
monotonic increasing VMA order.
The ELF ABI for Arm [1] specifies the following for mapping symbols:
1) A text section must always have a corresponding mapping symbol at it's
start.
2) Data sections do not require any mapping symbols.
3) The range of a mapping symbol extends from the address it starts on up to
the next mapping symbol (exclusive) or section end (inclusive).
However there is no defined order between a symbol and it's corresponding
mapping symbol in the symbol table. This means that while in general we look
up for a corresponding mapping symbol, we have to make at least one check of
the symbol below the address being disassembled.
When disassembling different PCs within the same section, the search for mapping
symbol can be cached somewhat. We know that the mapping symbol corresponding to
the current PC is either the previous one used, or one at the same address as
the current PC.
However this optimization and mapping symbol search must stop as soon as we
reach the end or start of the section. Furthermore if we're only disassembling
a part of a section, the search is a allowed to search further than the current
chunk, but is not allowed to search past it (The mapping symbol if there, must
be at the same address, so in practice we usually stop at PC+4).
lastly, since only data sections don't require a mapping symbol the default
mapping type should be DATA and not INSN as previously defined, however if the
binary has had all its symbols stripped than this isn't very useful. To fix
this we determine the default based on the section flags. This will allow the
disassembler to be more useful on stripped binaries. If there is no section
than we assume you to be disassembling INSN.
[1] https://developer.arm.com/docs/ihi0044/latest/elf-for-the-arm-architecture-abi-2018q4-documentation#aaelf32-table4-7
binutils/ChangeLog:
* testsuite/binutils-all/arm/in-order-all.d: New test.
* testsuite/binutils-all/arm/in-order.d: New test.
* testsuite/binutils-all/arm/objdump.exp: Support .d tests.
* testsuite/binutils-all/arm/out-of-order-all.d: New test.
* testsuite/binutils-all/arm/out-of-order.T: New test.
* testsuite/binutils-all/arm/out-of-order.d: New test.
* testsuite/binutils-all/arm/out-of-order.s: New test.
ld/ChangeLog:
* testsuite/ld-arm/jump-reloc-veneers-cond-long.d: Update disassembly.
* testsuite/ld-arm/jump-reloc-veneers-long.d: Update disassembly.
opcodes/ChangeLog:
* arm-dis.c (struct arm_private_data): Remove has_mapping_symbols.
(mapping_symbol_for_insn): Implement new algorithm.
(print_insn): Remove duplicate code.
Tamar Christina [Mon, 25 Mar 2019 12:14:37 +0000 (12:14 +0000)]
AArch64: Have -D override mapping symbol as documented.
The documentation for -D says that on Arm platforms -D should disassemble
data as instructions.
"If the target is an ARM architecture this switch also has the effect of
forcing the disassembler to decode pieces of data found in code sections
as if they were instructions. "
This makes it do as it says on the tincan so it's more consistent with
aarch32. The usecase here is for baremetal developers who have created
their instructions using .word directives instead if .insn.
Though for Linux users I do find this behavior somewhat non-optimal.
Perhaps there should be a new flag that just disassembles the values
following the actual mapping symbol?
binutils/ChangeLog:
* testsuite/binutils-all/aarch64/in-order-all.d: New test.
* testsuite/binutils-all/aarch64/out-of-order-all.d: New test.
* testsuite/binutils-all/aarch64/out-of-order.d:
opcodes/ChangeLog:
* aarch64-dis.c (print_insn_aarch64):
Implement override.
Tamar Christina [Mon, 25 Mar 2019 12:12:03 +0000 (12:12 +0000)]
AArch64: Fix AArch64 disassembler mapping symbol search
My previous patch for AArch64 was not enough to catch all the cases where
disassembling an out-of-order section could go wrong. It had missed the case
DATA sections could be incorrectly disassembled as TEXT.
Out of order here refers to an object file where sections are not listed in a
monotonic increasing VMA order.
The ELF ABI for AArch64 [1] specifies the following for mapping symbols:
1) A text section must always have a corresponding mapping symbol at it's
start.
2) Data sections do not require any mapping symbols.
3) The range of a mapping symbol extends from the address it starts on up to
the next mapping symbol (exclusive) or section end (inclusive).
However there is no defined order between a symbol and it's corresponding
mapping symbol in the symbol table. This means that while in general we look
up for a corresponding mapping symbol, we have to make at least one check of
the symbol below the address being disassembled.
When disassembling different PCs within the same section, the search for mapping
symbol can be cached somewhat. We know that the mapping symbol corresponding to
the current PC is either the previous one used, or one at the same address as
the current PC.
However this optimization and mapping symbol search must stop as soon as we
reach the end or start of the section. Furthermore if we're only disassembling
a part of a section, the search is a allowed to search further than the current
chunk, but is not allowed to search past it (The mapping symbol if there, must
be at the same address, so in practice we usually stop at PC+4).
lastly, since only data sections don't require a mapping symbol the default
mapping type should be DATA and not INSN as previously defined, however if the
binary has had all its symbols stripped than this isn't very useful. To fix this
we determine the default based on the section flags. This will allow the
disassembler to be more useful on stripped binaries. If there is no section than
we assume you to be disassembling INSN.
[1] https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4#aaelf64-section4-5-4
binutils/ChangeLog:
* testsuite/binutils-all/aarch64/in-order.d: New test.
* testsuite/binutils-all/aarch64/out-of-order.d: Disassemble data as
well.
opcodes/ChangeLog:
* aarch64-dis.c (print_insn_aarch64): Update the mapping symbol search
order.
Tamar Christina [Mon, 25 Mar 2019 12:08:53 +0000 (12:08 +0000)]
AArch64: Fix disassembler bug with out-of-order sections
The AArch64 disassembler has an optimization that it uses to reduce the amount
it has to search for mapping symbols during disassembly. This optimization
assumes that sections are listed in the section header in monotonic increasing
VMAs. However this is not a requirement for the ELF specification.
Because of this when such "out of order" sections occur the disassembler would
pick the wrong mapping symbol to disassemble the section with.
This fixes it by explicitly passing along the stop offset for the current
disassembly glob and when this changes compared to the previous one we've seen
the optimization won't be performed. In effect this restarts the search from
a well defined starting point. Usually the symbol's address.
The existing stop_vma can't be used for this as it is allowed to be unset and
setting this unconditionally would change the semantics of this field.
binutils/ChangeLog:
* objdump.c (disassemble_bytes): Pass stop_offset.
* testsuite/binutils-all/aarch64/out-of-order.T: New test.
* testsuite/binutils-all/aarch64/out-of-order.d: New test.
* testsuite/binutils-all/aarch64/out-of-order.s: New test.
include/ChangeLog:
* dis-asm.h (struct disassemble_info): Add stop_offset.
opcodes/ChangeLog:
* aarch64-dis.c (last_stop_offset): New.
(print_insn_aarch64): Use stop_offset.
Pedro Alves [Mon, 25 Mar 2019 13:26:23 +0000 (13:26 +0000)]
Fix testsuite hangs when gdb_test_multiple body errors out
This commit fixes a regression in the testsuite itself, triggered by
errors being raised from within gdb_test_multiple, originally reported
by Pedro Franco de Carvalho's at
<https://sourceware.org/ml/gdb-patches/2019-03/msg00160.html>. Parts
of the commit message are based on his report.
This started happening due to a commit that was introduced recently,
and it can cause the testsuite to hang.
The commit that triggers this is:
fe1a5cad302b5535030cdf62895e79512713d738
[gdb/testsuite] Log wait status on process no longer exists error
That commit introduces a new "eof" block in gdb_test_multiple. That
is not incorrect itself, but dejagnu's remote_expect is picking that
block as the "default" action when an error is raised from within the
commands inside a call to gdb_test_multiple:
# remote_expect works basically the same as standard expect, but it
# also takes care of getting the file descriptor from the specified
# host and also calling the timeout/eof/default section if there is an
# error on the expect call.
#
proc remote_expect { board timeout args } {
I find that "feature" surprising, and I don't really know why it
exists, but this means that the eof section that remote_expect picks
as the error block can be executed even when there was no actual eof
and the GDB process is still running, so the wait introduced in the
commit that tries to get the exit status of GDB hangs forever, while
GDB itself waits for input.
This only happens when there are internal testsuite errors (not
testcase failures). This can be reproduced easily with a testcase
such as:
gdb_start
gdb_test_multiple "show version" "show version" {
-re ".*" {
error "forced error"
}
}
I think that working around this in GDB is useful so that the
testsuite doesn't hang in these cases.
Adding an empty "default" block at the end of the expect body in
gdb_test_multiple doesn't work, because dejagnu gives preference to
"eof" blocks:
if { $x eq "eof" } {
set save_next 1
} elseif { $x eq "default" || $x eq "timeout" } {
if { $error_sect eq "" } {
set save_next 1
}
}
And we do have "eof" blocks. So we need to make sure that the last
"eof" block is safe to use as the default error block. It's also
pedantically incorrect to print
"ERROR: Process no longer exists"
which is what we'd get if the last eof block we have was selected
(more below on this).
So this commit solves this by appending an "eof" with an empty
spawn_id list, so that it won't ever match.
Now, why is the first "eof" block selected today as the error block,
instead of the last one?
The reason is that remote_expect, while parsing the body to select the
default block to execute after an error, is affected by the comments
in the body (since they are also parsed).
If this comment in gdb_test_multiple
# patterns below apply to any spawn id specified.
is changed to
# The patterns below apply to any spawn id specified.
then the second eof block is selected and there is no hang.
Any comment at that same place with an even number of tokens also
works.
This is IMO a coincidence caused by how comments work in TCL.
Comments should only appear in places where a command can appear. And
here, remote_expect is parsing a list of options, not commands, so
it's not unreasonable to not parse comments, similarly to how this:
set a_list {
an_element
# another_element
}
results in a list with three elements, not one element.
The fact that comments with an even number of tokens work is just a
coincidence of how remote_expect's little state machine is
implemented.
I thought we could solve this by stripping out comment lines in
gdb_expect, but I didn't find an easy way to do that. Particularly, a
couple naive approaches I tried run into complications. For example,
we have gdb_test calls with regular expressions that include sequences
like "\r\n#", and by the time we get to gdb_expect, the \r\n have
already been expanded to a real newline, so just splitting the whole
body at newline boundaries, looking for lines that start with #
results in incorrectly stripping out half of the gdb_text regexp. I
think it's better (at least in this commit), to move the comments out
of the list, because it's much simpler and risk free.
gdb/testsuite/ChangeLog:
2019-03-25 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_test_multiple): Split appends to $code and
move comments outside list. Append '-i "" eof' section.
Tom Tromey [Fri, 22 Mar 2019 22:53:12 +0000 (16:53 -0600)]
Remove null_block_symbol
This removes null_block_symbol. It seemed simpler to me to change
initializations and returns to use value initialization rather than
null_block_symbol. This also fixes up a few spots where
initialization was done piecemeal.
gdb/ChangeLog
2019-03-24 Tom Tromey <tom@tromey.com>
* ada-lang.c (standard_lookup): Simplify initialization.
(ada_lookup_symbol_nonlocal): Simplify return.
* solib-spu.c (spu_lookup_lib_symbol): Simplify return.
* solib-darwin.c (darwin_lookup_lib_symbol): Simplify return.
* solib-svr4.c (elf_lookup_lib_symbol): Simplify return.
* rust-lang.c (rust_lookup_symbol_nonlocal): Simplify
initialization.
* solib.c (solib_global_lookup): Simplify.
* symtab.c (null_block_symbol): Remove.
(symbol_cache_lookup): Simplify returns.
(lookup_language_this): Simplify returns.
(lookup_symbol_aux): Simplify return.
(lookup_local_symbol): Simplify returns.
(lookup_global_symbol_from_objfile): Simplify return.
(lookup_symbol_in_objfile_symtabs)
(lookup_symbol_in_objfile_from_linkage_name): Simplify return.
(lookup_symbol_via_quick_fns, lookup_symbol_in_static_block)
(lookup_static_symbol, lookup_global_symbol): Simplify return.
* cp-namespace.c (cp_lookup_bare_symbol)
(cp_search_static_and_baseclasses, cp_lookup_symbol_via_imports)
(cp_lookup_symbol_via_all_imports, cp_lookup_nested_symbol_1)
(cp_lookup_nested_symbol): Don't use null_block_symbol.
(cp_lookup_symbol_via_imports): Simplify initialization.
(find_symbol_in_baseclass): Likewise.
* symtab.h (null_block_symbol): Remove.
* d-namespace.c (d_lookup_symbol): Don't use null_block_symbol.
(d_lookup_nested_symbol, d_lookup_symbol_imports)
(d_lookup_symbol_module): Likewise.
(find_symbol_in_baseclass): Simplify initialization.
Tom Tromey [Fri, 22 Mar 2019 22:06:36 +0000 (16:06 -0600)]
Don't include symtab.h from expression.h
expression.h includes symtab.h, but apparently only for the
declaration of struct block. This patch changes it to foward-declare
the structure, and remove the include.
gdb/ChangeLog
2019-03-24 Tom Tromey <tom@tromey.com>
* expression.h: Don't include symtab.h.
(struct block): Forward declare.
Tom Tromey [Fri, 22 Mar 2019 21:54:10 +0000 (15:54 -0600)]
More block constification
I noticed that there are still many places referring to non-const
blocks. This constifies all the remaining ones that I found that
could be constified.
In a few spots, this search found unused variables or fields. I
removed these. I've also removed some unnecessary casts to
"struct block *".
gdb/ChangeLog
2019-03-24 Tom Tromey <tom@tromey.com>
* c-exp.y (typebase): Remove casts.
* gdbtypes.c (lookup_unsigned_typename, )
(lookup_signed_typename): Remove cast.
* eval.c (parse_to_comma_and_eval): Remove cast.
* parse.c (write_dollar_variable): Remove cast.
* block.h (struct block) <superblock>: Now const.
* symfile-debug.c (debug_qf_map_matching_symbols): Update.
* psymtab.c (psym_map_matching_symbols): Make "block" const.
(map_block): Make "block" const.
* symfile.h (struct quick_symbol_functions)
<map_matching_symbols>: Constify block argument to "callback".
* symtab.c (basic_lookup_transparent_type_quick): Make "block"
const.
(find_pc_sect_compunit_symtab): Make "b" const.
(find_symbol_at_address): Likewise.
(search_symbols): Likewise.
* dwarf2read.c (dw2_lookup_symbol): Make "block" const.
(dw2_debug_names_lookup_symbol): Likewise.
(dw2_map_matching_symbols): Update.
* p-valprint.c (pascal_val_print): Remove "block".
* ada-lang.c (ada_add_global_exceptions): Make "b" const.
(aux_add_nonlocal_symbols): Make "block" const.
(resolve_subexp): Remove cast.
* linespec.c (iterate_over_all_matching_symtabs): Make "block"
const.
(iterate_over_file_blocks): Likewise.
* f-exp.y (%union) <bval>: Remove.
* coffread.c (patch_opaque_types): Make "b" const.
* spu-tdep.c (spu_catch_start): Make "block" const.
* c-valprint.c (print_unpacked_pointer): Remove "block".
* symmisc.c (dump_symtab_1): Make "b" const.
(block_depth): Make "block" const.
* d-exp.y (%union) <bval>: Remove.
* cp-support.h (cp_lookup_rtti_type): Update.
* cp-support.c (cp_lookup_rtti_type): Make "block" const.
* psymtab.c (psym_lookup_symbol): Make "block" const.
(maintenance_check_psymtabs): Make "b" const.
* python/py-framefilter.c (extract_sym): Make "sym_block" const.
(enumerate_locals, enumerate_args): Update.
* python/py-symtab.c (stpy_global_block): Make "block" const.
(stpy_static_block): Likewise.
* inline-frame.c (block_starting_point_at): Make "new_block"
const.
* block.c (find_block_in_blockvector): Make return type const.
(blockvector_for_pc_sect): Make "b" const.
(find_block_in_blockvector): Make "b" const.
GDB Administrator [Mon, 25 Mar 2019 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Philippe Waroquiers [Sun, 24 Mar 2019 10:44:00 +0000 (11:44 +0100)]
(re-)fix the regcache leaks when detaching from an executable.
Commit
799efbe8e01ab8292c01f46ac59a6fb2349d4535 was supposed to fix
the below leak. However, for this fix to work, it is critical to
save the ptid before detach.
This commit (pushed as OBVIOUS, as the change was already reviewed/approved)
saves the ptid before the detach, as in the original reviewed patch
(see https://sourceware.org/ml/gdb-patches/2019-02/msg00263.html).
Re-tested on debian/amd64, natively and under valgrind.
==7426== 1,123 (72 direct, 1,051 indirect) bytes in 1 blocks are definitely lost in loss record 2,872 of 3,020
==7426== at 0x4C2C4CC: operator new(unsigned long) (vg_replace_malloc.c:344)
==7426== by 0x5BD1E1: get_thread_arch_aspace_regcache(ptid_t, gdbarch*, address_space*) (regcache.c:330)
==7426== by 0x5BD39A: get_thread_regcache (regcache.c:366)
==7426== by 0x5BD39A: get_current_regcache() (regcache.c:372)
==7426== by 0x4B1EB4: get_current_frame() (frame.c:1588)
...
GDB Administrator [Sun, 24 Mar 2019 00:01:13 +0000 (00:01 +0000)]
Automatic date update in version.in
Tom Tromey [Sat, 23 Mar 2019 16:11:51 +0000 (10:11 -0600)]
Have parser reset the innermost block tracker
I ran across a comment in symfile.c today:
/* Clear globals which might have pointed into a removed objfile.
FIXME: It's not clear which of these are supposed to persist
between expressions and which ought to be reset each time. */
It seems to me that this can be clarified: the parser entry points
ought to reset the innermost block tracker (and the expression context
block), and these should not be considered valid for code to use at
arbitrary times -- only immediately after an expression has been
parsed.
This patch implements this idea. This could be further improved by
removing the parser globals and changing the parser functions to
return this information, but I have not done this.
Tested by the buildbot.
gdb/ChangeLog
2019-03-23 Tom Tromey <tom@tromey.com>
* varobj.c (varobj_create): Update.
* symfile.c (clear_symtab_users): Don't reset innermost_block.
* printcmd.c (display_command, do_one_display): Don't reset
innermost_block.
* parser-defs.h (enum innermost_block_tracker_type): Move to
expression.h.
(innermost_block): Update comment.
* parse.c (parse_exp_1): Add tracker_types parameter.
(parse_exp_in_context): Rename from parse_exp_in_context_1. Add
tracker_types parameter. Reset innermost_block.
(parse_exp_in_context): Remove.
(parse_expression_for_completion): Update.
* objfiles.c (~objfile): Don't reset expression_context_block or
innermost_block.
* expression.h (enum innermost_block_tracker_type): Move from
parser-defs.h.
(parse_exp_1): Add tracker_types parameter.
* breakpoint.c (set_breakpoint_condition, watch_command_1): Don't
reset innermost_block.
Tom Tromey [Sat, 23 Mar 2019 16:50:27 +0000 (10:50 -0600)]
Include bcache.h from objfiles.h
objfiles.h needs "struct bcache" to be complete, so it should include
bcache.h. This patch implements this.
Tested by rebuilding.
gdb/ChangeLog
2019-03-23 Tom Tromey <tom@tromey.com>
* objfiles.h: Include bcache.h.
Tom Tromey [Sat, 23 Mar 2019 15:43:49 +0000 (09:43 -0600)]
Use scoped_restore_current_language in two places
I found a couple of spots that manually saved and restored the current
language. This patch changes them to use
scoped_restore_current_language.
Tested by the buildbot.
gdb/ChangeLog
2019-03-23 Tom Tromey <tom@tromey.com>
* linespec.c (get_current_search_block): Use
scoped_restore_current_language.
* symmisc.c (dump_symtab): Use scoped_restore_current_language.
GDB Administrator [Sat, 23 Mar 2019 00:00:38 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Hayward [Fri, 22 Mar 2019 10:43:17 +0000 (10:43 +0000)]
AArch64: Read pauth section from core files
gdb/ChangeLog:
* aarch64-linux-tdep.c
(aarch64_linux_iterate_over_regset_sections): Check for pauth
section.
* aarch64-linux-tdep.h (AARCH64_LINUX_SIZEOF_PAUTH): New define.
Alan Hayward [Fri, 22 Mar 2019 10:41:15 +0000 (10:41 +0000)]
AArch64: Prologue scan unwinder support for signed return addresses
Pauth address signing is enabled at binary compile time. When enabled the
return addresses for functions may be mangled. This patch adds functionality
to restore the original address for use in the prologue scan unwinder.
In the prologue analyzer, check for PACIASP/PACIBSP (enable address mangling)
and AUTIASP/AUTIBSP (disable address mangling).
When unwinding the PC from the prologue, unmask the register if required.
Add a test case to the prologue tests.
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_analyze_prologue): Check for pauth
instructions.
(aarch64_analyze_prologue_test): Add PACIASP test.
(aarch64_prologue_prev_register): Unmask PC value.
Alan Hayward [Fri, 22 Mar 2019 10:39:11 +0000 (10:39 +0000)]
AArch64: DWARF unwinder support for signed return addresses
Pauth address signing is enabled at binary compile time. When enabled the
return addresses for functions may be mangled. This patch adds functionality
to restore the original address for use in the DWARF unwinder.
DW_CFA_AARCH64_negate_ra_state in a binary indicates the toggling of address
signing between enabled and disabled. Ensure the state is stored in the DWARF
register ra_state.
Ensure the pauth DWARF registers are initialised.
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_frame_unmask_address): New function.
(aarch64_dwarf2_prev_register): Unmask PC value.
(aarch64_dwarf2_frame_init_reg): Init pauth registers.
(aarch64_execute_dwarf_cfa_vendor_op): Check for
DW_CFA_AARCH64_negate_ra_state.
(aarch64_gdbarch_init): Add aarch64_execute_dwarf_cfa_vendor_op.
Alan Hayward [Fri, 22 Mar 2019 10:37:46 +0000 (10:37 +0000)]
AArch64: Add pauth DWARF registers
Map the pauth registers to DWARF.
Add a new pseudo register ra_state and also map this to DWARF. This register
is hidden from the user - prevent it from being read or written to. It will
be used for the unmangling of addresses.
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_dwarf_reg_to_regnum): Check for pauth
registers.
(aarch64_pseudo_register_name): Likewise.
(aarch64_pseudo_register_type): Likewise.
(aarch64_pseudo_register_reggroup_p): Likewise.
(aarch64_gdbarch_init): Add pauth registers.
* aarch64-tdep.h (AARCH64_DWARF_PAUTH_RA_STATE): New define.
(AARCH64_DWARF_PAUTH_DMASK): Likewise.
(AARCH64_DWARF_PAUTH_CMASK): Likewise.
(struct gdbarch_tdep): Add regnum for ra_state.
Alan Hayward [Fri, 22 Mar 2019 10:34:09 +0000 (10:34 +0000)]
AArch64: gdbserver: read pauth registers
Add the pauth registers to the regset lists.
Add a new regset type OPTIONAL_REGS which allows for the regset read to fail.
Once the read fails, it will not be checked again. This allows targets with
optional features to keep a single static regset_info structure.
gdb/ChangeLog:
* arch/aarch64.h (AARCH64_PAUTH_REGS_SIZE): New define.
gdb/gdbserver/ChangeLog:
* linux-aarch64-low.c (aarch64_store_pauthregset): New function.
* linux-low.c (regsets_store_inferior_registers): Allow optional reads
to fail.
* linux-low.h (enum regset_type): Add OPTIONAL_REGS.
Alan Hayward [Fri, 22 Mar 2019 10:31:02 +0000 (10:31 +0000)]
AArch64: Read pauth registers
Initialise the pauth registers when creating a target description, and store
the regnum of the first pauth register.
Use ptrace to read the registers in the pauth feature.
Do not allow the registers to be written.
gdb/ChangeLog:
* aarch64-linux-nat.c (fetch_pauth_masks_from_thread): New
function.
(aarch64_linux_nat_target::fetch_registers): Read pauth registers.
* aarch64-tdep.c (aarch64_cannot_store_register): New function.
(aarch64_gdbarch_init): Add puth registers.
* aarch64-tdep.h (struct gdbarch_tdep): Add pauth features.
* arch/aarch64.h (AARCH64_PAUTH_DMASK_REGNUM): New define.
(AARCH64_PAUTH_CMASK_REGNUM): Likewise.
Alan Hayward [Fri, 22 Mar 2019 10:00:28 +0000 (10:00 +0000)]
AArch64: Use HWCAP to detect pauth feature
Add aarch64_get_hwcap functions for reading the HWCAP.
From this extract the PACA value and use this to enable pauth.
gdb/ChangeLog:
* aarch64-linux-nat.c
(aarch64_linux_nat_target::read_description): Read PACA hwcap.
* aarch64-linux-tdep.c
(aarch64_linux_core_read_description): Likewise.
(aarch64_linux_get_hwcap): New function.
* aarch64-linux-tdep.h (AARCH64_HWCAP_PACA): New define.
(aarch64_linux_get_hwcap): New declaration.
gdb/gdbserver/ChangeLog:
* linux-aarch64-low.c (AARCH64_HWCAP_PACA): New define.
(aarch64_get_hwcap): New function.
(aarch64_arch_setup): Read APIA hwcap.
Alan Hayward [Fri, 22 Mar 2019 09:58:42 +0000 (09:58 +0000)]
AArch64: Add pointer authentication feature
Pointer Authentication is a new feature in AArch64 v8.3-a. When enabled in
the compiler, function return addresses will be mangled by the kernel.
Add register description xml and wire up to aarch64_linux_read_description.
This description includes the two pauth user registers.
Nothing yet uses the feature - that is added in later patches.
gdb/ChangeLog:
* aarch64-linux-nat.c
(aarch64_linux_nat_target::read_description): Add pauth param.
* aarch64-linux-tdep.c
(aarch64_linux_core_read_description): Likewise.
* aarch64-tdep.c (struct target_desc): Add in pauth.
(aarch64_read_description): Add pauth param.
(aarch64_gdbarch_init): Likewise.
* aarch64-tdep.h (aarch64_read_description): Likewise.
* arch/aarch64.c (aarch64_create_target_description): Likewise.
* arch/aarch64.h (aarch64_create_target_description): Likewise.
* features/Makefile: Add new files.
* features/aarch64-pauth.c: New file.
* features/aarch64-pauth.xml: New file.
gdb/doc/ChangeLog:
* gdb.texinfo: Describe pauth feature.
gdb/gdbserver/ChangeLog:
* linux-aarch64-ipa.c (get_ipa_tdesc): Add pauth param.
(initialize_low_tracepoint): Likewise.
* linux-aarch64-low.c (aarch64_arch_setup): Likewise.
* linux-aarch64-tdesc-selftest.c (aarch64_tdesc_test): Likewise.
* linux-aarch64-tdesc.c (struct target_desc): Likewise.
(aarch64_linux_read_description): Likewise.
* linux-aarch64-tdesc.h (aarch64_linux_read_description): Likewise.
Alan Hayward [Wed, 13 Feb 2019 12:28:38 +0000 (12:28 +0000)]
Testsuite: Ensure pie is disabled on some tests
Recent versions of Ubuntu and Debian default GCC to enable pie.
In dump.exp, pie will causes addresses to be out of range for IHEX.
In break-interp.exp, pie is explicitly set for some tests and assumed
to be disabled for the remainder.
Ensure pie is disabled for these tests when required.
In addition, add a pie option to gdb_compile to match the nopie option
and simplify use.
gdb/testsuite/ChangeLog:
* README: Add pie options.
* gdb.base/break-interp.exp: Ensure pie is disabled.
* gdb.base/dump.exp: Likewise.
* lib/gdb.exp (gdb_compile): Add pie option.
GDB Administrator [Fri, 22 Mar 2019 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Thu, 21 Mar 2019 22:08:48 +0000 (15:08 -0700)]
RISC-V: Fix linker crash in section symbol check.
sym is only set for local symbols. h is only set for global symbols. Gas
won't let me create a global section symbol, but bfd appears to have some
support for that, and I can't rule out that other assemblers might do this.
So we need to support both, and verify sym and h are non-NULL before using.
bfd/
PR 24365
* elfnn-riscv.c (riscv_elf_relocate_section): For STT_SECTION check,
verify sym non-NULL before using. Add identical check using h.
Sudakshina Das [Thu, 21 Mar 2019 16:20:21 +0000 (16:20 +0000)]
[BFD, AArch64, x86] Improve warning for --force-bti
The AArch64 linker option to turn on BTI (--force-bti) warns in case there are
input objects which have a missing GNU NOTE section for BTI. This patch is trying
to improve the warnings that come out.
In order to do so, I propose adding a new argument to elf_merge_gnu_properties
and the backend function merge_gnu_properties. This new argument makes sure
that we now pass both the objects along with the properties to which they
belong to. The x86 backend function has also been updated to match this
change.
*** bfd/ChangeLog ***
2019-03-21 Sudakshina Das <sudi.das@arm.com>
* elf-bfd.h (struct elf_backend_data): Add argument to
merge_gnu_properties.
* elf-properties.c (elf_merge_gnu_properties): Add argument to
itself and while calling bed->merge_gnu_properties.
(elf_merge_gnu_property_list): Update the calls for
elf_merge_gnu_properties.
* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
of --force-bti warning and add argument.
* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
warning.
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
* elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
declaration.
*** ld/ChangeLog ***
2019-03-21 Sudakshina Das <sudi.das@arm.com>
* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
* testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
* testsuite/ld-aarch64/bti-plt-6.d: Update warning.
* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
* testsuite/ld-aarch64/bti-warn.d: New test.
Alan Modra [Thu, 21 Mar 2019 05:31:08 +0000 (16:01 +1030)]
Adjust pr14156 test for m68hc1*
The test section alignment is unnecessarily high, overflowing the
m68hc11 page used by .init code.
* testsuite/ld-elf/fini2.s: Reduce alignment.
* testsuite/ld-elf/fini3.s: Likewise.
* testsuite/ld-elf/finin.s: Likewise.
* testsuite/ld-elf/init2.s: Likewise.
* testsuite/ld-elf/init3.s: Likewise.
* testsuite/ld-elf/initn.s: Likewise.
* testsuite/ld-elf/pr14156a.d: Don't xfail m68hc1*-* or xgate-*.
* testsuite/ld-elf/pr14156b.d: Don't xfail xgate-*.
Alan Modra [Thu, 21 Mar 2019 04:28:35 +0000 (14:58 +1030)]
Add SORT_NONE to .init and .fini in scripts
The special case for .init and .fini in update_wild_statements is
ineffective for .init or .fini wildcards inside other output sections.
The special case needs to be on the wildcard, not the output section.
This patch is belt and braces, both fixing update_wild_statements and
the scripts.
* scripttempl/alpha.sc, * scripttempl/armbpabi.sc,
* scripttempl/crisaout.sc, * scripttempl/elf32cr16.sc,
* scripttempl/elf32crx.sc, * scripttempl/elf32xc16x.sc,
* scripttempl/elf32xc16xl.sc, * scripttempl/elf32xc16xs.sc,
* scripttempl/elf64hppa.sc, * scripttempl/elf_chaos.sc,
* scripttempl/elfarc.sc, * scripttempl/elfarcv2.sc,
* scripttempl/elfd30v.sc, * scripttempl/elfm68hc11.sc,
* scripttempl/elfm68hc12.sc, * scripttempl/elfm9s12z.sc,
* scripttempl/elfmicroblaze.sc, * scripttempl/elfxgate.sc,
* scripttempl/elfxtensa.sc, * scripttempl/epiphany_4x4.sc,
* scripttempl/ft32.sc, * scripttempl/i386beos.sc,
* scripttempl/iq2000.sc, * scripttempl/mcorepe.sc,
* scripttempl/mep.sc, * scripttempl/mips.sc, * scripttempl/moxie.sc,
* scripttempl/pe.sc, * scripttempl/pep.sc, * scripttempl/ppcpe.sc,
* scripttempl/tic4xcoff.sc, * scripttempl/tic80coff.sc,
* scripttempl/v850.sc, * scripttempl/v850_rh850.sc,
* scripttempl/visium.sc, * scripttempl/xstormy16.sc: Add KEEP and
SORT_NONE to .init and .fini wildcards.
* scripttempl/elf32xc16x.sc,
* scripttempl/elf32xc16xl.sc,
* scripttempl/elf32xc16xs.sc: Add .fini wildcard.
* scripttempl/elf_chaos.sc: Add .init output section.
* scripttempl/elfd30v.sc: Remove duplicate .init.
* scripttempl/elfm68hc11.sc, * scripttempl/elfm68hc12.sc,
* scripttempl/elfm9s12z.sc, * scripttempl/elfxgate.sc: Remove
duplicate .init, and add .fini wildcard.
* scripttempl/ppcpe.sc (INIT, FINI): Delete.
* ldlang.c (update_wild_statements): Special case .init and
.fini in the wildcard, not the output section.
GDB Administrator [Thu, 21 Mar 2019 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Wed, 20 Mar 2019 22:09:18 +0000 (08:39 +1030)]
lm32-linux ld testsuite fails
A number of the fails are due to ld supporting the creation of shared
libraries but not allowing linking against them without using an
option like -Bdynamic.
FAIL: Symbol export class test (final shared object)
FAIL: PROVIDE_HIDDEN test 4
FAIL: PROVIDE_HIDDEN test 6
FAIL: PROVIDE_HIDDEN test 10
FAIL: PROVIDE_HIDDEN test 12
FAIL: Build pr22471b.so
FAIL: Build pr22649-2b.so
FAIL: Build pr22649-2d.so
FAIL: PR ld/20828 dynamic symbols with section GC (plain)
FAIL: PR ld/20828 dynamic symbols with section GC (version script)
FAIL: PR ld/20828 dynamic symbols with section GC (versioned)
FAIL: PR ld/21233 dynamic symbols with section GC (--undefined)
FAIL: PR ld/21233 dynamic symbols with section GC (--require-defined)
FAIL: PR ld/21233 dynamic symbols with section GC (EXTERN)
FAIL: Build pr22150
FAIL: PR ld/14170
FAIL: Link using broken linker script
FAIL: pr17068 link --as-needed lib in group
FAIL: ld-gc/pr20022
* emulparams/elf32lm32fd.sh (DYNAMIC_LINK): Undef.
Alan Modra [Wed, 20 Mar 2019 08:05:16 +0000 (18:35 +1030)]
Remove strip_underscore from struct emulation
This field is unused. I would have liked to also remove
leading_underscore and fake_label_name but in an i386-elf/coff/aout
multi-obj setup those fields are used to select a different
fake_label_name for aout.
* emul.h (struct emulation): Delete strip_underscore.
* emul-target.h (emul_strip_underscore): Don't define.
(emul_struct_name): Update initialization.