This patch rewrites the make-target-delegates matching code a little
bit. The result is functionally the same (the output has some small
whitespace differences), but the new code is more forgiving regarding
the formatting of target.h. In particular now there's no need to
ensure that the return type and the method name appear on the same
line.
2014-07-23 Tom Tromey <tromey@redhat.com>
* make-target-delegates ($ARGS_PART): Match trailing close paren.
($INTRO_PART): Don't match whitespace.
($METHOD_TRAILER): Move earlier. Remove trailing semicolon and
argument matching.
($METHOD): Add $METHOD_TRAILER.
(trim): Rewrite.
(scan_target_h): New sub.
Change main loop not to collect state.
* target-delegates.c: Rebuild.
This commit fixes the build on systems without sigaltstack.
gdb/
2014-07-23 Gary Benson <gbenson@redhat.com>
* cp-support.c (gdb_demangle): Fix build on systems without
sigaltstack.
I cannot reproduce any wrong case having the code removed.
I just do not find it correct to have it disabled. But at the same time I do
like much / I do not find correct the code myself. It is a bit problematic to
have struct value describing a memory content which is no longer present
there.
What happens there:
------------------------------------------------------------------------------
volatile int vv;
static __attribute__((noinline)) int
bar (int &ref) {
ref = 20;
vv++; /* break-here */
return ref;
}
int main (void) {
int var = 10;
return bar (var);
}
------------------------------------------------------------------------------
<4><c7>: Abbrev Number: 13 (DW_TAG_GNU_call_site_parameter)
<c8> DW_AT_location : 1 byte block: 55 (DW_OP_reg5 (rdi))
<ca> DW_AT_GNU_call_site_value: 2 byte block: 91 74 (DW_OP_fbreg: -12)
<cd> DW_AT_GNU_call_site_data_value: 1 byte block: 3a (DW_OP_lit10)
------------------------------------------------------------------------------
gdb -ex 'b value_addr' -ex r --args ../gdb ./1 -ex 'watch vv' -ex r -ex 'p &ref@entry'
->
6 return ref;
bar (ref=@0x7fffffffd944: 20, ref@entry=@0x7fffffffd944: 10) at 1.C:25
------------------------------------------------------------------------------
At /* break-here */ struct value variable 'ref' is TYPE_CODE_REF.
With FSF GDB HEAD:
(gdb) x/gx arg1.contents
0x6004000a4ad0: 0x00007fffffffd944
(gdb) p ((struct value *)arg1.location.computed.closure).lval
$1 = lval_memory
(gdb) p/x ((struct value *)arg1.location.computed.closure).location.address
$3 = 0x7fffffffd944
With your #if0-ed code:
(gdb) x/gx arg1.contents
0x6004000a4ad0: 0x00007fffffffd944
(gdb) p ((struct value *)arg1.location.computed.closure).lval
$8 = not_lval
(gdb) p/x ((struct value *)arg1.location.computed.closure).location.address
$9 = 0x0
I do not see how to access
((struct value *)arg1.location.computed.closure).location.address
from GDB CLI. Trying
(gdb) p &ref@entry
will invoke value_addr()'s:
if (TYPE_CODE (type) == TYPE_CODE_REF)
/* Copy the value, but change the type from (T&) to (T*). We
keep the same location information, which is efficient, and
allows &(&X) to get the location containing the reference. */
and therefore the address gets fetched already from
arg1.contents
and not from
((struct value *)arg1.location.computed.closure).location.address
.
And for any other type than TYPE_CODE_REF this code you removed does not get
executed at all. This DW_AT_GNU_call_site_data_value DWARF was meant
primarily for Fortran but with -O0 entry values do not get produced
and with -Og and higher Fortran always optimizes out the passing by reference.
If you do not like the removed code there I am OK with removing it as I do not
know how to make it's use reproducible for user anyway. In the worst case
- if there really is some way how to exploit it - one should just get
Attempt to take address of value not located in memory.
instead of some wrong value and it may be easy to fix then.
gdb/
2014-07-22 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2loc.c (value_of_dwarf_reg_entry): Remove setting value address
for reference entry value target data value.
Message-ID: <20140720150727.GA18488@host2.jankratochvil.net>
The tests at
<https://sourceware.org/ml/gdb-patches/2014-07/msg00277.html> show
that comparing a fully optimized out value's contents with a value
that has not been optimized out, or is partially optimized out crashes
GDB:
(gdb) bt
#0 __memcmp_sse4_1 () at ../sysdeps/x86_64/multiarch/memcmp-sse4.S:816
#1 0x00000000005a1914 in memcmp_with_bit_offsets (ptr1=0x202b2f0 "\n", offset1_bits=0, ptr2=0x0, offset2_bits=0, length_bits=32)
at /home/pedro/gdb/mygit/build/../src/gdb/value.c:678
#2 0x00000000005a1a05 in value_available_contents_bits_eq (val1=0x2361ad0, offset1=0, val2=0x23683b0, offset2=0, length=32)
at /home/pedro/gdb/mygit/build/../src/gdb/value.c:717
#3 0x00000000005a1c09 in value_available_contents_eq (val1=0x2361ad0, offset1=0, val2=0x23683b0, offset2=0, length=4)
at /home/pedro/gdb/mygit/build/../src/gdb/value.c:769
#4 0x00000000006033ed in read_frame_arg (sym=0x1b78d20, frame=0x19bca50, argp=0x7fff4aba82b0, entryargp=0x7fff4aba82d0)
at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:416
#5 0x0000000000603abb in print_frame_args (func=0x1b78cb0, frame=0x19bca50, num=-1, stream=0x1aea450) at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:671
#6 0x0000000000604ae8 in print_frame (frame=0x19bca50, print_level=0, print_what=SRC_AND_LOC, print_args=1, sal=...)
at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:1205
#7 0x0000000000604050 in print_frame_info (frame=0x19bca50, print_level=0, print_what=SRC_AND_LOC, print_args=1, set_current_sal=1)
at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:857
#8 0x00000000006029b3 in print_stack_frame (frame=0x19bca50, print_level=0, print_what=SRC_AND_LOC, set_current_sal=1)
at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:169
#9 0x00000000005fc4b8 in print_stop_event (ws=0x7fff4aba8790) at /home/pedro/gdb/mygit/build/../src/gdb/infrun.c:6068
#10 0x00000000005fc830 in normal_stop () at /home/pedro/gdb/mygit/build/../src/gdb/infrun.c:6214
The 'ptr2=0x0' in frame #1 is val2->contents, and since git 4f14910f:
gdb/ChangeLog
2013-11-26 Andrew Burgess <aburgess@broadcom.com>
* value.c (allocate_optimized_out_value): Mark value as non-lazy.
... a fully optimized-out value can have it's value contents buffer
NULL.
As a spotgap fix, revert 4f14910f, with a comment. A full fix would
be too invasive for 7.8.
gdb/
2014-07-22 Pedro Alves <palves@redhat.com>
* value.c (allocate_optimized_out_value): Don't mark value as
non-lazy.
2014-07-21 Sriraman Tallam <tmsriram@google.com>
* object.cc (Relobj::is_section_name_included): Add
".rodata.nptl_version" to not garbage collect this section.
TERNOP_SLICE was added for language Chill, but it is used for Ada and D later.
Since language Chill was removed from GDB, TERNOP_SLICE is only used for
Ada and D. This patch is to update its comments.
gdb:
2014-07-20 Yao Qi <yao@codesourcery.com>
* std-operator.def: Update comments to TERNOP_SLICE.
BINOP_RANGE was added by the following commit for chill language.
commit badefd2800
Author: Per Bothner <per@bothner.com>
Date: Wed Nov 29 22:59:31 1995 +0000
* expression.h (enum exp_opcode): Add BINOP_RANGE.
* expprint.c (dump_expression): Support BINOP_RANGE.
* eval.c (evaluate_subexp_standard): Handle BINOP_RANGE (as error).
(case MULTI_SUBSCRIPT): Fix broken f77 value->int ad hoc conversion.
* ch-lang.c (chill_op_print_tab): Support BINOP_RANGE.
(evaluate_subexp_chill): Error on BINOP_COMMA.
Chill language is no longer supported, so we can remove BINOP_RANGE too.
This patch is to remove BINOP_RANGE.
gdb:
2014-07-20 Yao Qi <yao@codesourcery.com>
* std-operator.def: Remove BINOP_RANGE.
* breakpoint.c (watchpoint_exp_is_const): Update.
* expprint.c (dump_subexp_body_standard): Likewise.
* eval.c (init_array_element): Remove dead code.
(evaluate_subexp_standard): Likewise.
Chill language support was removed several years ago, and BINOP_IN
isn't used for Pascal. This patch is to remove BINOP_IN.
gdb:
2014-07-20 Yao Qi <yao@codesourcery.com>
* std-operator.def: Remove BINOP_IN.
* breakpoint.c (watchpoint_exp_is_const): Update.
* eval.c (evaluate_subexp_standard): Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
Even though the opcodes were defined for these instructions,
the actual instruction definitions were lacking.
cpu/
* or1korbis.cpu (l-msync, l-psync, l-csync): New instructions.
opcodes/
* or1k-desc.c, * or1k-desc.h, * or1k-opc.c, * or1k-opc.h,
* or1k-opinst.c: Regenerate.
Prior to version MicroBlaze v8.10.a,EDK 13.1, XMD's gdbserver stub returned 57
registers in response to GDB's G request. Starting with version MicroBlaze
v8.10.a, EDK 13.1, XMD added the slr and shr register, for a count of 59
registers. This patch adds these registers to the expected G response. This patch
fixes the above problem for baremetal and also supports the backward compatibility.
ChangeLog:
2014-07-02 Ajit Agarwal <ajitkum@xilinx.com>
* microblaze-tdep.c (microblaze_register_names): Add
the rshr and rslr register names.
(microblaze_gdbarch_init): Use of tdesc_has_registers.
Use of tdesc_find_feature. Use of tdesc_data_alloc.
Use of tdesc_numbered_register. Use of
microblaze_register_g_packet_guesses. Use of
tdesc_use_registers. Use of set_gdbarch_register_type.
(microblaze_register_g_packet_guesses): New.
* microblaze-tdep.h (microblaze_reg_num): Add
field MICROBLAZE_SLR_REGNUM MICROBLAZE_SHR_REGNUM
MICROBLAZE_NUM_REGS and MICROBLAZE_NUM_CORE_REGS.
(microblaze_frame_cache): Use of MICROBLAZE_NUM_REGS.
* features/microblaze-core.xml: New file.
* features/microblaze-stack-protect.xml: New file.
* features/microblaze-with-stack-protect.c: New file.
* features/microblaze-with-stack-protect.xml: New file.
* features/microblaze.xml: New file.
* features/microblaze.c: New file.
* features/Makefile (microblaze-with-stack-protect): Add
microblaze-with-stack-protect microblaze and
microblaze-expedite.
* regformats/microblaze-with-stack-protect.dat: New file.
* regformats/microblaze.dat: New file.
* doc/gdb.texinfo (MicroBlaze Features): New.
Signed-off-by:Ajit Agarwal ajitkum@xilinx.com
While working on some target stack changes, I noticed that exec_ops is
only used from exec.c. This patch makes it "static". This is cleaner
and makes it simpler to reason about the use of the target.
Tested by rebuilding.
I'm checking this in as obvious.
2014-07-18 Tom Tromey <tromey@redhat.com>
* exec.c (exec_ops): Now static.
* exec.h (exec_ops): Don't declare.
A long time ago Pedro pointed out that there are some calls to
find_target_beneath that pass in an explicit target_ops; but which
should instead use the ops provided to the method in question. See:
https://sourceware.org/ml/gdb-patches/2014-01/msg00429.html
This patch is just a minor cleanup to fix all such calls. There were
only three.
2014-07-18 Tom Tromey <tromey@redhat.com>
* spu-multiarch.c (spu_region_ok_for_hw_watchpoint): Pass "self"
to find_target_beneath.
* ravenscar-thread.c (ravenscar_prepare_to_store): Pass "ops" to
find_target_beneath.
(ravenscar_mourn_inferior): Pass "self" to find_target_beneath.
This fixes PR gdb/17130.
The bug is that some code in utils.c was not updated during the target
delegation change:
if (job_control
/* If there is no terminal switching for this target, then we can't
possibly get screwed by the lack of job control. */
|| current_target.to_terminal_ours == NULL)
fatal ("Quit");
else
fatal ("Quit (expect signal SIGINT when the program is resumed)");
After the delegation change, to_terminal_ours will never be NULL.
I think this bug can be seen before the target delegation change by
enabling target debugging -- this would also cause to_terminal_ours to
be non-NULL.
The fix is to introduce a new target_supports_terminal_ours function,
that properly checks the target stack. This is not perhaps ideal, but
I think is a reasonable-enough approach, and in keeping with some
other existing code of the same form.
This patch also fixes a similar bug in target_supports_delete_record.
2014-07-18 Tom Tromey <tromey@redhat.com>
PR gdb/17130:
* utils.c (quit): Use target_supports_terminal_ours.
* target.h (target_supports_terminal_ours): Declare.
* target.c (target_supports_delete_record): Don't check
to_delete_record against NULL.
(target_supports_terminal_ours): New function.
This patch cleans up some minor inconsistencies in target delegation.
It's primary purpose is to avoid confusion in the code. A few spots
were checking the "beneath" target; however this can only be NULL for
the dummy target, so such tests are not needed. Some other spots were
iterating over the beneath targets, looking for a method
implementation. This is not needed for methods handled by
make-target-delegates, as there is always an implementation.
2014-07-18 Tom Tromey <tromey@redhat.com>
PR gdb/17130:
* spu-multiarch.c (spu_region_ok_for_hw_watchpoint)
(spu_fetch_registers, spu_store_registers, spu_xfer_partial)
(spu_search_memory, spu_mourn_inferior): Simplify delegation.
* linux-thread-db.c (thread_db_pid_to_str): Always delegate.
* windows-nat.c (windows_xfer_partial): Always delegate.
* record-btrace.c (record_btrace_xfer_partial): Simplify
delegation.
(record_btrace_fetch_registers, record_btrace_store_registers)
(record_btrace_prepare_to_store, record_btrace_resume)
(record_btrace_wait, record_btrace_find_new_threads)
(record_btrace_thread_alive): Likewise.
* procfs.c (procfs_xfer_partial): Always delegate.
* corelow.c (core_xfer_partial): Always delegate.
* sol-thread.c (sol_find_new_threads): Simplify delegation.
This patch moves exec_make_note_section a bit earlier in exec.c. This
lets us remove an otherwise unnecessary forward declaration and it
also makes the file a bit more in line with other code, as now
_initialize_exec is the final function in the file.
Tested by rebuilding.
I'm committing this as obvious.
2014-07-18 Tom Tromey <tromey@redhat.com>
* exec.c (exec_make_note_section): Move earlier.
Override the default value of 0x0000 defined in
TEXT_START_ADDR to avoid linux executables to be mapped
at zero page.
ld/
* emulparams/elf32or1k_linux.sh (TEXT_START_ADDR): Increase from
0x0 to first page boundary at 0x2000.
Since we use tkill everywhere, using kill to try to kill each lwp
individually looks suspiciously odd. We should really be using tgkill
everywhere, but at least while we don't get there this makes us
consistent.
gdb/gdbserver/
2014-07-16 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_kill_one_lwp): Use kill_lwp, not kill.
gdb/
2014-07-16 Pedro Alves <palves@redhat.com>
* linux-nat.c (kill_callback): Use kill_lwp, not kill.
I noticed that the existing code casts a function's address to 'long',
but that doesn't work correctly on some ABIs, like Win64, where long
is 32-bit and while pointers are 64-bit:
func_addr = (long) &write_basic_trace_file;
Fixing that showed there's actually another place in the file that
writes a function address to file, and therefore should clear the
Thumb bit. This commit adds a macro+function pair to centralize the
Thumb bit handling, and uses it in both places.
The rest is just enough changes to make the file build without
warnings with "-Wall -Wextra" with x86_64-w64-mingw32-gcc and
i686-w64-mingw32-gcc cross compilers, and with -m32/-m64 on x86_64
GNU/Linux. Currently with x86_64-w64-mingw32-gcc we get:
$ x86_64-w64-mingw32-gcc tfile.c -Wall -DTFILE_DIR=\"\"
tfile.c: In function 'start_trace_file':
tfile.c:51:23: error: 'S_IRGRP' undeclared (first use in this function)
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
^
tfile.c:51:23: note: each undeclared identifier is reported only once for each function it appears in
tfile.c:51:31: error: 'S_IROTH' undeclared (first use in this function)
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
^
tfile.c: In function 'add_memory_block':
tfile.c:79:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
ll_x = (unsigned long) addr;
^
tfile.c: In function 'write_basic_trace_file':
tfile.c:113:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
func_addr = (long) &write_basic_trace_file;
^
tfile.c:137:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
add_memory_block (&testglob, sizeof (testglob));
^
tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
add_memory_block (char *addr, int size)
^
tfile.c:139:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
add_memory_block (&testglob2, 1);
^
tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
add_memory_block (char *addr, int size)
^
tfile.c: In function 'write_error_trace_file':
tfile.c:185:3: warning: implicit declaration of function 'alloca' [-Wimplicit-function-declaration]
char *hex = alloca (len * 2 + 1);
^
tfile.c:185:15: warning: incompatible implicit declaration of built-in function 'alloca' [enabled by default]
char *hex = alloca (len * 2 + 1);
^
tfile.c:211:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
(long) &write_basic_trace_file);
^
Tested on x86_64 Fedora 20, -m64 and -m32.
Tested by Yao on arm targets.
gdb/testsuite/
2014-07-16 Pedro Alves <palves@redhat.com>
* gdb.trace/tfile.c: Include unistd.h and stdint.h.
(start_trace_file): Guard S_IRGRP and S_IROTH uses behind #ifdef.
(tfile_write_64, tfile_write_16, tfile_write_8, tfile_write_addr)
(tfile_write_buf): New functions.
(add_memory_block): Rewrite using the above.
(adjust_function_address): New function.
(FUNCTION_ADDRESS): New macro.
(write_basic_trace_file): Remove short_x local, and use
tfile_write_16. Change type of func_addr local to unsigned long
long. Use FUNCTION_ADDRESS instead of handling the Thumb bit
here. Cast argument of add_memory_block to char pointer.
(write_error_trace_file): Avoid alloca. Use FUNCTION_ADDRESS.
(main): Remove parameters.
* gdb.trace/tfile.exp: Remove nowarnings.
Relocations against .got.plt section may not be in the same order as
entries in PLT section. It is incorrect to assume that the Ith reloction
index against .got.plt section always maps to the (I + 1)th entry in PLT
section. This patch matches the .got.plt relocation offset/index in PLT
entry against the index in .got.plt relocation table. It only checks
R_*_JUMP_SLOT and R_*_IRELATIVE relocations. It ignores R_*_TLS_DESC
and R_*_TLSDESC relocations since they have different PLT entries.
bfd/
PR binutils/17154
* elf32-i386.c (elf_i386_plt_sym_val): Only match R_*_JUMP_SLOT
and R_*_IRELATIVE relocation offset with PLT entry.
* elf64-x86-64.c (elf_x86_64_plt_sym_val): Likewise.
(elf_x86_64_plt_sym_val_offset_plt_bnd): New.
(elf_x86_64_get_synthetic_symtab): Use it.
ld/testsuite/
PR binutils/17154
* ld-ifunc/pr17154-i386.d: New file.
* ld-ifunc/pr17154-x86-64.d: Likewise.
* ld-ifunc/pr17154-x86.s: Likewise.
* ld-x86-64/bnd-ifunc-2.d: Likewise.
* ld-x86-64/bnd-ifunc-2.s: Likewise.
* ld-x86-64/mpx.exp: Run bnd-ifunc-2.
* ld-x86-64/tlsdesc-nacl.pd: Updated.
* ld-x86-64/tlsdesc.pd: Likewise.
As Joel pointed out in...
https://sourceware.org/ml/gdb-patches/2014-07/msg00391.html
...it would be nice to add a test for that.
Tested on Linux x86_64 (Ubuntu 14.10).
gdb/testsuite/ChangeLog
2014-07-15 Simon Marchi <simon.marchi@ericsson.com>
* gdb.base/debug-expr.exp: Test string evaluation with
"debug expression" on.
A comment in target.h went past the column limit. This patch
reformats it. I'm pushing this as obvious.
2014-07-16 Tom Tromey <tromey@redhat.com>
* target.h (struct target_ops) <to_delete_record>: Reformat
comment.
target-delegates.c was out of date. This patch rebuilds it.
Built and regtested on x86-64 Fedora 20.
Committed as obvious.
2014-07-16 Tom Tromey <tromey@redhat.com>
* target-delegates.c: Rebuild.
Commit e1f987424b changed how
next_tls_desc_index was set up. This patch updates
elf_i386_compute_jump_table_size to use elf.srelplt->reloc_count
instead of next_tls_desc_index.
bfd/
PR ld/17057
* elf32-i386.c (elf_i386_compute_jump_table_size): Replace
next_tls_desc_index with elf.srelplt->reloc_count.
ld/testsuite/
PR ld/17057
* ld-i386/i386.exp: Run pr17057.
* ld-i386/pr17057.d: New file.
* ld-i386/pr17057.s: Likewise.
The other day I noticed that default_gdb_start reuses the GDB process
if it has been spawned already:
proc default_gdb_start { } {
...
if [info exists gdb_spawn_id] {
return 0
}
I was a bit surprised, and so I hacked in an error to check whether
anything is relying on it:
+ if [info exists gdb_spawn_id] {
+ error "GDB already spawned"
+ }
And lo, that tripped on a funny buglet (see below). The comment in
reread.exp says "Restart GDB entirely", but in reality, due to the
above, that's not what is happening, as a gdb_exit call is missing.
The test is proceeding with the previous GDB process...
I don't really want to go hunt for whether there's an odd setup out
there that assumes this in its board file or something, so for now,
I'm taking the simple route of just making the test do what it says it
does. I think this much makes it an obvious fix.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(gdb) PASS: gdb.base/reread.exp: run to foo() second time
ERROR: tcl error sourcing ../src/gdb/testsuite/gdb.base/reread.exp.
ERROR: GDB already spawned
while executing
"error "GDB already spawned""
invoked from within
"if [info exists gdb_spawn_id] {
error "GDB already spawned"
}"
(procedure "default_gdb_start" line 22)
invoked from within
"default_gdb_start"
(procedure "gdb_start" line 2)
invoked from within
"gdb_start"
invoked from within
"if [is_remote target] {
unsupported "second pass: GDB should check for changes before running"
} else {
# Put the older executable back in pl..."
(file "../src/gdb/testsuite/gdb.base/reread.exp" line 114)
invoked from within
"source ../src/gdb/testsuite/gdb.base/reread.exp"
("uplevel" body line 1)
invoked from within
"uplevel #0 source ../src/gdb/testsuite/gdb.base/reread.exp"
invoked from within
"catch "uplevel #0 source $test_file_name""
testcase ../src/gdb/testsuite/gdb.base/reread.exp completed in 1 seconds
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gdb/testsuite/
2014-07-15 Pedro Alves <palves@redhat.com>
* gdb.base/reread.exp: Use clean_restart.