This patch convert aarch64_analyze_prologue to using aarch64_decode_insn
to decode instructions. After this change, aarch64_analyze_prologue
looks much simple, and some aarch64_decode_* functions are removed
accordingly.
gdb:
2015-11-05 Yao Qi <yao.qi@linaro.org>
* aarch64-tdep.c (extract_signed_bitfield): Remove.
(decode_masked_match): Remove.
(aarch64_decode_add_sub_imm): Remove.
(aarch64_decode_br): Remove.
(aarch64_decode_eret): Remove.
(aarch64_decode_movz): Remove.
(aarch64_decode_orr_shifted_register_x): Remove.
(aarch64_decode_ret): Remove.
(aarch64_decode_stp_offset): Remove.
(aarch64_decode_stur): Remove.
(aarch64_analyze_prologue): Call aarch64_decode_insn
and use aarch64_inst to decode instructions.
This patch combines both aarch64_decode_stp_offset_wb and
aarch64_decode_stp_offset together.
gdb:
2015-11-05 Yao Qi <yao.qi@linaro.org>
* aarch64-tdep.c (aarch64_decode_stp_offset): New argument
wback.
(aarch64_decode_stp_offset_wb): Removed.
(aarch64_analyze_prologue): Don't use
aarch64_decode_stp_offset_wb.
allocate (vla1 (5)) ! vla1-not-allocated
l = allocated(vla1) ! vla1-allocated <------------------
Expecting: ^(510-data-evaluate-expression vla1[^M
]+)?(510\^done,value="\(0, 0, 0, 0, 0\)"[^M
]+[(]gdb[)] ^M
[ ]*)
510-data-evaluate-expression vla1^M
510^done,value="(1.82987403e-09, 7.8472714e-44, 1.82987403e-09, 7.8472714e-44, 2.67929926e+20)"^M
(gdb) ^M
FAIL: gdb.mi/mi-vla-fortran.exp: evaluate allocated vla
gcc-4.9.2-6.fc21.x86_64
I think some older gfortran did initialize allocated memory but that is an
unspecified behavior. I haven't found any initialization mentioned
in Fortran 90 standard (draft) and it is also clearly stated here:
https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/268786
Initialization to 0 of allocated arrays (of integers) is an
implementation issue. i.e. do not rely on it.
Joel Brobecker wrote:
I am wondering if it might be better to just relax instead the regexp to allow
any number rather than just remove the test altogether. The test allows us to
verify that, as soon as we're past the "allocate" call, we no longer say "not
allocated".
gdb/testsuite/ChangeLog
2015-11-03 Jan Kratochvil <jan.kratochvil@redhat.com>
Joel Brobecker <brobecker@adacore.com>
* gdb.mi/mi-vla-fortran.exp (evaluate allocated vla): Permit any data.
This is needed to avoid O(n**2) complexity when recording MVCLE and other
partial execution instructions.
gdb/ChangeLog:
PR/18376
* gdb/s390-linux-tdep.c (s390_is_partial_instruction): New function.
(s390_software_single_step): New function.
(s390_displaced_step_hw_singlestep): New function.
(s390_gdbarch_init): Fill gdbarch slots with the above.
gdb/ChangeLog:
PR/18376
* gdb/configure.tgt: Add linux-record.o to s390*-linux.
* gdb/s390-linux-tdep.c: #include "linux-record.h", "record-full.h"
(s390_linux_record_tdep): New static global variable.
(s390x_linux_record_tdep): New static global variable.
(s390_all_but_pc_registers_record): New function.
(s390_canonicalize_syscall): New function.
(s390_linux_syscall_record): New function.
(s390_linux_record_signal): New function.
(s390_record_calc_disp_common): New function.
(s390_record_calc_disp): New function.
(s390_record_calc_disp_vsce): New function.
(s390_record_calc_rl): New function.
(s390_record_gpr_g): New function.
(s390_record_gpr_h): New function.
(s390_record_vr): New function.
(s390_process_record): New function.
(s390_init_linux_record_tdep): New function.
(s390_gdbarch_init): Fill record function slots.
gdb/testsuite/ChangeLog:
* gdb.reverse/s390-mvcle.c: New test.
* gdb.reverse/s390-mvcle.exp: New file.
* lib/gdb.exp: Enable reverse tests on s390*-linux.
On the newly added s390 target, it's possible for a single instruction
to write practically unbounded amount of memory (eg. MVCLE). This caused
a stack overflow when alloca was used.
gdb/ChangeLog:
* record-full.c (record_full_exec_insn): Use xmalloc for temporary
memory storage.
The breakpoint presented in the return statement was not activated while
compiling the test with gcc 4.9.2. Added a dummy statement to allow the
breakpoint again.
2015-10-14 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/testsuite:
* i386-mpx-map.c (foo): Add dummy statement to trigger breakpoint.
Change-Id: I5293ca1c7f82a631e1e41cb650c30dd2d09ef3c2
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
Adapts tests to use actual GCC flags, previous used flags were
related to an internal GCC release.
2015-06-18 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/testsuite:
* gdb.arch/i386-mpx-map.exp (comp_flags): Use released GCC flags.
* gdb.arch/i386-mpx.exp (comp_flags): Use released GCC flags.
Change-Id: Id4c4551693a8df071ed4b71bb5dfb46a526ed5db
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
Error was introduced to fix a build issue caused by a mismatching variable
size. The error message is changed to explicitly report what goes wrong
and how user might still investigate the issue.
2015-06-18 Walfred Tedeschi <walfred.tedeschi@intel.com>
* i386-tdep.c (i386_mpx_get_bt_entry) Improves error message.
Change-Id: I6e9c7475eba663f49bd8e720b84ad0265bcb0e92
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
Add support for the /s modifier of the "record instruction-history" command. It
behaves exactly like /m and prints disassembled instructions in the order in
which they were recorded with interleaved sources. We accept /s in addition
to /m to align with the "disassemble" command.
The "record instruction-history" modifiers were not documented. Document
all of them.
gdb/
* record.c (get_insn_history_modifiers): Set DISASSEMBLY_SOURCE
instead of DISASSEMBLY_SOURCE_DEPRECATED. Also accept /s.
(_initialize_record): Document the /s modifier.
* NEWS: Announce record instruction-history's new /s modifier.
doc/
* gdb.texinfo (Process Record and Replay): Document "record
instruction-history" modifiers.
The /m modifier interleaves source lines with the disassembly of recorded
instructions. This calls disasm.c's gdb_disassembly once for each recorded
instruction to be printed.
This doesn't really work because gdb_disassembly may choose not to print
anything in some situations. And if it does print something, the output
interferes with btrace_insn_history's output around it.
It further results in a separate asm_insns list for each instruction in MI.
Even though there is no MI support for target record, yet, we fix this obvious
issue.
Change record instruction-history /m to use the new gdb_pretty_print_insn
function for printing a single instruction and interleave source lines as
appropriate.
We cannot reuse the new disasm.c do_mixed_source_and_assembly function without
significant changes to it.
gdb/
* record-btrace.c (struct btrace_line_range): New.
(btrace_mk_line_range, btrace_line_range_add)
(btrace_line_range_is_empty, btrace_line_range_contains_range)
(btrace_find_line_range, btrace_print_lines): New.
(btrace_insn_history): Add source interleaving algorithm.
The "record instruction-history" command prints for each instruction in
addition to the instruction's disassembly:
- the instruction number in the recorded execution trace
- a '?' before the instruction if it was executed speculatively
To allow the "record instruction-history" command to use GDB's disassembly
infrastructure, we extend gdb_pretty_print_insn to optionally print those
additional fields and export the function.
Add a new struct disasm_insn to add additional fields describing the
to-be-disassembled instruction. The additional fields are:
number an optional instruction number, zero if omitted.
is_speculative a predicate saying whether the instruction was
executed speculatively.
If non-zero, the instruction number is printed first. It will also appear
as a new optional field "insn-number" in MI. The field will be present if
insn_num is non-zero.
If is_speculative is set, speculative execution will be indicated by a "?"
following the new instruction number field. Unless the PC is omitted, it
will overwrite the first byte of the PC prefix. It will appear as a new
optional field "is-speculative" in MI. The field will contain "?" and will
be present if is_speculative is set.
The speculative execution indication is guarded by a new flag
DISASSEMBLY_SPECULATION.
Replace the PC parameter of gdb_pretty_print_insn with a pointer to the above
struct. GDB's "disassemble" command does not use the new fields.
gdb/
* disasm.h (DISASSEMBLY_SPECULATION): New.
(struct disasm_insn): New.
(gdb_pretty_print_insn): New.
* disasm.c (gdb_pretty_print_insn): Replace parameter PC with INSN.
Update users. Print instruction number and indicate speculative
execution, if requested.
Split disasm.c's dump_insn into two parts:
- print a single instruction
- loop over the specified address range
The first part will be refined in subsequent patches so it can be reused.
gdb/
* disasm.c (dump_insns): Split into this and ...
(gdb_pretty_print_insn): ... this.
This actually fixes the build in C:
/home/simark/src/binutils-gdb/gdb/xtensa-linux-nat.c💯1: error: no previous prototype for ‘supply_gregset_reg’ [-Werror=missing-prototypes]
supply_gregset_reg (struct regcache *regcache,
^
/home/simark/src/binutils-gdb/gdb/xtensa-linux-nat.c:257:1: error: no previous prototype for ‘xtensa_linux_fetch_inferior_registers’ [-Werror=missing-prototypes]
xtensa_linux_fetch_inferior_registers (struct target_ops *ops,
^
/home/simark/src/binutils-gdb/gdb/xtensa-linux-nat.c:272:1: error: no previous prototype for ‘xtensa_linux_store_inferior_registers’ [-Werror=missing-prototypes]
xtensa_linux_store_inferior_registers (struct target_ops *ops,
^
cc1: all warnings being treated as errors
These functions are local to this file, so they should be static.
gdb/ChangeLog:
* xtensa-linux-nat.c (supply_gregset_reg): Make static.
(xtensa_linux_fetch_inferior_registers): Likewise.
(xtensa_linux_store_inferior_registers): Likewise.
Fixes
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-mips-low.c: In function ‘void mips_add_watchpoint(arch_process_info*, CORE_ADDR, int, int)’:
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-mips-low.c:368:19: error: invalid conversion from ‘int’ to ‘target_hw_bp_type’ [-fpermissive]
new_watch->type = watch_type;
^
gdb/gdbserver/ChangeLog:
* linux-mips-low.c (mips_linux_new_thread): Change type of
watch_type to enum target_hw_bp_type.
Trivial casts for C++.
Fixes things like
In file included from /home/simark/src/binutils-gdb/gdb/gdbserver/../common/common-defs.h:39:0,
from /home/simark/src/binutils-gdb/gdb/gdbserver/server.h:22,
from /home/simark/src/binutils-gdb/gdb/gdbserver/linux-arm-low.c:19:
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-arm-low.c: In function ‘int arm_get_hwcap(long unsigned int*)’:
/home/simark/src/binutils-gdb/gdb/gdbserver/../../include/libiberty.h:711:38: error: invalid conversion from ‘void*’ to ‘unsigned char*’ [-fpermissive]
# define alloca(x) __builtin_alloca(x)
^
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-arm-low.c:807:25: note: in expansion of macro ‘alloca’
unsigned char *data = alloca (8);
^
gdb/gdbserver/ChangeLog:
* linux-aarch32-low.c (arm_fill_gregset): Add cast.
(arm_store_gregset): Likewise.
* linux-arm-low.c (arm_get_hwcap): Likewise.
(arm_read_description): Likewise.
Mostly some casts from "generic arg" void* to the actual type.
There are two (enum gdb_signal) casts. I tried to see if it would have
been better to change the type of sigrc, but it has a double role, as an
enum and as an integer, so I left it as is.
gdb/ChangeLog:
* remote-sim.c (check_for_duplicate_sim_descriptor): Add casts.
(get_sim_inferior_data): Likewise.
(sim_inferior_data_cleanup): Likewise.
(gdbsim_close_inferior): Likewise.
(gdbsim_resume_inferior): Likewise.
(gdbsim_wait): Likewise.
(simulator_command): Likewise.
(sim_command_completer): Likewise.
g++ doesn't like that we forward-declare a variable that is initialized
later in the file. It's easy enough to re-order things to fix it.
Fixes
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-ppc-low.c:663:28: error: redefinition of ‘usrregs_info ppc_usrregs_info’
static struct usrregs_info ppc_usrregs_info =
^
/home/simark/src/binutils-gdb/gdb/gdbserver/linux-ppc-low.c:381:28: note: ‘usrregs_info ppc_usrregs_info’ previously declared here
static struct usrregs_info ppc_usrregs_info;
^
gdb/gdbserver/ChangeLog:
* linux-ppc-low.c (ppc_usrregs_info): Remove
forward-declaration.
(ppc_arch_setup): Move lower in file.
readelf ought to notify when a symbol wrongly has both a version
definition and a needed version. This patch does that, and removes
the heuristic that only defined symbols in SHT_NOBITS sections have
verneed entries.
* readelf (process_version_sections): Check DT_VERNEED and
DT_VERDEF for all symbols. Report "*both*" should a symbol
have both a verneed and verdef.
(get_symbol_version_string): Reduce indentation by early
exits. Don't use SHT_NOBITS heuristic to detect case where a
defined symbol has a verneed entry.
continue_to_breakpoint always continues to the next breakpoint, not to the
one named in parameter. This rendered the tests effectively useless, since
marker2 was never reached.
gdb/testsuite/ChangeLog:
* gdb.reverse/fstatat-reverse.exp: Set breakpoint on marker1 after
reaching marker2.
* gdb.reverse/getresuid-reverse.exp: Likewise.
* gdb.reverse/pipe-reverse.exp: Likewise.
* gdb.reverse/readv-reverse.exp: Likewise.
* gdb.reverse/recvmsg-reverse.exp: Likewise.
* gdb.reverse/time-reverse.exp: Likewise.
* gdb.reverse/waitpid-reverse.exp: Likewise and add KFAILs.
opcode * rx.h (enum RX_Operand_Type): Add RX_Operand_Zero_Indirect.
opcodes * rx-decode.opc (rx_disp): If the displacement is zero, set the
type to RX_Operand_Zero_Indirect.
* rx-decode.c: Regenerate.
* rx-dis (print_insn): Handle RX_Operand_Zero_Indirect.
gas * config/rx-parse.y: Allow zero value for 5-bit displacements.
tests * gas/rx/mov.sm: Add tests for zero offset indirect moves.
* gas/rx/mov.d: Update expected output.
Assuming displaced stepping is enabled, and a breakpoint is set in the
memory region of the scratch pad, things break. One of two cases can
happen:
#1 - The breakpoint wasn't inserted yet (all threads were stopped), so
after setting up the displaced stepping scratch pad with the
adjusted copy of the instruction we're trying to single-step, we
insert the breakpoint, which corrupts the scratch pad, and the
inferior executes the wrong instruction. (Example below.)
This is clearly unacceptable.
#2 - The breakpoint was already inserted, so setting up the displaced
stepping scratch pad overwrites the breakpoint. This is OK in
the sense that we already assume that no thread is going to
executes the code in the scratch pad range (after initial
startup) anyway.
This commit addresses both cases by simply punting on displaced
stepping if we have a breakpoint in the scratch pad range.
The #1 case above explains a few regressions exposed by the AS/NS
series on x86:
Running ./gdb.dwarf2/callframecfa.exp ...
FAIL: gdb.dwarf2/callframecfa.exp: set display for call-frame-cfa
FAIL: gdb.dwarf2/callframecfa.exp: step 1 for call-frame-cfa
FAIL: gdb.dwarf2/callframecfa.exp: step 2 for call-frame-cfa
FAIL: gdb.dwarf2/callframecfa.exp: step 3 for call-frame-cfa
FAIL: gdb.dwarf2/callframecfa.exp: step 4 for call-frame-cfa
Running ./gdb.dwarf2/typeddwarf.exp ...
FAIL: gdb.dwarf2/typeddwarf.exp: continue to breakpoint: continue to typeddwarf.c:53
FAIL: gdb.dwarf2/typeddwarf.exp: check value of x at typeddwarf.c:53
FAIL: gdb.dwarf2/typeddwarf.exp: check value of y at typeddwarf.c:53
FAIL: gdb.dwarf2/typeddwarf.exp: check value of z at typeddwarf.c:53
FAIL: gdb.dwarf2/typeddwarf.exp: continue to breakpoint: continue to typeddwarf.c:73
FAIL: gdb.dwarf2/typeddwarf.exp: check value of w at typeddwarf.c:73
FAIL: gdb.dwarf2/typeddwarf.exp: check value of x at typeddwarf.c:73
FAIL: gdb.dwarf2/typeddwarf.exp: check value of y at typeddwarf.c:73
FAIL: gdb.dwarf2/typeddwarf.exp: check value of z at typeddwarf.c:73
Enabling "maint set target-non-stop on" implies displaced stepping
enabled as well, and it's the latter that's to blame here. We can see
the same failures with "maint set target-non-stop off + set displaced
on".
Diffing (good/bad) gdb.log for callframecfa.exp shows:
@@ -99,29 +99,29 @@ Breakpoint 2 at 0x80481b0: file q.c, lin
continue
Continuing.
-Breakpoint 2, func (arg=77) at q.c:2
+Breakpoint 2, func (arg=52301) at q.c:2
2 in q.c
(gdb) PASS: gdb.dwarf2/callframecfa.exp: continue to breakpoint: continue to breakpoint for call-frame-cfa
display arg
-1: arg = 77
-(gdb) PASS: gdb.dwarf2/callframecfa.exp: set display for call-frame-cfa
+1: arg = 52301
+(gdb) FAIL: gdb.dwarf2/callframecfa.exp: set display for call-frame-cfa
The problem is here, when setting up the func call:
Breakpoint 1, main (argc=-13345, argv=0x0) at q.c:7
7 in q.c
(gdb) disassemble
Dump of assembler code for function main:
0x080481bb <+0>: push %ebp
0x080481bc <+1>: mov %esp,%ebp
0x080481be <+3>: sub $0x4,%esp
=> 0x080481c1 <+6>: movl $0x4d,(%esp)
0x080481c8 <+13>: call 0x80481b0 <func>
0x080481cd <+18>: leave
0x080481ce <+19>: ret
End of assembler dump.
(gdb) disassemble /r
Dump of assembler code for function main:
0x080481bb <+0>: 55 push %ebp
0x080481bc <+1>: 89 e5 mov %esp,%ebp
0x080481be <+3>: 83 ec 04 sub $0x4,%esp
=> 0x080481c1 <+6>: c7 04 24 4d 00 00 00 movl $0x4d,(%esp)
0x080481c8 <+13>: e8 e3 ff ff ff call 0x80481b0 <func>
0x080481cd <+18>: c9 leave
0x080481ce <+19>: c3 ret
End of assembler dump.
Note the breakpoint at main is set at 0x080481c1. Right at the
instruction that sets up func's argument. Executing that instruction
should write 0x4d to the address pointed at by $esp. However, if we
stepi, the program manages to write 52301/0xcc4d there instead (0xcc
is int3, the x86 breakpoint instruction), because the breakpoint
address is 4 bytes inside the scratch pad location, which is
0x080481bd:
(gdb) p 0x080481c1 - 0x080481bd
$1 = 4
IOW, instead of executing:
"c7 04 24 4d 00 00 00" [ movl $0x4d,(%esp) ]
the inferior executes:
"c7 04 24 4d cc 00 00" [ movl $0xcc4d,(%esp) ]
gdb/ChangeLog:
2015-10-30 Pedro Alves <palves@redhat.com>
* breakpoint.c (breakpoint_in_range_p)
(breakpoint_location_address_range_overlap): New functions.
* breakpoint.h (breakpoint_in_range_p): New declaration.
* infrun.c (displaced_step_prepare_throw): If there's a breakpoint
in the scratch pad range, don't displaced step.
Nowadays, test gdb.threads/wp-replication.exp uses a while loop to
repeatedly insert HW watchpoint, resume and check no error message
coming out, in order to count HW watchpoints There are some
drawbacks in this way,
- the loop could be endless. I think this is use to making trouble
to S/390, since we had such comment
# Some targets (like S/390) behave as though supporting
# unlimited hardware watchpoints. In this case we just take a
# safe exit out of the loop.
I hit this today too because a GDB internal error is triggered
on "continue" in the loop, and $done is 0 invariantly, so the loop
can't end.
- the code counting hardware watchpoint is too complicated. We can
use "set breakpoint always-inserted on" to get the result of inserting
HW watchpoint without resuming the inferior. In this way,
watch_count_done and empty_cycle in c file is no longer needed.
In this patch, I change to use "set breakpoint always-inserted on" trick,
and only iterate $NR_THREADS times, to count the HW watchpoint. In this
way, the loop can't be endless, and GDB doesn't need to resume the inferior.
gdb/testsuite:
2015-10-30 Yao Qi <yao.qi@linaro.org>
* gdb.threads/wp-replication.c (watch_count_done): Remove.
(empty_cycle): Remove.
(main): Don't call empty_cycle. Don't use watch_count_done.
* gdb.threads/wp-replication.exp: Don't set breakpoint on
empty_cycle. Rewrite the code counting HW watchpoints.
60 bytes is the size of glibc's struct termios, the one used by kernel is
36 bytes long.
gdb/ChangeLog:
* aarch64-linux-tdep.c (aarch64_linux_init_abi): Fix size_termios.
* amd64-linux-tdep.c (amd64_linux_init_abi): Fix size_termios.
(amd64_x32_linux_init_abi): Fix size_termios.
We have to use extract_unsigned_integer to read paramaters structure - target
pointers can have different endianness and size.
gdb/ChangeLog:
* linux-record.c (record_linux_system_call): Fix old_select.
Memory size for getgroups16 needs to be multiplied by entry count, and only
needs recording if the pointer is non-NULL. setgroups16, on the other hand,
doesn't write to user memory and doesn't need special handling at all.
gdb/ChangeLog:
* linux-record.c (record_linux_system_call): Fix [gs]etgroups16.