In mi_interpreter_init, multiple MI consoles/channels are created and a quoting
character is given. In mi_console_raw_packet, we check if the value is not 0
to decide if we should quote the string, but we don't use the value. It is
hardcoded to ". We might never use another quoting character than an actual
quote, but I suggest we change it, for correctness. There is not visible
behavior change.
I changed the latest fputs_unfiltered changed to fputc_unfiltered just to stay
consistent.
gdb/ChangeLog:
2014-05-12 Simon Marchi <simon.marchi@ericsson.com>
* mi/mi-console.c (mi_console_raw_packet): Use the value from
mi_console->quote as the quoting character.
I think "set debugvarobj" has the wrong name.
It ought to be "set debug varobj", like gdb's other debug settings.
This patch makes the change.
I chose not to install deprecated aliases, since this is only a debug
setting; but if someone feels strongly about it I will add them.
Built and regtested on x86-64 Fedora 20.
2014-04-29 Tom Tromey <tromey@redhat.com>
* varobj.c (_initialize_varobj): Rename to "set debug varobj" and
"show debug varobj".
2014-04-29 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Debugging Output): Rename to "set debug varobj" and
"show debug varobj".
gdb/Changelog:
* aarch64-tdep.c (aarch64_software_single_step): New function.
(aarch64_gdbarch_init): Handle single stepping of atomic sequences
with aarch64_software_single_step.
gdb/testsuite/ChangeLog:
* gdb.arch/aarch64-atomic-inst.c: New file.
* gdb.arch/aarch64-atomic-inst.exp: New file.
Hi,
I recently see the fail in dwzbuildid.exp below on some targets,
(gdb) print the_int
No symbol "the_int" in current context.
(gdb) FAIL: gdb.dwarf2/dwzbuildid.exp: mismatch: print the_int
Looks the pattern expects to see "No symbol table is loaded", which
is emitted in c-exp.y,
variable: name_not_typename
....
if (msymbol.minsym != NULL)
write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
else
error (_("No symbol \"%s\" in current context."),
copy_name ($1.stoken));
it is expected to have no full symbols nor partial symbols, but something
brings full symbols or partial symbols in. I added "maint info symtabs"
and "maint info psymtabs" in dwzbuildid.exp, and it shows symbols are from
ld.so, which has debug information. Then, I reproduce the fail like this,
$ make check RUNTESTFLAGS="CFLAGS_FOR_TARGET='-Wl,-rpath=${glibc_build}:${glibc_build}/math -Wl,--dynamic-linker=${glibc_build}/elf/ld.so' dwzbuildid.exp"
${glibc_build} is the glibc build tree. Debug information is not striped,
so the test fail. However, if I strip debug information from libc.so, libm.so
and ld.so. The test passes.
This patch is to relax the pattern to match the both cases that glibc build
has and has not debug information.
gdb/testsuite:
2014-05-07 Yao Qi <yao@codesourcery.com>
* gdb.dwarf2/dwzbuildid.exp: Match output "No symbol "the_int" in
current context" too.
2014-05-05 Keith Seitz <keiths@redhat.com>
* linespec.c (linespec_parse_basic): Run cleanups if a convenience
variable or history value is successfully parsed.
2014-05-05 Keith Seitz <keiths@redhat.com>
* gdb.linespec/ls-dollar.exp: Add test for linespec
file:convenience_variable.
In gdb.trace/unavailable.exp, an action is defined to collect
struct_b.struct_a.array[2] and struct_b.struct_a.array[100],
struct StructB
{
int d, ef;
StructA struct_a;
int s:1;
static StructA static_struct_a;
const char *string;
};
and the other files are not collected.
When GDB examine traceframe collected by the action, "struct_b" is
unavailable completely, which is wrong.
(gdb) p struct_b
$1 = <unavailable>
When GDB reads 'struct_b', it will request to read memory at struct_b's address
of length LEN. Since struct_b.d is not collected, no 'M' block
includes the first part of the desired range, so tfile_xfer_partial returns
TARGET_XFER_UNAVAILABLE and GDB thinks the whole requested range is unavailable.
In order to fix this problem, in the iteration to 'M' blocks, we record the
lowest address of blocks within the request range. If it has, the requested
range isn't unavailable completely. This applies to ctf too. With this patch
applied, the result looks good and fails in unavailable.exp is fixed.
(gdb) p struct_b
$1 = {d = <unavailable>, ef = <unavailable>, struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable>,
<unavailable>, -1431655766, <unavailable> <repeats 97 times>, -1431655766, <unavailable> <repeats 9899 times>}, ptr = <unavailable>, bitfield = <unavailable>}, s = <unavailable>, static static_struct_a = {a = <unavailable>, b = <unavailable>, array = {<unavailable> <repeats 10000 times>}, ptr = <unavailable>,
bitfield = <unavailable>}, string = <unavailable>}
gdb:
2014-05-05 Yao Qi <yao@codesourcery.com>
Pedro Alves <palves@redhat.com>
* tracefile-tfile.c (tfile_xfer_partial): Record the lowest
address of blocks that intersects the requested range. Trim
LEN up to LOW_ADDR_AVAILABLE if read from executable read-only
sections.
* ctf.c (ctf_xfer_partial): Likewise.
gdb/testsuite:
2014-05-05 Yao Qi <yao@codesourcery.com>
* gdb.trace/unavailable.exp (gdb_collect_args_test): Save
traceframes into tfile and ctf trace files. Read data from
trace file and test collected data.
(gdb_collect_locals_test): Likewise.
(gdb_unavailable_registers_test): Likewise.
(gdb_unavailable_floats): Likewise.
(gdb_collect_globals_test): Likewise.
(top-level): Append "ctf" to trace_file_targets if GDB
supports.
When I run refactored unavailable.exp, I find
command display behaves a little different on live inferior and on
examining traceframes. In live inferior, when command "display argc"
is typed, the value of "argc" is shown.
(gdb) display argc
1: argc = 1 '\001'
however, on tfile target, when command "display argc" is typed, the
value of "argc" is not shown.
(gdb) tfind
Found trace frame 0, tracepoint 1
at ../../../../git/gdb/testsuite/gdb.trace/unavailable.cc:198
198 i = (int) argc + argi + argf + argd + argstruct.memberi + argarray[1];
(gdb) display argc
I also notice that on "core" target, the value of "argc" isn't shown
either. This difference is caused by the code below in printcmd.c:display_command,
if (from_tty && target_has_execution)
do_one_display (new);
Looks the value of each display is shown if the target has execution.
Source code archaeology doesn't tell much about this requirement.
However, if we type command "display" then on "core" or "tfile"
target, the value of "argc" is still displayed,
for "core" target,
(gdb) display argc
(gdb) display
1: argc = 1 '\001'
for "tfile" target,
(gdb) display argc
(gdb) display
1: argc = <unavailable>
I feel that it is not necessary to have such "target has execution"
requirement to show the value of new created display. Auto-display is
a feature to show the value of expression frequently, has nothing to
do with whether target has execution or not. On the other hand, GDB
has the requirement for new created display, but command "display" can
still show them, this is an inconsistency, which should be fixed.
This patch is to remove the checking to target_has_execution from the
condition.
gdb:
2014-05-05 Yao Qi <yao@codesourcery.com>
* printcmd.c (display_command): Remove the check to
target_has_execution.
This patch moves traceframe checking code out of traceframe generation,
so that we can generation traceframe once, and do the checking in multiple
times (with target remote, tfile and ctf respectively). This is a
pure refactor, not functional changes in unavailable.exp.
gdb/testsuite:
2014-05-05 Yao Qi <yao@codesourcery.com>
* gdb.trace/unavailable.exp (gdb_collect_args_test): Move some
code to ...
(gdb_collect_args_test_1): ... it. New proc.
(gdb_collect_locals_test): Move some code to ...
(gdb_collect_locals_test_1): ... it. New proc.
(gdb_unavailable_registers_test): Move some code to ...
(gdb_unavailable_registers_test_1): ... it. New proc.
(gdb_unavailable_floats): Move some code to ...
(gdb_unavailable_floats_1): ... it. New proc.
This commit is actually an update to make the parser in
gdb/stap-probe.c be aware of all the possible prefixes that a probe
argument can have. According to the section "Argument Format" in:
<https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation>
The bitness of the arguments can be 8, 16, 32 or 64 bits, signed or
unsigned. Currently GDB recognizes only 32 and 64-bit arguments.
This commit extends this. It also provides a testcase, only for
x86_64 systems.
gdb/
2014-05-02 Sergio Durigan Junior <sergiodj@redhat.com>
* stap-probe.c (enum stap_arg_bitness): New enums to represent 8
and 16-bit signed and unsigned arguments. Update comment.
(stap_parse_probe_arguments): Extend code to handle such
arguments. Use warning instead of complaint to notify about
unrecognized bitness.
gdb/testsuite/
2014-05-02 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.arch/amd64-stap-optional-prefix.S (main): Add several
probes to test for bitness recognition.
* gdb.arch/amd64-stap-optional-prefix.exp
(test_probe_value_without_reg): New procedure.
Add code to test for different kinds of bitness.
This commit fixes PR breakpoints/16889, which is about a bug that
triggers when GDB tries to parse probes whose arguments do not contain
the initial (and optional) "N@" part. For reference sake, the de
facto format is described here:
<https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation>
Anyway, this PR actually uncovered two bugs (related) that were
happening while parsing the arguments. The first one was that the
parser *was* catching *some* arguments that were missing the "N@"
part, but it wasn't correctly setting the argument's type. This was
causing a NULL pointer being dereferenced, ouch...
The second bug uncovered was that the parser was not catching all of
the cases for a probe which did not provide the "N@" part. The fix
for that was to simplify the check that the code was making to
identify non-prefixed probes. The code is simpler and easier to read
now.
I am also providing a testcase for this bug, only for x86_64
architectures.
gdb/
2014-05-02 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/16889
* stap-probe.c (stap_parse_probe_arguments): Simplify
check for non-prefixed probes (i.e., probes whose
arguments do not start with "N@"). Always set the
argument type to a sane value.
gdb/testsuite/
2014-05-02 Sergio Durigan Junior <sergiodj@redhat.com>
PR breakpoints/16889
* gdb.arch/amd64-stap-optional-prefix.S: New file.
* gdb.arch/amd64-stap-optional-prefix.exp: Likewise.
In a test I was writting, I needed a procedure that would connect to
the target, and do "load", or equivalent.
Years ago, boards would override gdb_load to implement that. Then
gdb_reload was added, and gdb_load was relaxed to allow boards avoid
the spawing and connecting to the target. This sped up gdbserver
testing. See
https://www.sourceware.org/ml/gdb-patches/2007-02/msg00318.html.
To actually spawn the target and load the executable on the target
side, gdb_reload was born:
# gdb_reload -- load a file into the target. Called before "running",
# either the first time or after already starting the program once,
# for remote targets. Most files that override gdb_load should now
# override this instead.
proc gdb_reload { } {
# For the benefit of existing configurations, default to gdb_load.
# Specifying no file defaults to the executable currently being
# debugged.
return [gdb_load ""]
}
Note the comment about specifying no file. Indeed looking at
config/sid.exp, or config/monitor.exp, we see examples of that.
However, the default gdb_load itself doesn't handle the case of no
file specified. When passed no file, it just calls gdb_file_cmd with
no file either, which ends up invocing the "file" command with no
argument, which means unloading the file and its symbols... That
means calling gdb_reload when testing against native targets is
broken. We don't see that today because the only call to gdb_reload
that exists today is guarded by target_info exists
gdb,do_reload_on_run.
The native-extended-gdbserver.exp board is likewise broken here. When
[gdb_load ""] is called, the board sets the remote exec-file to "" ...
Tested on x86_64 Fedora 17, native, remote gdbserver and
extended-remote gdbserver.
testsuite/
2014-05-01 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_load): Extend comment. Skip calling
gdb_file_cmd if no file is specified.
* boards/native-extended-gdbserver.exp (gdb_load): Use the
last_loaded_file to set the remote exec-file.
When connecting to a remote system, we use the compare-sections
command to verify that the box is running the code that we think it is
running. Since the system is up and running and *NOT* 'freshly
downloaded without yet executing anything', read-write sections, of
course, differ from what they were in the executable file.
Comparing read-write sections takes time and more importantly the
MIS-MATCHED output is confusing to some users.
The compare-sections command compares all loadable sections including
read-write sections. This patch gives the user the option to compare
just the loadable read-only sections.
gdb/
2014-05-01 David Taylor <dtaylor@emc.com>
* remote.c (compare_sections_command): Add -r option to compare
all loadable read-only sections.
gdb/doc/
2014-05-01 David Taylor <dtaylor@emc.com>
* gdb.texinfo (compare-sections): Document the new -r (read-only)
option.
This adds a variant of local-remote-host-notty.exp that forces
pseudo-tty allocation, so that readline/editing is enabled.
$ ssh localhost gdb -q
(gdb) show editing
Editing of command lines as they are typed is off.
(gdb)
vs:
$ ssh -t localhost gdb -q
(gdb) show editing
Editing of command lines as they are typed is on.
We now get, e.g.:
Running ../../../src/gdb/testsuite/gdb.base/filesym.exp ...
PASS: gdb.base/filesym.exp: complete on "filesy"
PASS: gdb.base/filesym.exp: completion list for "filesym"
PASS: gdb.base/filesym.exp: set breakpoint at filesym
gdb/testsuite/
2014-05-01 Pedro Alves <palves@redhat.com>
* boards/local-remote-host.exp: New file.
When testing with this board, stdin is not a tty, and so
readline/editing is disabled:
$ ssh localhost gdb -q
(gdb) show editing
Editing of command lines as they are typed is off.
(gdb)
Rename the file, to make room for a version of this board that forces a pseudo-tty.
gdb/testsuite/
2014-05-01 Pedro Alves <palves@redhat.com>
* boards/local-remote-host.exp: Rename to ...
* boards/local-remote-host-notty.exp: ... this.
... and others. The recent patch that fixed several "set remote
foo-packet on/off" commands introduced a regression, observable when
connecting GDB to QEMU. For instance:
(gdb) set debug remote 1
(gdb) tar rem :4444
Remote debugging using :4444
Sending packet: $qSupported:multiprocess+;qRelocInsn+#2a...Ack
Packet received: PacketSize=1000;qXfer:features:read+
Packet qSupported (supported-packets) is supported
Sending packet: $Hgp0.0#ad...Ack
Packet received: OK
Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Ack
Packet received: [...]
Sending packet: $qXfer:features:read:arm-core.xml:0,ffb#08...Ack
Packet received: [...]
!!! -> Sending packet: $QNonStop:0#8c...Ack
Packet received:
Remote refused setting all-stop mode with:
The "QNonStop" feature is associated with the PACKET_QNonStop packet,
with a default of PACKET_DISABLE, so GDB should not be sending the
packet at all.
The patch that introduced the regression decoupled packet_config's
'detect' and 'support' fields, making the former (an auto_boolean)
purely the associated "set remote foo-packet" command's variable. In
the example above, the packet config's 'supported' field does end up
correctly set to PACKET_DISABLE. However, nothing is presently
initializing packet configs that don't actually have a command
associated. Those configs's 'detect' field then ends up set to
AUTO_BOOLEAN_TRUE, simply because that happens to be 0. This forces
GDB to assume the packet is supported, irrespective of what the target
claims it supports, just like if the user had done "set remote
foo-packet on" (this being the associated command, if there was one).
Ideally, all packet configs would have a command associated. While
that isn't true, make sure all packet configs are initialized, even if
no command is associated, and add an assertion that prevents adding
more packets/features without an associated command.
Tested on x86_64 Fedora 17, against pristine gdbserver, and against a
gdbserver with the QNonStop packet/feature disabled with a local hack.
gdb/
2014-04-29 Pedro Alves <palves@redhat.com>
* remote.c (struct packet_config) <detect>: Extend comment.
(add_packet_config_cmd): Don't set the config's detect or support
fields here.
(init_all_packet_configs): Also initialize the config's 'detect'
field.
(reset_all_packet_configs_support): New function.
(remote_open_1): Call reset_all_packet_configs_support instead of
init_all_packet_configs.
(_initialize_remote): Initialize all packet configs. Assert that
all packets have an associated command, except a few known
outliers.
This add a testcases that verifies correct handling of dynamicity
for lower bounds of arrays.
gdb/testsuite/ChangeLog:
* gdb.ada/dyn_arrayidx: New testcase.
Currently, read_subrange_type handles dynamicity only in the case of
the upper bound, and assumes that the lower bound is always static.
That's rooted in the fact that dynamicity was added to support C99
variable-length arrays, where the lower bound is always zero, and
therefore never dynamic. But the lower bound can, in fact, be dynamic
in other languages such as Ada.
Consider for instance the following declaration in Ada...
type Array_Type is array (L .. U) of Natural;
... where L and U are parameters of the function where the declaration
above was made, and whose value are 5 and 10. Currently, the debugger
is able to print the value of the upper bound correctly, but not the
lower bound:
(gdb) ptype array_type
type = array (1 .. 10) of natural
After this patch, the debugger now prints:
(gdb) ptype array_type
type = array (5 .. 10) of natural
gdb/ChangeLog:
* dwarf2read.c (read_subrange_type): Handle dynamic
DW_AT_lower_bound attributes.
Consider the following declaration in Ada...
type Array_Type is array (L .. U) of Natural;
... where L and U are parameters of the function where the declaration
above was made. At the moment, GDB relies on descriptive types in order
to properly decode the array bounds. For instance, if L was 5, and U
was 10, we would see the following:
(gdb) ptype array_type
type = array (5 .. 10) of natural
(gdb) maintenance set ada ignore-descriptive-types
(gdb) ptype array_type
type = array (1 .. 28544912) of natural
This patch enhances ada_discrete_type_{high,low}_bound to resolve
any dynamicity. This is sufficient to fix the case of the upper bound.
For the lower bound, the dwarf2read module does not handle dynamic
lower bounds yet, but once it does, the lower bound should be correctly
handled as well [1].
gdb/ChangeLog:
* ada-lang.c (ada_discrete_type_high_bound): Resolve the type's
dynamic bounds before computing its upper bound.
(ada_discrete_type_low_bound): Same as above with the lower bound.
[1]: The reason why we do not enhance dwarf2read to handle dynamic
lower bounds ahead of this patch is because it unveils some latent
issues such as this one.
This change breaks down the resolve_dynamic_bounds function which
works only on arrays and its index range types into two functions,
one that resolves range types, and one that resolves arrays (using
the new routine to resolve the array's index range type). The
is_dynamic_type and resolve_dynamic_type function are then re-organized
to handle range types as well.
One small change worth mentioning is the fact that, now that range
types are resolved on their own (rather than in the limited context
of array index types), the resolved range types are created from
a copy of the dynamic range type, rather than from scratch (first
parameter of create_range_type). This allows us to preserve as many
original properties in the resolved type as possible (Eg. the type's
name).
This is preparation work that will help better support dynamic range
types for languages that allow the declaration of such types (Eg. Ada).
gdb/ChangeLog:
* dwarf2read.c (is_dynamic_type): Return true for dynamic
range types. Adjust the array handling implementation to
take advantage of this change.
(resolve_dynamic_range): New function, mostly extracted from
resolve_dynamic_bounds.
(resolve_dynamic_array): New function, mostly extracted from
resolve_dynamic_bounds.
(resolve_dynamic_bounds): Delete.
(resolve_dynamic_type): Reimplement. Add handling of
TYPE_CODE_RANGE types.
ada-varobj.c::ada_varobj_describe_simple_array_child only ever gets
called after all GNAT encodings have been applied to (parent_value,
parent_type). So there is no point in redoing it partially by
checking for parallel XA types again.
gdb/ChangeLog:
* ada-varobj.c (ada_varobj_describe_simple_array_child): Remove
handling of parallel ___XA types.
In ada-lang.c::ada_evaluate_subexp, case OP_VAR_VALUE, when noside
is EVAL_AVOID_SIDE_EFFECTS, the first thing we do is set type as
follow:
type = static_unwrap_type (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
Later on in the same block, we make the same call:
return value_zero
(to_static_fixed_type
(static_unwrap_type (SYMBOL_TYPE (exp->elts[pc + 2].symbol))),
not_lval);
This patch removes the second call, since it should result in the same
type being returned, so no point in making that call again.
gdb/ChangeLog:
* ada-lang.c (ada_evaluate_subexp) <OP_VAR_VALUE>: Remove
unnecessary second call to static_unwrap_type.
The makefile rule i386-avx512.c is to generate i386-avx512.c, but it
is written to i386-avx.c by mistake. This patch is to fix this typo.
gdb/gdbserver:
2014-04-28 Yao Qi <yao@codesourcery.com>
* Makefile.in (i386-avx512.c): Fix the typo of generated file
name.
When GDB debug DUMMY_FRAME, SIGTRAMP_FRAME and ARCH_FRAME, even if
"set disassemble-next-line on", it will not output the asm code:
(gdb) set disassemble-next-line on
(gdb) si
<signal handler called>
(gdb)
<signal handler called>
(gdb)
<signal handler called>
So make this patch make they can work together, it will become:
(gdb) si
<signal handler called>
=> 0xffffffff816bfb09 <int_with_check+0>: 65 48 8b 0c 25 c8 c7 00 00 mov %gs:0xc7c8,%rcx
(gdb)
<signal handler called>
=> 0xffffffff816bfb12 <int_with_check+9>: 48 81 e9 d8 1f 00 00 sub $0x1fd8,%rcx
(gdb)
<signal handler called>
=> 0xffffffff816bfb19 <int_with_check+16>: 8b 51 10 mov 0x10(%rcx),%edx
2014-04-27 Hui Zhu <hui@codesourcery.com>
* stack.c (print_frame_info): Call do_gdb_disassembly with
DUMMY_FRAME, SIGTRAMP_FRAME and ARCH_FRAME.
In Dwarf::assemble in dwz.exp, 10 is hard-coded in it,
subprogram {
{name main}
{low_pc main addr}
{high_pc "main + 10" addr}
}
however, the length of main function varies on architectures. The
hard-coded 10 here causes dwz.exp fails on some targets, such as
nios2.
This patch is to add some code to compute the length of function main,
which is similar to what we are doing in entry-values.exp.
gdb/testsuite:
2014-04-26 Yao Qi <yao@codesourcery.com>
* gdb.dwarf2/dwz.exp: Compile main.c to object. Restart GDB
and compute the length of function main. Save it in
$main_length.
(Dwarf::assemble): Use $main_length instead of hard-coded 10.
(top-level): Use gdb_compile to compile objects into
executable and restart GDB. Remove invocation to
prepare_for_testing.
2014-04-25 Pedro Alves <palves@redhat.com>
PR server/16255
* linux-low.c (linux_attach_fail_reason_string): New function.
(linux_attach_lwp): Delete.
(linux_attach_lwp_1): Rename to ...
(linux_attach_lwp): ... this. Take a ptid instead of a pid as
argument. Remove "initial" parameter. Return int instead of
void. Don't error or warn here.
(linux_attach): Adjust to call linux_attach_lwp. Call error on
failure to attach to the tgid. Call warning when failing to
attach to an lwp.
* linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as
argument. Remove "initial" parameter. Return int instead of
void. Don't error or warn here.
(linux_attach_fail_reason_string): New declaration.
* thread-db.c (attach_thread): Adjust to linux_attach_lwp's
interface change. Use linux_attach_fail_reason_string.
On Linux, we need to explicitly ptrace attach to all lwps of a
process. Because GDB might not be connected yet when an attach is
requested, and thus it may not be possible to activate thread_db, as
that requires access to symbols (IOW, gdbserver --attach), a while ago
we make linux_attach loop over the lwps as listed by /proc/PID/task to
find the lwps to attach to.
linux_attach_lwp_1 has:
...
if (initial)
/* If lwp is the tgid, we handle adding existing threads later.
Otherwise we just add lwp without bothering about any other
threads. */
ptid = ptid_build (lwpid, lwpid, 0);
else
{
/* Note that extracting the pid from the current inferior is
safe, since we're always called in the context of the same
process as this new thread. */
int pid = pid_of (current_inferior);
ptid = ptid_build (pid, lwpid, 0);
}
That "safe" comment referred to linux_attach_lwp being called by
thread-db.c. But this was clearly missed when a new call to
linux_attach_lwp_1 was added to linux_attach. As a result,
current_inferior will be set to some random process, and non-initial
lwps of the second inferior get assigned the pid of the wrong
inferior. E.g., in the case of attaching to two inferiors, for the
second inferior (and so on), non-initial lwps of the second inferior
get assigned the pid of the first inferior. This doesn't trigger on
the first inferior, when current_inferior is NULL, add_thread switches
the current inferior to the newly added thread.
Rather than making linux_attach switch current_inferior temporarily
(thus avoiding further reliance on global state), or making
linux_attach_lwp_1 get the tgid from /proc, which add extra syscalls,
and will be wrong in case of the user having originally attached
directly to a non-tgid lwp, and then that lwp spawning new clones (the
ptid.pid field of further new clones should be the same as the
original lwp's pid, which is not the tgid), we note that callers of
linux_attach_lwp/linux_attach_lwp_1 always have the right pid handy
already, so they can pass it down along with the lwpid.
The only other reason for the "initial" parameter is to error out
instead of warn in case of attach failure, when we're first attaching
to a process. There are only three callers of
linux_attach_lwp/linux_attach_lwp_1, and each wants to print a
different warn/error string, so we can just move the error/warn out of
linux_attach_lwp_1 to the callers, thus getting rid of the "initial"
parameter.
There really nothing gdbserver-specific about attaching to two
threaded processes, so this adds a new test under gdb.multi/. The
test passes cleanly against the native GNU/Linux target, but
fails/triggers the bug against GDBserver (before the patch), with the
native-extended-remote board (as plain remote doesn't support
multi-process).
Tested on x86_64 Fedora 17, with the native-extended-gdbserver board.
gdb/gdbserver/
2014-04-25 Pedro Alves <palves@redhat.com>
PR server/16255
* linux-low.c (linux_attach_fail_reason_string): New function.
(linux_attach_lwp): Delete.
(linux_attach_lwp_1): Rename to ...
(linux_attach_lwp): ... this. Take a ptid instead of a pid as
argument. Remove "initial" parameter. Return int instead of
void. Don't error or warn here.
(linux_attach): Adjust to call linux_attach_lwp. Call error on
failure to attach to the tgid. Call warning when failing to
attach to an lwp.
* linux-low.h (linux_attach_lwp): Take a ptid instead of a pid as
argument. Remove "initial" parameter. Return int instead of
void. Don't error or warn here.
(linux_attach_fail_reason_string): New declaration.
* thread-db.c (attach_thread): Adjust to linux_attach_lwp's
interface change. Use linux_attach_fail_reason_string.
gdb/
2014-04-25 Pedro Alves <palves@redhat.com>
PR server/16255
* common/linux-ptrace.c (linux_ptrace_attach_warnings): Rename to ...
(linux_ptrace_attach_fail_reason): ... this. Remove "warning: "
and newline from built string.
* common/linux-ptrace.h (linux_ptrace_attach_warnings): Rename to ...
(linux_ptrace_attach_fail_reason): ... this.
* linux-nat.c (linux_nat_attach): Adjust to use
linux_ptrace_attach_fail_reason.
gdb/testsuite/
2014-04-25 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR server/16255
* gdb.multi/multi-attach.c: New file.
* gdb.multi/multi-attach.exp: New file.
For several RSP packets, there's a corresponding "set remote
foo-packet on/off/auto" command that one can use do bypass
auto-detection of support for the packet or feature. However, I
noticed that setting several of these commands to 'on' or 'off'
doesn't actually have any effect. These are, at least:
set remote breakpoint-commands-packet
set remote conditional-breakpoints-packet
set remote fast-tracepoints-packet
set remote static-tracepoints-packet
set remote install-in-trace-packet
These are commands that control a remote protocol feature that doesn't
have a corresponding regular packet, and because of that we cache the
knowledge of the remote side support as returned by the qSupported
packet in the remote_state object.
E.g., in the case of the 'set remote breakpoint-commands-packet'
command, whether the feature is supported is recorded in the
'breakpoint_commands' field of the remote_state object.
Whether to bypass packet support auto-detection or not is controlled
by the 'detect' field of the corresponding packet's packet_config
structure. That field is the variable associated directly with the
"set remote foo-packet" command. Actual remote stub support for the
packet (or feature) is recorded in the 'support' field of the same
structure.
However, when the user toggles the command, the 'support' field is
also correspondingly updated to PACKET_ENABLE/DISABLE/SUPPORT_UNKNOWN,
discarding the knowledge of whether the target actually supports the
feature. If one toggles back to 'auto', it's no big issue for real
packets, as they'll just end up re-probed the next time they might be
necessary. But features whose support is only reported through
qSupported don't get their corresponding (manually added/maintained)
fields in remote_state objected updated. As we lost the actual status
of the target support for the feature, GDB would need to probe the
qSupported features again, which GDB doesn't do.
But we can avoid that extra traffic, and clean things up, IMO.
Instead of going in that direction, this patch completely decouples
struct packet_config's 'detect' and 'support' fields. E.g., when the
user does "set remote foo-packet off", instead of setting the packet
config's 'support' field to PACKET_DISABLE, the 'support' field is not
touched at all anymore. That is, we end up respecting this simple
table:
| packet_config->detect | packet_config->support | should use packet/feature? |
|-----------------------+------------------------+----------------------------|
| auto | PACKET_ENABLE | PACKET_ENABLE |
| auto | PACKET_DISABLE | PACKET_DISABLE |
| auto | PACKET_UNKNOWN | PACKET_UNKNOWN |
| yes | don't care | PACKET_ENABLE |
| no | don't care | PACKET_DISABLE |
This is implemented by the new packet_support function. With that, we
need to update this pattern throughout:
if (remote_protocol_packets[PACKET_foo].support == PACKET_DISABLE)
to do this instead:
if (packet_support (PACKET_qAttached) == PACKET_DISABLE)
where as mentioned, the packet_support function takes struct
packet_config's 'detect' field into account, like in the table above.
As when the packet is force-disabled or force-enabled, the 'support'
field is just ignored, if the command is set back to auto, we'll
resume respecting whatever the target said it supports. IOW, the end
result is that the 'support' field always represents whether the
target actually supports the packet or not.
After all that, the manually maintained breakpoint_commands and
equivalent fields of struct remote_state can then be eliminated, with
references replaced by checking the result of calling the
packet_support function on the corresponding packet or feature. This
required adding new PACKET_foo enum values for several features that
didn't have it yet. (The patch does not add corresponding "set remote
foo-packet" style commands though, focusing only on bug fixing and
laying the groundwork).
Tested on x86_64 Fedora 17, native GDBserver. The new tests all fail
without this patch.
gdb/
2014-04-25 Pedro Alves <palves@redhat.com>
* remote.c (struct remote_state): Remove multi_process_aware,
non_stop_aware, cond_tracepoints, cond_breakpoints,
breakpoint_commands, fast_tracepoints, static_tracepoints,
install_in_trace, disconnected_tracing,
enable_disable_tracepoints, string_tracing, and
augmented_libraries_svr4_read fields.
(remote_multi_process_p): Move further below in the file.
(struct packet_config): Add comments.
(update_packet_config): Delete function.
(show_packet_config_cmd): Use packet_config_support.
(add_packet_config_cmd): Use NULL as set callback.
(packet_ok): "set remote foo-packet"-style commands no longer
change config->supported -- adjust.
(PACKET_ConditionalTracepoints, PACKET_ConditionalBreakpoints)
(PACKET_BreakpointCommands, PACKET_FastTracepoints)
(PACKET_StaticTracepoints, PACKET_InstallInTrace): Add comments.
(PACKET_QNonStop, PACKET_multiprocess_feature)
(PACKET_EnableDisableTracepoints_feature, PACKET_tracenz_feature)
(PACKET_DisconnectedTracing_feature)
(PACKET_augmented_libraries_svr4_read_feature): New enum values.
(set_remote_protocol_packet_cmd): Delete function.
(packet_config_support, packet_support): New functions.
(set_remote_protocol_Z_packet_cmd): Don't call
update_packet_config.
(remote_query_attached, remote_pass_signals)
(remote_program_signals, remote_threads_info)
(remote_threads_extra_info, remote_start_remote): Use
packet_support.
(remote_start_remote): Use packet_config_support and
packet_support.
(init_all_packet_configs): Set all packets to unknown support,
instead of calling update_packet_config.
(remote_check_symbols): Use packet_support.
(remote_supported_packet): Unconditionally set the packet config's
support status.
(remote_multi_process_feature, remote_non_stop_feature)
(remote_cond_tracepoint_feature, remote_cond_breakpoint_feature)
(remote_breakpoint_commands_feature)
(remote_fast_tracepoint_feature, remote_static_tracepoint_feature)
(remote_install_in_trace_feature)
(remote_disconnected_tracing_feature)
(remote_enable_disable_tracepoint_feature)
(remote_string_tracing_feature)
(remote_augmented_libraries_svr4_read_feature): Delete functions.
(remote_protocol_features): Adjust to use remote_supported_packet
for "augmented-libraries-svr4-read", "multiprocess", "QNonStop",
"ConditionalTracepoints", "ConditionalBreakpoints",
"BreakpointCommands", "FastTracepoints", "StaticTracepoints",
"InstallInTrace", "DisconnectedTracing", "DisconnectedTracing",
"EnableDisableTracepoints", and "tracenz".
(remote_query_supported): Use packet_support.
(remote_open_1): Adjust.
(extended_remote_attach_1): Use packet_support. Switch on the
result of packet_ok instead of checking whether the packet ended
up disabled.
(remote_vcont_resume): Use packet_support.
(remote_resume, remote_stop_ns, fetch_register_using_p)
(remote_prepare_to_store, store_register_using_P)
(check_binary_download, remote_write_bytes): Use packet_support.
(remote_vkill): Use packet_support. Switch on the result of
packet_ok instead of checking whether the packet ended up
disabled.
(extended_remote_supports_disable_randomization): Use
packet_support.
(extended_remote_run): Switch on the result of packet_ok instead
of checking whether the packet ended up disabled.
(remote_insert_breakpoint, remote_remove_breakpoint)
(remote_insert_watchpoint, remote_remove_watchpoint)
(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Use
packet_support.
(remote_search_memory): Use packet_config_support.
(remote_get_thread_local_address, remote_get_tib_address)
(remote_hostio_send_command, remote_can_execute_reverse): Use
packet_support.
(remote_supports_cond_tracepoints)
(remote_supports_cond_breakpoints)
(remote_supports_fast_tracepoints)
(remote_supports_static_tracepoints)
(remote_supports_install_in_trace)
(remote_supports_enable_disable_tracepoint)
(remote_supports_string_tracing)
(remote_can_run_breakpoint_commands): Rewrite, checking whether
the packet config says the feature is enabled or disabled.
(remote_download_tracepoint, remote_trace_set_readonly_regions)
(remote_get_trace_status): Use packet_support.
(remote_set_disconnected_tracing): Adjust to check whether the
feature is enabled with packet_support.
(remote_set_trace_buffer_size, remote_use_agent)
(remote_can_use_agent, remote_supports_btrace): Use
packet_support.
(remote_enable_btrace, remote_disable_btrace, remote_read_btrace):
Use packet_config_support.
(remote_augmented_libraries_svr4_read): Rewrite, checking whether
the packet config says the feature is enabled or disabled.
(set_range_stepping): Use packet_support.
gdb/testsuite/
2014-04-25 Pedro Alves <palves@redhat.com>
* gdb.base/cond-eval-mode.exp (warning): Move trailing \r\n to
user.
(top level): Test that "set remote conditional-breakpoints-packet
off" works as intended.
* gdb.base/dprintf.exp: Test that "set remote
breakpoint-commands-packet off" works as intended.
* gdb.trace/change-loc.exp (tracepoint_install_in_trace_disabled):
New function.
(top level): Call it.
* gdb.trace/ftrace.exp (test_fast_tracepoints): Test that "set
remote fast-tracepoints-packet off" works as intended.
* gdb.trace/qtro.exp (gdb_is_target_remote): Moved ...
* lib/gdb.exp (gdb_is_target_remote): ... here.
gdb/testsuite/
* gdb.base/catch-syscall.c: Make unreferenced statics non-static to
ensure clang would not discard them.
* gdb.base/gdbvars.c: Ditto.
* gdb.base/memattr.c: Ditto.
* gdb.base/whatis.c: Ditto.
* gdb.python/py-prettyprint.c: Ditto.
* gdb.trace/actions.c: Ditto.
* gdb.cp/ptype-cv-cp.cc: Mark unused global const int as used to
ensure clang would not discard it.
gdb/testsuite/
* gdb.stabs/gdb11479.c (tag_dummy_enum): introduce a variable to cause
clang to emit the full definition of type required by the test
* gdb.stabs/gdb11479.exp (do_test): correct a typo in a test message
gdb/testsuite/
* gdb.cp/pr10728-x.cc: Return by value instead of pointer to coax
Clang into emitting the definition of the type.
* gdb.cp/pr10728-x.h: Ditto.
* gdb.cp/pr10728-y.cc: Ditto.
gdb/testsuite/
* gdb.base/label.exp: XFAIL label related tests under Clang.
* gdb.cp/cplabel.exp: Ditto.
* gdb.linespec/ls-errs.exp: Refactor tests to execute directly
and XFAIL under Clang those using labels.
I happen to see that 'double_label' isn't used in dwz.exp dwarf assembler.
Similarly, partial_label and double_label aren't used in dwzbuildid.exp.
This patch is to remove them.
gdb/testsuite:
2014-04-25 Yao Qi <yao@codesourcery.com>
* gdb.dwarf2/dwz.exp (Dwarf::assemble): Remove unused
double_label.
* gdb.dwarf2/dwzbuildid.exp (Dwarf::assemble): Remove
partial_label and double_label.
This patch expands standard_exc's introductory comment to explain
why this table does not include Numeric_Error.
gdb/ChangeLog:
* ada-lang.c (standard_exc): Expand introductory comment.
gdb/testsuite/
* gdb.cp/cpexprs.cc: Move braces to the same line as the start
of the function to work across GCC and Clang.
* gdb.cp/cpexprs.exp: Account for GCC/Clang difference in vtable
pointer types (const void ** const V void **).
This patch adds support for the Intel(R) Advanced Vector
Extensions 512 (Intel(R) AVX-512) registers. Native and remote
debugging are covered by this patch.
Intel(R) AVX-512 is an extension to AVX to support 512-bit wide
SIMD registers in 64-bit mode (XMM0-XMM31, YMM0-YMM31, ZMM0-ZMM31).
The number of available registers in 32-bit mode is still 8
(XMM0-7, YMM0-7, ZMM0-7). The lower 256-bits of the ZMM registers
are aliased to the respective 256-bit YMM registers. The lower
128-bits are aliased to the respective 128-bit XMM registers.
There are also 8 new, dedicated mask registers (K0-K7) in both 32-bit
mode and 64-bit mode.
For more information please see
Intel(R) Developer Zone: Intel(R) AVX
http://software.intel.com/en-us/intel-isa-extensions#pid-16007-1495
Intel(R) Architecture Instruction Set Extensions Programming Reference:
http://software.intel.com/en-us/file/319433-017pdf
2014-04-24 Michael Sturm <michael.sturm@mintel.com>
Walfred Tedeschi <walfred.tedeschi@intel.com>
* amd64-linux-nat.c (amd64_linux_gregset32_reg_offset): Add
AVX512 registers.
(amd64_linux_read_description): Add code to handle AVX512 xstate
mask and return respective tdesc.
* amd64-linux-tdep.c: Include features/i386/amd64-avx512-linux.c
and features/i386/x32-avx512-linux.c.
(amd64_linux_gregset_reg_offset): Add AVX512 registers.
(amd64_linux_core_read_description): Add code to handle AVX512
xstate mask and return respective tdesc.
(_initialize_amd64_linux_tdep): Initialize AVX512 tdesc.
* amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM): Adjust regnum
calculation.
(AMD64_LINUX_NUM_REGS): Adjust to new number of registers.
(tdesc_amd64_avx512_linux): New prototype.
(tdesc_x32_avx512_linux): Likewise.
* amd64-tdep.c: Include features/i386/amd64-avx512.c and
features/i386/x32-avx512.c.
(amd64_ymm_avx512_names): New register names for pseudo
registers YMM16-31.
(amd64_ymmh_avx512_names): New register names for raw registers
YMMH16-31.
(amd64_k_names): New register names for K registers.
(amd64_zmmh_names): New register names for ZMM raw registers.
(amd64_zmm_names): New registers names for ZMM pseudo registers.
(amd64_xmm_avx512_names): New register names for XMM16-31
registers.
(amd64_pseudo_register_name): Add code to return AVX512 pseudo
registers.
(amd64_init_abi): Add code to intitialize AVX512 tdep variables
if feature is present.
(_initialize_amd64_tdep): Call AVX512 tdesc initializers.
* amd64-tdep.h (enum amd64_regnum): Add AVX512 registers.
(AMD64_NUM_REGS): Adjust to new number of registers.
* i386-linux-nat.c (GETXSTATEREGS_SUPPLIES): Extend range of
registers supplied via XSTATE by AVX512 registers.
(i386_linux_read_description): Add case for AVX512.
* i386-linux-tdep.c: Include i386-avx512-linux.c.
(i386_linux_gregset_reg_offset): Add AVX512 registers.
(i386_linux_core_read_description): Add case for AVX512.
(i386_linux_init_abi): Install supported register note section
for AVX512.
(_initialize_i386_linux_tdep): Add call to tdesc init function for
AVX512.
* i386-linux-tdep.h (I386_LINUX_NUM_REGS): Set number of
registers to be number of zmm7h + 1.
(tdesc_i386_avx512_linux): Add tdesc for AVX512 registers.
* i386-tdep.c: Include features/i386/i386-avx512.c.
(i386_zmm_names): Add ZMM pseudo register names array.
(i386_zmmh_names): Add ZMM raw register names array.
(i386_k_names): Add K raw register names array.
(num_lower_zmm_regs): Add constant for the number of lower ZMM
registers. AVX512 has 16 more ZMM registers than there are YMM
registers.
(i386_zmmh_regnum_p): Add function to look up register number of
ZMM raw registers.
(i386_zmm_regnum_p): Likewise for ZMM pseudo registers.
(i386_k_regnum_p): Likewise for K raw registers.
(i386_ymmh_avx512_regnum_p): Likewise for additional YMM raw
registers added by AVX512.
(i386_ymm_avx512_regnum_p): Likewise for additional YMM pseudo
registers added by AVX512.
(i386_xmm_avx512_regnum_p): Likewise for additional XMM registers
added by AVX512.
(i386_register_name): Add code to hide YMMH16-31 and ZMMH0-31.
(i386_pseudo_register_name): Add ZMM pseudo registers.
(i386_zmm_type): Construct and return vector registers type for ZMM
registers.
(i386_pseudo_register_type): Return appropriate type for YMM16-31,
ZMM0-31 pseudo registers and K registers.
(i386_pseudo_register_read_into_value): Add code to read K, ZMM
and YMM16-31 registers from register cache.
(i386_pseudo_register_write): Add code to write K, ZMM and
YMM16-31 registers.
(i386_register_reggroup_p): Add code to include/exclude AVX512
registers in/from respective register groups.
(i386_validate_tdesc_p): Handle AVX512 feature, add AVX512
registers if feature is present in xcr0.
(i386_gdbarch_init): Add code to initialize AVX512 feature
variables in tdep structure, wire in pseudo registers and call
initialize_tdesc_i386_avx512.
* i386-tdep.h (struct gdbarch_tdep): Add AVX512 related
variables.
(i386_regnum): Add AVX512 registers.
(I386_SSE_NUM_REGS): New define for number of SSE registers.
(I386_AVX_NUM_REGS): Likewise for AVX registers.
(I386_AVX512_NUM_REGS): Likewise for AVX512 registers.
(I386_MAX_REGISTER_SIZE): Change to 64 bytes, ZMM registers are
512 bits wide.
(i386_xmm_avx512_regnum_p): New prototype for register look up.
(i386_ymm_avx512_regnum_p): Likewise.
(i386_k_regnum_p): Likewise.
(i386_zmm_regnum_p): Likewise.
(i386_zmmh_regnum_p): Likewise.
* i387-tdep.c : Update year in copyright notice.
(xsave_ymm_avx512_offset): New table for YMM16-31 offsets in
XSAVE buffer.
(XSAVE_YMM_AVX512_ADDR): New macro.
(xsave_xmm_avx512_offset): New table for XMM16-31 offsets in
XSAVE buffer.
(XSAVE_XMM_AVX512_ADDR): New macro.
(xsave_avx512_k_offset): New table for K register offsets in
XSAVE buffer.
(XSAVE_AVX512_K_ADDR): New macro.
(xsave_avx512_zmm_h_offset): New table for ZMM register offsets
in XSAVE buffer.
(XSAVE_AVX512_ZMM_H_ADDR): New macro.
(i387_supply_xsave): Add code to supply AVX512 registers to XSAVE
buffer.
(i387_collect_xsave): Add code to collect AVX512 registers from
XSAVE buffer.
* i387-tdep.h (I387_NUM_XMM_AVX512_REGS): New define for number
of XMM16-31 registers.
(I387_NUM_K_REGS): New define for number of K registers.
(I387_K0_REGNUM): New define for K0 register number.
(I387_NUM_ZMMH_REGS): New define for number of ZMMH registers.
(I387_ZMM0H_REGNUM): New define for ZMM0H register number.
(I387_NUM_YMM_AVX512_REGS): New define for number of YMM16-31
registers.
(I387_YMM16H_REGNUM): New define for YMM16H register number.
(I387_XMM16_REGNUM): New define for XMM16 register number.
(I387_YMM0_REGNUM): New define for YMM0 register number.
(I387_KEND_REGNUM): New define for last K register number.
(I387_ZMMENDH_REGNUM): New define for last ZMMH register number.
(I387_YMMH_AVX512_END_REGNUM): New define for YMM31 register
number.
(I387_XMM_AVX512_END_REGNUM): New define for XMM31 register
number.
* common/i386-xstate.h: Add AVX 3.1 feature bits, mask and XSTATE
size.
* features/Makefile: Add AVX512 related files.
* features/i386/32bit-avx512.xml: New file.
* features/i386/64bit-avx512.xml: Likewise.
* features/i386/amd64-avx512-linux.c: Likewise.
* features/i386/amd64-avx512-linux.xml: Likewise.
* features/i386/amd64-avx512.c: Likewise.
* features/i386/amd64-avx512.xml: Likewise.
* features/i386/i386-avx512-linux.c: Likewise.
* features/i386/i386-avx512-linux.xml: Likewise.
* features/i386/i386-avx512.c: Likewise.
* features/i386/i386-avx512.xml: Likewise.
* features/i386/x32-avx512-linux.c: Likewise.
* features/i386/x32-avx512-linux.xml: Likewise.
* features/i386/x32-avx512.c: Likewise.
* features/i386/x32-avx512.xml: Likewise.
* regformats/i386/amd64-avx512-linux.dat: New file.
* regformats/i386/amd64-avx512.dat: Likewise.
* regformats/i386/i386-avx512-linux.dat: Likewise.
* regformats/i386/i386-avx512.dat: Likewise.
* regformats/i386/x32-avx512-linux.dat: Likewise.
* regformats/i386/x32-avx512.dat: Likewise.
* NEWS: Add note about new support for AVX512.
testsuite/
* Makefile.in (EXECUTABLES): Added i386-avx512.
* gdb.arch/i386-avx512.c: New file.
* gdb.arch/i386-avx512.exp: Likewise.
gdbserver/
* Makefile.in: Added rules to handle new files
i386-avx512.c i386-avx512-linux.c amd64-avx512.c
amd64-avx512-linux.c x32-avx512.c x32-avx512-linux.c.
* configure.srv (srv_i386_regobj): Add i386-avx512.o.
(srv_i386_linux_regobj): Add i386-avx512-linux.o.
(srv_amd64_regobj): Add amd64-avx512.o and x32-avx512.o.
(srv_amd64_linux_regobj): Add amd64-avx512-linux.o and
x32-avx512-linux.o.
(srv_i386_32bit_xmlfiles): Add i386/32bit-avx512.xml.
(srv_i386_64bit_xmlfiles): Add i386/64bit-avx512.xml.
(srv_amd64_xmlfiles): Add i386/amd64-avx512.xml and
i386/x32-avx512.xml.
(srv_i386_linux_xmlfiles): Add i386/i386-avx512-linux.xml.
(srv_amd64_linux_xmlfiles): Add i386/amd64-avx512-linux.xml and
i386/x32-avx512-linux.xml.
* i387-fp.c (num_avx512_k_registers): New constant for number
of K registers.
(num_avx512_zmmh_low_registers): New constant for number of
lower ZMM registers (0-15).
(num_avx512_zmmh_high_registers): New constant for number of
higher ZMM registers (16-31).
(num_avx512_ymmh_registers): New contant for number of higher
YMM registers (ymm16-31 added by avx521 on x86_64).
(num_avx512_xmm_registers): New constant for number of higher
XMM registers (xmm16-31 added by AVX512 on x86_64).
(struct i387_xsave): Add space for AVX512 registers.
(i387_cache_to_xsave): Change raw buffer size to 64 characters.
Add code to handle AVX512 registers.
(i387_xsave_to_cache): Add code to handle AVX512 registers.
* linux-x86-low.c (init_registers_amd64_avx512_linux): New
prototypei from generated file.
(tdesc_amd64_avx512_linux): Likewise.
(init_registers_x32_avx512_linux): Likewise.
(tdesc_x32_avx512_linux): Likewise.
(init_registers_i386_avx512_linux): Likewise.
(tdesc_i386_avx512_linux): Likewise.
(x86_64_regmap): Add AVX512 registers.
(x86_linux_read_description): Add code to handle AVX512 XSTATE
mask.
(initialize_low_arch): Add code to initialize AVX512 registers.
doc/
* gdb.texinfo (i386 Features): Add description of AVX512
registers.
Change-Id: Ifc4c08c76b85dbec18d02efdbe6182e851584438
Signed-off-by: Michael Sturm <michael.sturm@intel.com>
breakpoint table handling. This is a patch in five parts (all committed
here in one commit).
----- 1/5: parse_args
parse_args is a very useful utility function which allows you to do
getopt-y kinds of things in Tcl.
Example:
proc myproc {foo args} {
parse_args {{bar} {baz "abc"} {qux}}
# ...
}
myproc ABC -bar -baz DEF peanut butter
will define the following variables in myproc:
foo (=ABC), bar (=1), baz (=DEF), and qux (=0)
args will be the list {peanut butter}
----- 2/5: mi_build_kv_pairs
build_kv_pairs simply does what it says: given the input list
and an option join string, it combines list elements into kv-pairs
for MI handling. It knows how to handle tuples and other special
MI types.
Example:
mi_build_kv_pairs {a b c d e f g \[.*\]}
returns a=\"b\",c=\"d\",e=\"f\",g=\[.*\]
----- 3/5: mi_make_breakpoint
This function builds breakpoint regexps, such as
"bkpt={number=\".*\", [snip]}".
Note that ONLY the options given to mi_make_breakpoint/mi_create_breakpoint
will actually be tested. So if -number is omitted, the regexp will allow
anything [number=\".*\"]
Examples:
mi_make_breakpoint -number 3
mi_create_breakpoint "myfile.c:21" -file myfile.c -line 21
----- 4/5: mi_make_breakpoint_table
This function builds MI breakpoint table regexps.
Example:
set bps {}
lappend bps [mi_make_breakpoint -number 1 -func "main" \
-file ".*/myfile.c" -line 42
lappend bps [mi_make_breakpoint -number 2 -func "marker" \
-file ".*myfile.c" -line 21
gdb_test "-break-info" "\\^done,[mi_make_breakpoint_table $bps]" \
"breakpoint list"
----- 5/5: Update all callers
Self-explanatory
testsuite/ChangeLog
2014-04-23 Keith Seitz <keiths@redhat.com>
* lib/mi-support.exp (mi_list_breakpoints): Delete.
(mi_make_breakpoint_table): New procedure.
(mi_create_breakpoint): Use mi_make_breakpoint
and return the result.
(mi_make_breakpoint): New procedure.
(mi_build_kv_pairs): New procedure.
* gdb.mi/mi-break.exp: Remove unused globals,
update mi_create_breakpoint usage, and use mi_make_breakpoint_table.
All callers updated.
* gdb.mi/mi-dprintf.exp: Use variable to track command
number.
Update all callers of mi_create_breakpoint and use
mi_make_breakpoint_table.
Remove any unused global variables.
* gdb.mi/mi-nonstop.exp: Likewise.
* gdb.mi/mi-nsintrall.exp: Likewise.
* gdb.mi/mi-nsmoribund.exp: Likewise.
* gdb.mi/mi-nsthrexec.exp: Likewise.
* gdb.mi/mi-reverse.exp: Likewise.
* gdb.mi/mi-simplerun.exp: Likewise.
* gdb.mi/mi-stepn.exp: Likewise.
* gdb.mi/mi-syn-frame.exp: Likewise.
* gdb.mi/mi-until.exp: Likewise.
* gdb.mi/mi-var-cp.exp: Likewise.
* gdb.mi/mi-var-display.exp: Likewise.
* gdb.mi/mi2-amd64-entry-value.exp: Likewise.
* gdb.mi/mi2-var-child.exp: Likewise.
* gdb.mi/mi-vla-c99.exp: Likewise.
* lib/mi-support.exp: Likewise.
From Ian Lance Taylor <iant@cygnus.com>:
* lib/gdb.exp (parse_args): New procedure.
My main motivation here is moving in the direction of decoupling
insert_point/remove_point from packet numbers, though this bit alone
should make it a little bit easier to merge gdb/gdbserver/i386-low.c
and gdb/i386-nat.c (which are largely the same).
Tested on x86_64 Fedora 17, and cross built for i686-mingw32 too.
gdb/gdbserver/
2014-04-23 Pedro Alves <palves@redhat.com>
* i386-low.c: Don't include break-common.h here.
(i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change
prototype to take target_hw_bp_type as argument instead of a Z
packet char.
* i386-low.h: Include break-common.h here.
(Z_packet_to_hw_type): Declare.
(i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change
prototypes.
* linux-x86-low.c (x86_insert_point): Convert the packet number to
a target_hw_bp_type before calling i386_low_insert_watchpoint.
(x86_remove_point): Convert the packet number to a
target_hw_bp_type before calling i386_low_remove_watchpoint.
* win32-i386-low.c (i386_insert_point): Convert the packet number
to a target_hw_bp_type before calling i386_low_insert_watchpoint.
(i386_remove_point): Convert the packet number to a
target_hw_bp_type before calling i386_low_remove_watchpoint.
Without the code portion of the patch, we get these failures:
FAIL: gdb.base/break-unload-file.exp: always-inserted on: break: continue
FAIL: gdb.base/break-unload-file.exp: always-inserted on: hbreak: continue
FAIL: gdb.base/sym-file.exp: stale bkpts: continue to breakpoint: end here
They all looks like random SIGTRAPs:
continue
Continuing.
Program received signal SIGTRAP, Trace/breakpoint trap.
0x0000000000400541 in foo () at ../../../src/gdb/testsuite/gdb.base/break-unload-file.c:21
21 }
(gdb) FAIL: gdb.base/break-unload-file.exp: always-inserted on: break: continue
(This is a regression caused by the remove-symbol-file command
series.)
break-unload-file.exp is about having breakpoints inserted, and then
doing "file". I caught this while writing a test that does "file
PROGRAM", while PROGRAM was already loaded, which internally does
"file" first, because I wanted to force a breakpoint_re_set, but the
test is more explicit in case GDB ever optimizes out that re-set.
The problem is that unloading the file with "file" ends up in
disable_breakpoints_in_freed_objfile, which marks all breakpoint
locations of the objfile as both shlib_disabled, _and_ clears the
inserted flag, without actually removing the breakpoints from the
inferior. Now, usually, in all-stop, breakpoints will already be
removed from the inferior before the user can issue the "file"
command, but, with non-stop, or breakpoints always-inserted on mode,
breakpoints stay inserted even while the user has the prompt. In the
latter case, then, if we let the program continue, and it executes the
address where we had previously set the breakpoint, it'll actually
execute the breakpoint instruction that we left behind...
Now, one issue is that the intent of
disable_breakpoints_in_freed_objfile is really to handle the unloading
of OBJF_USERLOADED objfiles. These are objfiles that were added with
add-symbol-file and that are removed with remove-symbol-file.
"add-symbol-file"'s docs in the manual clearly say these commands are
used to let GDB know about dynamically loaded code:
You would use this command when @var{filename} has been dynamically
loaded (by some other means) into the program that is running.
Similarly, the online help says:
(gdb) help add-symbol-file
Load symbols from FILE, assuming FILE has been dynamically loaded.
So it makes sense to, like when shared libraries are unloaded through
the generic solib machinery, mark the breakpoint locations as
shlib_disabled. But, the "file" command is not about dynamically
loaded code, it's about the main program. So the patch makes
disable_breakpoints_in_freed_objfile skip all objfiles but
OBJF_USERLOADED ones, thus skipping the main objfile.
Then, the reason that disable_breakpoints_in_freed_objfile was
clearing the inserted flag isn't clear, but likely to avoid breakpoint
removal errors, assuming remove-symbol-file was called after the
dynamic object was already unmapped from the inferior. In that case,
it'd okay to simply clear the inserted flag, but not so if the user
for example does remove-symbol-file to remove the library because he
made a mistake in the library's address, and wants to re-do
add-symbol-file with the correct address.
To address all that, I propose an alternative implementation, that
handles both cases. The patch includes changes to sym-file.exp to
cover them.
This implementation leaves the inserted flag alone, and handles
breakpoint insertion/removal failure gracefully when the locations are
in OBJF_USERLOADED objfiles, just like we handle insertion/removal
failure gracefully for locations in shared libraries.
To try to make sure we aren't patching back stale shadow memory
contents into the inferior, in case the program mapped a different
library at the same address where we had the breakpoint, without the
user having had a chance of remove-symbol-file'ing before, this adds a
new memory_validate_breakpoint function that checks if the breakpoint
instruction is still in memory. ppc_linux_memory_remove_breakpoint
does this unconditionally for all memory breakpoints, and questions
whether memory_remove_breakpoint should be changed to do this for all
breakpoints. Possibly yes, though I'm not certain, hence this
baby-steps patch.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2014-04-23 Pedro Alves <palves@redhat.com>
* breakpoint.c (insert_bp_location): Tolerate errors if the
breakpoint is set in a user-loaded objfile.
(remove_breakpoint_1): Likewise. Also tolerate errors if the
location is marked shlib_disabled. If the breakpoint is set in a
user-loaded objfile is a GDB-side memory breakpoint, validate it
before uninsertion. (disable_breakpoints_in_freed_objfile): Skip
non-OBJF_USERLOADED objfiles. Don't clear the location's inserted
flag.
* mem-break.c (memory_validate_breakpoint): New function.
* objfiles.c (userloaded_objfile_contains_address_p): New
function.
* objfiles.h (userloaded_objfile_contains_address_p): Declare.
* target.h (memory_validate_breakpoint): New declaration.
gdb/testsuite/
2014-04-23 Pedro Alves <palves@redhat.com>
* gdb.base/break-unload-file.c: New file.
* gdb.base/break-unload-file.exp: New file.
* gdb.base/sym-file-lib.c (baz): New function.
* gdb.base/sym-file-loader.c (struct segment) <mapped_size>: New
field.
(load): Store the segment's mapped size.
(unload): New function.
(unload_shlib): New function.
* gdb.base/sym-file-loader.h (unload_shlib): New declaration.
* gdb.base/sym-file-main.c (main): Unload, and reload the library,
set a breakpoint at baz, and call it.
* gdb.base/sym-file.exp: New tests for stale breakpoint
instructions.
libraries.
As explained in
https://sourceware.org/ml/gdb-patches/2008-08/msg00361.html, after a
shared library was unloaded, we can no longer insert or remove
breakpoints into/from its (no longer present) code segment. That'll
fail with memory errors. However, that concern does not apply to
hardware breakpoints. By definition, hardware breakpoints are
implemented using a mechanism that is not dependent on being able to
modify the target's memory. Usually, by setting up CPU debug
registers. IOW, we should be able to set hw breakpoints in an
unmapped address. We don't seem to have a test that exercises that,
so this patch adds one.
I noticed the error supression because of a related issue -- the
target_insert_hw_breakpoint/target_remove_hw_breakpoint interfaces
don't really distinguish "not supported" from "error" return, and so
remote.c returns -1 in both cases. This results in hardware
breakpoints set in shared libraries silently ending up pending forever
even though the target doesn't actually support hw breakpoints.
(gdb) set breakpoint always-inserted on
(gdb) set remote Z-packet off
(gdb) info breakpoints
No breakpoints or watchpoints.
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y <PENDING> shrfunc
After the patch we get the expected:
(gdb) hbreak shrfunc
Hardware assisted breakpoint 3 at 0x7ffff7dfb657: file ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c, line 21.
Warning:
Cannot insert hardware breakpoint 3.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.
(gdb) info break
Num Type Disp Enb Address What
3 hw breakpoint keep y 0x00007ffff7dfb657 in shrfunc at ../../../src/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported-shr.c:21
(HW breakpoints set in the main executable, when the target doesn't
support HW breakpoints always resulted in the latter output.)
We probably should improve the insert/remove interface to return a
different error code for unsupported. But I chose to fix the error
supression first, as it's a deeper and wider issue.
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/
2014-04-23 Pedro Alves <palves@redhat.com>
* breakpoint.c (insert_bp_location, remove_breakpoint_1): If
the breakpoint is set in a shared library, only suppress
errors for software breakpoints, not hardware breakpoints.
gdb/testsuite/
2014-04-23 Pedro Alves <palves@redhat.com>
* gdb.base/hbreak-in-shr-unsupported-shr.c: New file.
* gdb.base/hbreak-in-shr-unsupported.c: New file.
* gdb.base/hbreak-in-shr-unsupported.exp: New file.
* gdb.base/hbreak-unmapped.c: New file.
* gdb.base/hbreak-unmapped.exp: New file.
* gdb.trace/qtro.exp (gdb_is_target_remote): Move ...
* lib/gdb.exp (gdb_is_target_remote): ... here.
If a thread trips on a breakpoint that needs stepping over just after
finishing a step over, GDB currently fails an assertion. This is a
regression caused by the "Handle multiple step-overs." patch
(99619beac6) at
https://sourceware.org/ml/gdb-patches/2014-02/msg00765.html.
(gdb) x /4i $pc
=> 0x400540 <main+4>: movl $0x0,0x2003da(%rip) # 0x600924 <i>
0x40054a <main+14>: movl $0x1,0x2003d0(%rip) # 0x600924 <i>
0x400554 <main+24>: movl $0x2,0x2003c6(%rip) # 0x600924 <i>
0x40055e <main+34>: movl $0x3,0x2003bc(%rip) # 0x600924 <i>
(gdb) PASS: gdb.base/consecutive-step-over.exp: get breakpoint addresses
break *0x40054a
Breakpoint 2 at 0x40054a: file ../../../src/gdb/testsuite/gdb.base/consecutive-step-over.c, line 23.
(gdb) PASS: gdb.base/consecutive-step-over.exp: insn 1: set breakpoint
condition $bpnum condition
(gdb) PASS: gdb.base/consecutive-step-over.exp: insn 1: set condition
break *0x400554
Breakpoint 3 at 0x400554: file ../../../src/gdb/testsuite/gdb.base/consecutive-step-over.c, line 24.
(gdb) PASS: gdb.base/consecutive-step-over.exp: insn 2: set breakpoint
condition $bpnum condition
(gdb) PASS: gdb.base/consecutive-step-over.exp: insn 2: set condition
break *0x40055e
Breakpoint 4 at 0x40055e: file ../../../src/gdb/testsuite/gdb.base/consecutive-step-over.c, line 25.
(gdb) PASS: gdb.base/consecutive-step-over.exp: insn 3: set breakpoint
condition $bpnum condition
(gdb) PASS: gdb.base/consecutive-step-over.exp: insn 3: set condition
break 27
Breakpoint 5 at 0x400568: file ../../../src/gdb/testsuite/gdb.base/consecutive-step-over.c, line 27.
(gdb) continue
Continuing.
../../src/gdb/infrun.c:5200: internal-error: switch_back_to_stepped_thread: Assertion `!tp->control.trap_expected' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
FAIL: gdb.base/consecutive-step-over.exp: continue to breakpoint: break here (GDB internal error)
The assertion fails, because the code is not expecting that the event
thread itself might need another step over. IOW, not expecting that
TP in:
tp = find_thread_needs_step_over (stepping_thread != NULL,
stepping_thread);
could be the event thread.
A small fix for this would be to clear the event thread's
trap_expected earlier, before asserting. But looking deeper, although
currently_stepping_or_nexting_callback's intention is finding the
thread that is doing a step/next, it also returns the thread that is
doing a step-over dance, with trap_expected set. If there ever was a
reason for that (it was I who added
currently_stepping_or_nexting_callback , but I can't recall why I put
trap_expected there in the first place), the only remaining reason
nowadays is to aid in implementing switch_back_to_stepped_thread's
assertion that is now triggering, by piggybacking on the walk over all
threads, thus avoiding a separate walk. This is quite obscure, and I
think we can do even better, by merging the walks that look for the
stepping thread, and the walk that looks for some thread that might
need a step over.
Tested on x86_64 Fedora 17, native and gdbserver, and also native on
top of my "software single-step on x86_64" series.
gdb/
2014-04-22 Pedro Alves <palves@redhat.com>
* infrun.c (schedlock_applies): New function, factored out from
find_thread_needs_step_over.
(find_thread_needs_step_over): Use it.
(switch_back_to_stepped_thread): Always clear trap_expected if the
step over is finished. Return early if scheduler locking applies.
Look for the stepping thread and a potential step-over thread with
a single loop.
(currently_stepping_or_nexting_callback): Delete.
2014-04-22 Pedro Alves <palves@redhat.com>
* gdb.base/consecutive-step-over.c: New file.
* gdb.base/consecutive-step-over.exp: New file.
This switches the gdb_continue_to_breakpoint routine to use
gdb_test_multiple instead of send_gdb/gdb_expect, so that an internal
error is detected immediately, instead of failing on timeout.
gdb/testsuite/
2014-04-22 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_continue_to_breakpoint): Use gdb_test_multiple
instead of send_gdb/gdb_expect.
In gdb.trace/tfile.exp, we execute binary to generate tracefile,
remote_exec target "$binfile"
however, this fails on bare metal target. This patch is to
handle binary execution failure by running binary in GDB.
The binary will do some io operation to generate tracefile, so
we need a check 'target_info exists gdb,nofileio'.
This patch is to check whether tracefile is generated. tfile.exp can
be skipped if generation is failed, while test_tfind_tfile in
mi-traceframe-changed.exp is skipped if generated failed. The rest of
the mi-traceframe-changed.exp can still be executed, because on some
bare metal targets, the remote stub supports tracepoint but doesn't
support fileio.
gdb/testsuite:
2014-04-22 Yao Qi <yao@codesourcery.com>
* lib/trace-support.exp (generate_tracefile): New procedure.
* gdb.trace/tfile.exp: Skip the test if generate_tracefile
return 0.
* gdb.trace/mi-traceframe-changed.exp: Invoke test_tfind_tfile
if generate_tracefile returns 1.
Functions ctf_fetch_registers and tfile_fetch_registers have some
duplicated code about guessing the PC in regcache. Sometimes, we
may change one function and forget to update the other one, like this
https://www.sourceware.org/ml/gdb-patches/2014-01/msg00292.html
This patch is to move the duplicated code into a new function
tracefile_fetch_registers, and let both ctf_fetch_registers and
tfile_fetch_registers call it.
gdb:
2014-04-22 Yao Qi <yao@codesourcery.com>
* tracefile-tfile.c (tfile_fetch_registers): Move the bottom to ...
* tracefile.c (tracefile_fetch_registers): ... it. New function.
* tracefile.h (tracefile_fetch_registers): Declare.
* ctf.c (ctf_fetch_registers): Remove the bottom. Call
tracefile_fetch_registers.
gdb/windows-nat.c (thread_rec): Don't display a warning when
SuspendThread fails with ERROR_ACCESS_DENIED. If SuspendThread
fails for any reason, set th->suspended to -1, so that we don't
try to resume such a thread. Also, don't return NULL in these
cases, to avoid completely ruin the session due to "PC register is
not available" error.
(do_windows_fetch_inferior_registers): Check errors in
GetThreadContext call.
(windows_continue): Accept an additional argument KILLED; if not
zero, ignore errors in the SetThreadContext call, since the
inferior was killed and is shutting down.
(windows_resume, get_windows_debug_event)
(windows_create_inferior, windows_mourn_inferior)
(windows_kill_inferior): All callers of windows_continue changed
to adjust to its new calling sequence.
We don't call post_create_inferior at the end of ctf_open. It is an
oversight in patch
[PATCH 2/2] Create inferior for ctf target.
https://sourceware.org/ml/gdb-patches/2014-01/msg01056.html
This patch is to call post_create_inferior at the end of ctf_open,
like the end of tfile_open.
gdb:
2014-04-19 Yao Qi <yao@codesourcery.com>
* ctf.c (ctf_open): Call post_create_inferior.
In ctf trace, for each 'R' block, we save it as a "register" event,
as defined below in metadata.
event {
name = "register";
id = 0;
fields := struct {
ascii contents[440];
};
}
Nowadays, we initialize trace_regblock_size by getting the length of
"contents" from a "register" event. However, 'R' block may not exist
in traceframe, as a result, "register" event doesn't exist in trace file
and trace_regblock_size isn't set.
This patch changes to get trace_regblock_size from metadata (or declaration)
which always exists.
gdb:
2014-04-19 Yao Qi <yao@codesourcery.com>
* ctf.c (handle_id): New static variable.
(ctf_open_dir): Get handle_id from bt_context_add_trace return
value. Get the declaration of event "register" and get length
of field "contents".
I find a gdb crash when gdb reads ctf trace. The crash is caused by passing
NULL to strcmp. This patch is to add null pointer check, as what we did
somewhere else in ctf.c.
gdb:
2014-04-19 Yao Qi <yao@codesourcery.com>
* ctf.c (ctf_xfer_partial): Check 'name' is NULL before strcmp.
This PR is about an assertion failure in GDB that can be triggered by
setting "backtrace limit" to a value that causes GDB to stop unwinding
after an inline frame. In this case, an assertion in
inline_frame_this_id will trigger:
/* We need a valid frame ID, so we need to be based on a valid
frame. (...). */
gdb_assert (frame_id_p (*this_id));
Looking at the function:
static void
inline_frame_this_id (struct frame_info *this_frame,
void **this_cache,
struct frame_id *this_id)
{
struct symbol *func;
/* In order to have a stable frame ID for a given inline function,
we must get the stack / special addresses from the underlying
real frame's this_id method. So we must call get_prev_frame.
Because we are inlined into some function, there must be previous
frames, so this is safe - as long as we're careful not to
create any cycles. */
*this_id = get_frame_id (get_prev_frame (this_frame));
we see we're computing the frame id for the inline frame. If this is
an inline frame, which is a virtual frame constructed based on debug
info, on top of a real stack frame, we should _always_ be able to find
where the frame was inlined into, as that ultimately just means
peeling off the virtual frames on top of the real stack frame. If
there ultimately was no prev (real) stack frame, then we wouldn't have
been able to construct the inline frame either, by design. That's
what the assertion catches.
So we have an inline frame, we should _always_ be able to compute its
ID, even if that means bypassing the user backtrace limits to get at
the real stack frame's info. The problem is that inline_frame_id
calls get_prev_frame, and that takes user backtrace limits into
account. Code that wants to bypass the limits calls get_prev_frame_1
instead.
Note how get_prev_frame_1 already skips all checks for inline frames:
/* If we are unwinding from an inline frame, all of the below tests
were already performed when we unwound from the next non-inline
frame. We must skip them, since we can not get THIS_FRAME's ID
until we have unwound all the way down to the previous non-inline
frame. */
if (get_frame_type (this_frame) == INLINE_FRAME)
return get_prev_frame_if_no_cycle (this_frame);
And note how the related frame_unwind_caller_id function also uses
get_prev_frame_1:
struct frame_id
frame_unwind_caller_id (struct frame_info *next_frame)
{
struct frame_info *this_frame;
/* Use get_prev_frame_1, and not get_prev_frame. The latter will truncate
the frame chain, leading to this function unintentionally
returning a null_frame_id (e.g., when a caller requests the frame
ID of "main()"s caller. */
next_frame = skip_artificial_frames (next_frame);
this_frame = get_prev_frame_1 (next_frame);
if (this_frame)
return get_frame_id (skip_artificial_frames (this_frame));
else
return null_frame_id;
}
get_prev_frame_1 is currently static in frame.c. As a _1 suffix is
not a good name for an extern function, I've renamed it.
Tested on x86-64 Fedora 17.
gdb/
2014-04-18 Pedro alves <palves@redhat.com>
Tom Tromey <tromey@redhat.com>
PR backtrace/15558
* frame.c (get_prev_frame_1): Rename to ...
(get_prev_frame_always): ... this, and make extern. Adjust.
(skip_artificial_frames): Use get_prev_frame_always.
(frame_unwind_caller_id, frame_pop, get_prev_frame)
(get_frame_unwind_stop_reason): Adjust to rename.
* frame.h (get_prev_frame_always): Declare.
* inline-frame.c: Include frame.h.
(inline_frame_this_id): Use get_prev_frame_always.
gdb/testsuite/
2014-04-18 Tom Tromey <palves@redhat.com>
Pedro alves <tromey@redhat.com>
PR backtrace/15558
* gdb.opt/inline-bt.exp: Test backtracing from an inline function
with a backtrace limit.
* gdb.python/py-frame-inline.exp: Test running to an inline
function with a backtrace limit, and printing the newest frame.
* gdb.python/py-frame-inline.c (main): Call f.
Use bfd_mach_o_get_base_address to extract load address.
gdb/
* solib-darwin.c (darwin_solib_create_inferior_hook): Simplify
code by using bfd_mach_o_get_base_address.
This patch enables use of DWARF unwinders for the SPU target.
In addition to appending the DWARF unwinders, we also need to install
a spu_dwarf_reg_to_regnum that maps the raw stack pointer register to
the cooked version (to avoid mismatches with gdbarch_sp_regnum).
This also causes confusion with the AX collect handling, so we also
install ax_pseudo_register routines to handle the cooked SP.
gdb/
2014-04-17 Ulrich Weigand <uweigand@de.ibm.com>
* spu-tdep.c: Include "dwarf2-frame.h" and "ax.h".
(spu_ax_pseudo_register_collect): New function.
(spu_ax_pseudo_register_push_stack): Likewise.
(spu_dwarf_reg_to_regnum): Likewise.
(spu_gdbarch_init): Install them. Append DWARF unwinders.
This patch fixes a problem that prevented use of the Dwarf unwinders on SPU,
because dwarf2-frame.c common code did not support the situation where the
stack and/or frame pointer is maintained in a *vector* register. This is
because read_addr_from_reg is hard-coded to assume that such pointers can
be read from registers via a simple get_frame_register / unpack_pointer
operation.
Now, there *is* a routine address_from_register that calls into the
appropriate tdep routines to handle pointer values in "weird" registers
like on SPU, but it turns out I cannot simply change dwarf2-frame.c to
use address_from_register. This is because address_from_register uses
value_from_register to create a (temporary) value, and that routine
at some point calls get_frame_id in order to set up that value's
VALUE_FRAME_ID entry.
However, the dwarf2-frame.c read_addr_from_reg routine will be called
during early unwinding (to unwind the frame's CFA), at which point the
frame's ID is not actually known yet! This would cause an assert.
On the other hand, we may notice that VALUE_FRAME_ID is only needed in the
value returned by value_from_register if that value is later used as an
lvalue. But this is obviously never done to the temporary value used in
address_from_register. So, if we could change address_from_register to
not call value_from_register but instead accept constructing a value
that doesn't have VALUE_FRAME_ID set, things should be fine.
To do that, we can change the value_from_register callback to accept
a FRAME_ID instead of a FRAME; the only existing uses of the FRAME
argument were either to extract its frame ID, or its gdbarch. (To
keep a way of getting at the latter, we also change the callback's
type from "f" to "m".) Together with the required follow-on changes
in the existing value_from_register implementations (including the
default one), this seems to fix the problem.
As another minor interface cleanup, I've removed the explicit TYPE
argument from address_from_register. This routine really always
uses a default pointer type, and in the new implementation it -to
some extent- relies on that fact, in that it will now no longer
handle types that require gdbarch_convert_register_p handling.
gdb:
2014-04-17 Ulrich Weigand <uweigand@de.ibm.com>
* gdbarch.sh (value_from_register): Make class "m" instead of "f".
Replace FRAME argument with FRAME_ID.
* gdbarch.c, gdbarch.h: Regenerate.
* findvar.c (default_value_from_register): Add GDBARCH argument;
replace FRAME by FRAME_ID. No longer call get_frame_id.
(value_from_register): Update call to gdbarch_value_from_register.
* value.h (default_value_from_register): Update prototype.
* s390-linux-tdep.c (s390_value_from_register): Update interface
and call to default_value_from_register.
* spu-tdep.c (spu_value_from_register): Likewise.
* findvar.c (address_from_register): Remove TYPE argument.
Do not call value_from_register; use gdbarch_value_from_register
with null_frame_id instead.
* value.h (address_from_register): Update prototype.
* dwarf2-frame.c (read_addr_from_reg): Use address_from_register.
* dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for
address_from_register interface change.
Hi,
We find gdb.base/printcmds.exp fails a lot on windows host, like this,
p ctable1[163]
$204 = 163 '£'
(gdb) FAIL: gdb.base/printcmds.exp: p ctable1[163]
however, on linux host,
p ctable1[163]
$205 = 163 '\243'
(gdb) PASS: gdb.base/printcmds.exp: p ctable1[163]
The printing related code is in valprint.c:print_wchar,
if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w)
&& w != LCST ('8')
&& w != LCST ('9'))))
{
gdb_wchar_t wchar = w;
if (w == gdb_btowc (quoter) || w == LCST ('\\'))
obstack_grow_wstr (output, LCST ("\\"));
obstack_grow (output, &wchar, sizeof (gdb_wchar_t));
}
else
{
// print W in hex or octal digits
}
When I debug gdb on different hosts, I find
on windows host, gdb_iswprint (iswprint) returns true if 'w' is 163.
However, on linux host, iswprint returns false if 'w' is 163. Looks
this difference is caused by the charset. On Linux host,
the target-charset is ANSI_X3.4-1968, while on windows host, the
target-charset is CP1252.
We can see how target-charset affects the output. On linux host,
(gdb) set target-charset ASCII
(gdb) p ctable1[163]
$1 = 163 '\243'
(gdb) set target-charset CP1252
(gdb) p ctable1[163]
$2 = 163 '£'
we can print the pound sign too, and it shows target-charset does
affect the output.
This patch is to set target-charset temporarily to ASCII for some
charset-sensitive tests. Tested on arm-none-eabi and
powerpc-linux-gnu on mingw32 host. More than one hundred fails are
fixed.
gdb/testsuite:
2014-04-17 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (with_target_charset): New proc.
* gdb.base/printcmds.exp (test_print_all_chars): Wrap tests with
with_target_charset.
(test_print_strings): Likewise.
(test_repeat_bytes): Likewise.
* gdb.base/setvar.exp: Set target-charset to ASCII temporarily
for some tests.
Nowadays, we have one page on "GDB Types" generated by doxygen, but types
and macros referenced in doc are not linked to their definitions. This
patch tweaks the comments a little to use doxygen syntax so that these
types and macros are linked their definitions.
Is it OK?
gdb:
2014-04-17 Yao Qi <yao@codesourcery.com>
* gdbtypes.h: Update comments to link to types and macros'
definitions.
Install some sanity checks that sibling DIE offsets are not beyond the
defined limits of the DWARF input buffer in read_partial_die and skip_one_die.
2014-03-20 Keith Seitz <keiths@redhat.com>
PR gdb/15827
* dwarf2read.c (skip_one_die): Check that all relative-offset
sibling DIEs fall within range of the current reader's buffer.
(read_partial_die): Likewise.
2014-03-20 Keith Seitz <keiths@redhat.com>
PR gdb/15827
* gdb.dwarf2/corrupt.c: New file.
* gdb.dwarf2/corrupt.exp: New file.
[forgot to commit/push these with previous push]
If lookup_symbol_file tries to locate a member variable with NULL name:
/* A simple lookup failed. Check if the symbol was defined in
a base class. */
cleanup = make_cleanup (null_cleanup, NULL);
/* Find the name of the class and the name of the method,
variable, etc. */
prefix_len = cp_entire_prefix_len (name);
/* If no prefix was found, search "this". */
if (prefix_len == 0)
{
struct type *type;
struct symbol *this;
this = lookup_language_this (language_def (language_cplus), block);
if (this == NULL)
{
do_cleanups (cleanup);
return NULL;
}
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
klass = xstrdup (TYPE_NAME (type));
nested = xstrdup (name);
}
TYPE_NAME (type) is NULL, so xstrdup (NULL) and boom!
This can happen, e.g., with clang++. See testsuite/gdb.cp/namelessclass.exp
or the bugzilla report.
This patch simply adds a fencepost against this case, allowing the caller
of lookup_symbol_file to search other blocks for the right symbol.
If lookup_symbol_file tries to locate a member variable with NULL name:
/* A simple lookup failed. Check if the symbol was defined in
a base class. */
cleanup = make_cleanup (null_cleanup, NULL);
/* Find the name of the class and the name of the method,
variable, etc. */
prefix_len = cp_entire_prefix_len (name);
/* If no prefix was found, search "this". */
if (prefix_len == 0)
{
struct type *type;
struct symbol *this;
this = lookup_language_this (language_def (language_cplus), block);
if (this == NULL)
{
do_cleanups (cleanup);
return NULL;
}
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
klass = xstrdup (TYPE_NAME (type));
nested = xstrdup (name);
}
TYPE_NAME (type) is NULL, so xstrdup (NULL) and boom!
This can happen, e.g., with clang++. See testsuite/gdb.cp/namelessclass.exp
or the bugzilla report.
This patch simply adds a fencepost against this case, allowing the caller
of lookup_symbol_file to search other blocks for the right symbol.
* lib/gdbserver-support.exp (gdbserver_default_get_remote_address):
Add comment.
(gdbserver_default_get_comm_port): New function.
(gdbserver_start): Check if board file provided
"gdbserver,get_comm_port" and use it if so.
* boards/native-stdio-gdbserver.exp (sockethost): Set to "".
(gdb,socketport): Set to "stdio".
(gdbserver,get_comm_port): Set to ${board}_get_comm_port.
(stdio_gdbserver_template): Delete.
(${board}_get_remote_address): Update.
(${board}_build_remote_cmd): Delete.
(${board}_get_comm_port): New function.
(${board}_spawn): Update.
* boards/remote-stdio-gdbserver.exp (${board}_build_remote_cmd):
Delete.
(${board}_get_remote_address): Update.
(${board}_get_comm_port): New function.
https://sourceware.org/ml/gdb-patches/2014-04/msg00210.html
Improve the regexp used in the memattr.exp test so allow for different
memory regions (.data / .bss) being laid out in different orders.
gdb/testsuite/ChangeLog:
* gdb.base/memattr.exp: Improve regexps to handle memory regions
appearing in any order.
This test uses a simple custom elf loader, implemented in
gdb.base/sym-file-loader.h|c. This loader doesn't have a dlclose-like
function today, but I'll need one. But, I found that the guts of the
loader are exposed too much to the client, making the interface more
complicated than necessary. It's simpler if the loader just exports a
few dlopen/dlsym -style functions. That's what this patch does.
Tested on x86_86 Fedora 17, native and gdbserver.
gdb/testsuite/
2014-04-15 Pedro Alves <palves@redhat.com>
* gdb.base/sym-file-loader.h: Move inclusion of <inttypes.h>,
<ansidecl.h>, <elf/common.h> and <elf/external.h> to
sym-file-loader.c.
(Elf_External_Phdr, Elf_External_Ehdr, Elf_External_Shdr)
(Elf_External_Sym, Elf_Addr, GET, GETADDR, struct segment): Move
to sym-file-loader.c.
(struct library): Forward declare.
(load_shlib, lookup_function): Change prototypes.
(find_shstrtab, find_strtab, find_shdr, find_symtab)
(translate_offset): Remove declarations.
(get_text_addr): New declaration.
* gdb.base/sym-file-loader.c: Move inclusion of <inttypes.h>,
<ansidecl.h>, <elf/common.h> and <elf/external.h> here from
sym-file-loader.h.
(Elf_External_Phdr, Elf_External_Ehdr, Elf_External_Shdr)
(Elf_External_Sym, Elf_Addr, GET, GETADDR, struct segment): Move
here from sym-file-loader.h.
(struct library): New structure.
(load_shlib, lookup_function): Change prototypes and adjust to
work with a struct library.
(find_shstrtab, find_strtab, find_shdr, find_symtab)
(translate_offset): Make static.
(get_text_addr): New function.
* gdb.base/sym-file-main.c (main): Adjust to new loader interface.
SELF_LINK, not SELK_LINK...
gdb/testsuite/
2014-04-15 Pedro Alves <palves@redhat.com>
* gdb.base/sym-file-loader.c: Fix typo. SELF_LINK, not SELK_LINK.
The main issue here is that this test passes the host's absolute path
to the library to load to the "dlopen"-like routine, which doesn't
work when either the target or the host are remote, unless a shared
filesystem has been set up.
Tests that dynamically load a library solve this by dlopen'ing by
basename, and setting rpath to $ORIGIN. See gdb_compile.
This test doesn't use dlopen, but instead uses its own simple elf
loader. The fix is to pass this loader the library basename, and
teach it to look up the library by basename in the executable's
directory as well, i.e., assuming/emulating RPATH=$ORIGIN.
Tested on x86_64 Fedora 17, native and gdbserver.
I looked around in the web to figure out Linux's /proc/self/exe
equivalents in other ELF OSs. I think I covered all relevant, but if
not, I think it'll be simple enough to add more. (Note the test is
skipped on non-ELF targets.)
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/testsuite/
2014-04-15 Pedro Alves <palves@redhat.com>
* gdb.base/sym-file-loader.c: Include <limits.h>.
(SELF_LINK): New define.
(get_origin): New function.
(load_shlib): Use it.
* gdb.base/sym-file.exp: Don't early return if the target is
remote. Use runto_main, and issue fail is that fails. Use
gdb_load_shlibs.
(shlib_name): Delete.
(lib_so, lib_syms, lib_dlopen): New globals. Use them throughout.
Remove regex characters from test message, and don't refer to
breakpoint numbers in test messages (subsequent patches will add more
breakpoints, changing these numbers). Result:
-PASS: gdb.base/sym-file.exp: add-symbol-file .*sym-file-lib\.so addr
+PASS: gdb.base/sym-file.exp: add-symbol-file sym-file-lib.so addr
-PASS: gdb.base/sym-file.exp: check if Breakpoint 2 is pending.
-PASS: gdb.base/sym-file.exp: check if Breakpoint 3 is pending.
+PASS: gdb.base/sym-file.exp: breakpoint at foo is pending
+PASS: gdb.base/sym-file.exp: breakpoint at bar is pending
gdb/testsuite/
2014-04-15 Pedro Alves <palves@redhat.com>
* gdb.base/sym-file.exp: Remove regex characters from test
message. Don't refer to breakpoint numbers in test messages.
PR c++/16253.
symbol_matches_domain was permitting searches for a VAR_DOMAIN
symbol to also match STRUCT_DOMAIN symbols for languages like C++
where STRUCT_DOMAIN symbols also define a typedef of the same name,
e.g., "struct foo {}" introduces a typedef of the name "foo".
Problems occur if there exists both a VAR_DOMAIN and STRUCT_DOMAIN
symbol of the same name. Then it is essentially a race between which
symbol is found first. The other symbol is obscurred.
[This is a relatively common idiom: enum e { ... } e;]
This patchset moves this "language defines a typedef" logic to
lookup_symbol[_in_language], looking first for a symbol in the given
domain and falling back to searching STRUCT_DOMAIN when/if appropriate.
2014-04-14 Keith Seitz <keiths@redhat.com>
PR c++/16253
* ada-lang.c (ada_symbol_matches_domain): Moved here and renamed
from symbol_matches_domain in symtab.c. All local callers
of symbol_matches_domain updated.
(standard_lookup): If DOMAIN is VAR_DOMAIN and no symbol is found,
search STRUCT_DOMAIN.
(ada_find_any_type_symbol): Do not search STRUCT_DOMAIN
independently. standard_lookup will do that automatically.
* cp-namespace.c (cp_lookup_symbol_nonlocal): Explain when/why
VAR_DOMAIN searches may return a STRUCT_DOMAIN match.
(cp_lookup_symbol_in_namespace): Likewise.
If no VAR_DOMAIN symbol is found, search STRUCT_DOMAIN.
(cp_lookup_symbol_exports): Explain when/why VAR_DOMAIN searches
may return a STRUCT_DOMAIN match.
(lookup_symbol_file): Search for the class name in STRUCT_DOMAIN.
* cp-support.c: Include language.h.
(inspect_type): Explicitly search STRUCT_DOMAIN before searching
VAR_DOMAIN.
* psymtab.c (match_partial_symbol): Compare the requested
domain with the symbol's domain directly.
(lookup_partial_symbol): Likewise.
* symtab.c (lookup_symbol_in_language): Explain when/why
VAR_DOMAIN searches may return a STRUCT_DOMAIN match.
If no VAR_DOMAIN symbol is found, search STRUCT_DOMAIN for
appropriate languages.
(symbol_matches_domain): Renamed `ada_symbol_matches_domain'
and moved to ada-lang.c
(lookup_block_symbol): Explain that this function only returns
symbol matching the requested DOMAIN.
Compare the requested domain with the symbol's domain directly.
(iterate_over_symbols): Compare the requested domain with the
symbol's domain directly.
* symtab.h (symbol_matches_domain): Remove.
2014-04-14 Keith Seitz <keiths@redhat.com>
PR c++/16253
* gdb.cp/var-tag.cc: New file.
* gdb.cp/var-tag.exp: New file.
* gdb.dwarf2/dw2-ada-ffffffff.exp: Set the language to C++.
* gdb.dwarf2/dw2-anon-mptr.exp: Likewise.
* gdb.dwarf2/dw2-double-set-die-type.exp: Likewise.
* gdb.dwarf2/dw2-inheritance.exp: Likewise.
This adds support for the C++11 "enum class" feature. This is
PR c++/15246.
I chose to use the existing TYPE_DECLARED_CLASS rather than introduce
a new type code. This seemed both simple and clear to me.
I made overloading support for the new enum types strict. This is how
it works in C++; and it didn't seem like an undue burden to keep this,
particularly because enum constants are printed symbolically by gdb.
Built and regtested on x86-64 Fedora 20.
2014-04-14 Tom Tromey <tromey@redhat.com>
PR c++/15246:
* c-exp.y (type_aggregate_p): New function.
(qualified_name, classify_inner_name): Use it.
* c-typeprint.c (c_type_print_base): Handle TYPE_DECLARED_CLASS
and TYPE_TARGET_TYPE of an enum type.
* dwarf2read.c (read_enumeration_type): Set TYPE_DECLARED_CLASS on
an enum type.
(determine_prefix) <case DW_TAG_enumeration_type>: New case;
handle TYPE_DECLARED_CLASS.
* gdbtypes.c (rank_one_type): Handle TYPE_DECLARED_CLASS on enum
types.
* gdbtypes.h (TYPE_DECLARED_CLASS): Update comment.
* valops.c (enum_constant_from_type): New function.
(value_aggregate_elt): Use it.
* cp-namespace.c (cp_lookup_nested_symbol): Handle
TYPE_CODE_ENUM.
2014-04-14 Tom Tromey <tromey@redhat.com>
* gdb.cp/classes.exp (test_enums): Handle underlying type.
* gdb.dwarf2/enum-type.exp: Add test for enum with underlying
type.
* gdb.cp/enum-class.exp: New file.
* gdb.cp/enum-class.cc: New file.
While working on another patch I realized that value_aggregate_elt's
"name" parameter ought to be const. This patch implements this.
2014-04-14 Tom Tromey <tromey@redhat.com>
* valops.c (value_aggregate_elt, value_struct_elt_for_reference)
(value_namespace_elt, value_maybe_namespace_elt): Make "name"
const.
* value.h (value_aggregate_elt): Update.
DWARF allows an enumeration type to have a DW_AT_type. GDB doesn't
recognize this, but there is a patch to change GCC to emit it, and a
DWARF proposal to further allow an enum type with a DW_AT_type to omit
the DW_AT_byte_size. This patch changes gdb to implement this.
Built and regtested on x86-64 Fedora 20.
2014-04-14 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (read_enumeration_type): Handle DW_AT_type.
2014-04-14 Tom Tromey <tromey@redhat.com>
* gdb.dwarf2/enum-type.exp: New file.
The dwarf attribute DW_AT_count specifies the elements of a subrange.
This test covers subranges with present count but absent upper bound
attribute, both with static and dynamic attribute values.
testsuite/ChangeLog:
* gdb.dwarf2/count.exp: New file.
The c99 standard in "6.5.3.4 The sizeof operator" states:
If the type of the operand is a variable length array type, the operand
is evaluated;[...]
This patch mirrors the following c99 semantic in gdb:
1| int vla[n][m];
2| int i = 1;
3| sizeof(vla[i++][0]); // No sideffect
4| assert (i == 1);
5| sizeof(vla[i++]); // With sideffect
6| assert (i == 2);
Note: ptype/whatis still do not allow any sideeffects.
This patch was motivated by:
https://sourceware.org/ml/gdb-patches/2014-01/msg00732.html
gdb/ChangeLog:
* eval.c (evaluate_subexp_for_sizeof): Add enum noside argument.
(evaluate_subexp_standard): Pass noside argument.
(evaluate_subexp_for_sizeof) <BINOP_SUBSCRIPT>: Handle subscript case
if noside equals EVAL_NORMAL. If the subscript yields a vla type
re-evaluate subscript operation with EVAL_NORMAL to enable sideffects.
* gdbtypes.c (resolve_dynamic_bounds): Mark bound as evaluated.
* gdbtypes.h (enum range_flags): Add RANGE_EVALUATED case.
testsuite/ChangeLog:
* gdb.base/vla-sideeffect.c: New file.
* gdb.base/vla-sideeffect.exp: New file.
A variable location might be a constant value and therefore no inferior memory
access is needed to read the content. In this case try to resolve the type
bounds.
gdb/ChangeLog:
* findvar.c (default_read_var_value): Resolve dynamic bounds if location
points to a constant blob.
This patch adds support for DW_AT_count as requested in the code review:
https://sourceware.org/ml/gdb-patches/2013-11/msg00200.html
gdb/ChangeLog:
* dwarf2read.c (read_subrange_type): Convert DW_AT_count to a dynamic
property and store it as the high bound and flag the range accordingly.
* gdbtypes.c (resolve_dynamic_bounds): If range is flagged as
RANGE_UPPER_BOUND_IS_COUNT assign low + high - 1 as the new high bound.
* gdbtypes.h (enum range_flags): New enum.
(struct range_bounds): Add flags member.
1| void foo (size_t n) {
2| int vla[n];
3| }
Given the following expression
(gdb) ptype &vla
Gdb evaluates the expression with EVAL_AVOID_SIDE_EFFECTS and thus
does not resolve the bounds information and misinterprets the high
bound as a constant. The current output is:
type = int (*)[1289346]
this patch deals with this case and prints:
type = int (*)[variable length]
instead.
gdb/ChangeLog:
* c-typeprint.c (c_type_print_varspec_suffix): Added
check for not yet resolved high bound. If unresolved, print
"variable length" string to the console instead of random
length.
Constructing a value based on a type and address might change the type
of the newly constructed value. Thus re-fetch type via value_type to ensure
we have the correct type at hand.
gdb/ChangeLog
* ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value.
(ada_template_to_fixed_record_type_1): Likewise.
(ada_to_fixed_type_1): Likewise.
* cp-valprint.c (cp_print_value_fields_rtti): Likewise.
(cp_print_value): Likewise.
* d-valprint.c (dynamic_array_type): Likewise.
* findvar.c (address_of_variable): Likewise.
* jv-valprint.c (java_value_print): Likewise.
* valops.c (value_ind): Likewise.
* value.c (coerce_ref): Likewise.
This patch enables the sizeof operator for indirections:
1| void foo (size_t n) {
2| int vla[n];
3| int *vla_ptr = &vla;
4| }
(gdb) p sizeof(*vla_ptr)
yields sizeof (size_t) * n.
gdb/ChangeLog:
* eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
value and retrieve the dynamic type size.
In C99 the sizeof operator computes the size of a variable length array
at runtime (6.5.3.4 The sizeof operator). This patch reflects the semantic
change in the debugger.
We now are able to get the size of a vla:
1| void foo (size_t n) {
2| int vla[n];
3| }
(gdb) p sizeof(vla)
yields N * sizeof(int).
gdb/ChangeLog:
* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
passed to sizeof is dynamic evaluate the argument to compute the length.
The dwarf standard allow certain attributes to be expressed as dwarf
expressions rather than constants. For instance upper-/lowerbound attributes.
In case of a c99 variable length array the upperbound is a dynamic attribute.
With this change c99 vla behave the same as with static arrays.
1| void foo (size_t n) {
2| int ary[n];
3| memset(ary, 0, sizeof(ary));
4| }
(gdb) print ary
$1 = {0 <repeats 42 times>}
gdb/ChangeLog:
* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
(dwarf2_evaluate_property): New function.
* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
* dwarf2read.c (attr_to_dynamic_prop): New function.
(read_subrange_type): Use attr_to_dynamic_prop to read high bound
attribute.
* gdbtypes.c: Include dwarf2loc.h.
(is_dynamic_type): New function.
(resolve_dynamic_type): New function.
(resolve_dynamic_bounds): New function.
(get_type_length): New function.
(check_typedef): Use get_type_length to compute type length.
* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
(TYPE_LOW_BOUND_KIND): New macro.
(is_dynamic_type): New function prototype.
* value.c (value_from_contents_and_address): Call resolve_dynamic_type
to resolve dynamic properties of the type. Update comment.
* valops.c (get_value_at, value_at, value_at_lazy): Update comment.
Clang defaults this warning to an error, breaking the build & causing
these tests not to run.
gdb/testsuite/
* gdb.mi/non-stop.c: Add return value for non-void function return
statement.
* gdb.threads/staticthreads.c: Ditto.
* guile/scm-value.c (gdbscm_value_dynamic_type): Use coerce_ref to
dereference TYPE_CODE_REF values.
testsuite/
* gdb.guile/scm-value.c: Improve test case.
* gdb.guile/scm-value.exp: Add new test.
This reverts the following patch series, as they cause some regresssions.
commit 37c1ab67a3
type: add c99 variable length array support
gdb/
* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
(dwarf2_evaluate_property): New function.
* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
* dwarf2read.c (attr_to_dynamic_prop): New function.
(read_subrange_type): Use attr_to_dynamic_prop to read high bound
attribute.
* gdbtypes.c: Include dwarf2loc.h.
(is_dynamic_type): New function.
(resolve_dynamic_type): New function.
(resolve_dynamic_bounds): New function.
(get_type_length): New function.
(check_typedef): Use get_type_length to compute type length.
* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
(TYPE_LOW_BOUND_KIND): New macro.
(is_dynamic_type): New function prototype.
* value.c (value_from_contents_and_address): Call resolve_dynamic_type
to resolve dynamic properties of the type. Update comment.
* valops.c (get_value_at, value_at, value_at_lazy): Update comment.
commit 26cb189f8b
vla: enable sizeof operator to work with variable length arrays
gdb/
* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
passed to sizeof is dynamic evaluate the argument to compute the length.
commit 04b19544ef
vla: enable sizeof operator for indirection
gdb/
* eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
value and retrieve the dynamic type size.
commit bcd629a44f
vla: update type from newly created value
gdb/
* ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value.
(ada_template_to_fixed_record_type_1): Likewise.
(ada_to_fixed_type_1): Likewise.
* cp-valprint.c (cp_print_value_fields_rtti): Likewise.
(cp_print_value): Likewise.
* d-valprint.c (dynamic_array_type): Likewise.
* eval.c (evaluate_subexp_with_coercion): Likewise.
* findvar.c (address_of_variable): Likewise.
* jv-valprint.c (java_value_print): Likewise.
* valops.c (value_ind): Likewise.
* value.c (coerce_ref): Likewise.
commit b86138fb04
vla: print "variable length" for unresolved dynamic bounds
gdb/
* c-typeprint.c (c_type_print_varspec_suffix): Added
check for not yet resolved high bound. If unresolved, print
"variable length" string to the console instead of random
length.
commit e1969afbd4
vla: support for DW_AT_count
gdb/
* dwarf2read.c (read_subrange_type): Convert DW_AT_count to a dynamic
property and store it as the high bound and flag the range accordingly.
* gdbtypes.c (resolve_dynamic_bounds): If range is flagged as
RANGE_UPPER_BOUND_IS_COUNT assign low + high - 1 as the new high bound.
* gdbtypes.h (enum range_flags): New enum.
(struct range_bounds): Add flags member.
commit 92b09522dc
vla: resolve dynamic bounds if value contents is a constant byte-sequence
gdb/
* findvar.c (default_read_var_value): Resolve dynamic bounds if location
points to a constant blob.
commit 3bce82377f
vla: evaluate operand of sizeof if its type is a vla
gdb/
* eval.c (evaluate_subexp_for_sizeof): Add enum noside argument.
(evaluate_subexp_standard): Pass noside argument.
(evaluate_subexp_for_sizeof) <BINOP_SUBSCRIPT>: Handle subscript case
if noside equals EVAL_NORMAL. If the subscript yields a vla type
re-evaluate subscript operation with EVAL_NORMAL to enable sideffects.
* gdbtypes.c (resolve_dynamic_bounds): Mark bound as evaluated.
* gdbtypes.h (enum range_flags): Add RANGE_EVALUATED case.
gdb/testsuite
* gdb.base/vla-sideeffect.c: New file.
* gdb.base/vla-sideeffect.exp: New file.
commit 504f34326e
test: cover subranges with present DW_AT_count attribute
gdb/testsuite/
* gdb.dwarf2/count.exp: New file.
commit 1a237e0ee5
test: multi-dimensional c99 vla.
gdb/testsuite/
* gdb.base/vla-multi.c: New file.
* gdb.base/vla-multi.exp: New file.
commit 024e13b46f
test: evaluate pointers to C99 vla correctly.
gdb/testsuite/
* gdb.base/vla-ptr.c: New file.
* gdb.base/vla-ptr.exp: New file.
commit c8655f75e2
test: basic c99 vla tests for C primitives
gdb/testsuite/
* gdb.base/vla-datatypes.c: New file.
* gdb.base/vla-datatypes.exp: New file.
commit 58a84dcf29
test: add mi vla test
gdb/testsuite/
* gdb.mi/mi-vla-c99.exp: New file.
* gdb.mi/vla.c: New file.
The dwarf attribute DW_AT_count specifies the elements of a subrange.
This test covers subranges with present count but absent upper bound
attribute, both with static and dynamic attribute values.
testsuite:
* gdb.dwarf2/count.exp: New file.
The c99 standard in "6.5.3.4 The sizeof operator" states:
If the type of the operand is a variable length array type, the operand
is evaluated;[...]
This patch mirrors the following c99 semantic in gdb:
1| int vla[n][m];
2| int i = 1;
3| sizeof(vla[i++][0]); // No sideffect
4| assert (i == 1);
5| sizeof(vla[i++]); // With sideffect
6| assert (i == 2);
Note: ptype/whatsis still do not allow any sideeffects.
This patch was motivated by:
https://sourceware.org/ml/gdb-patches/2014-01/msg00732.html
* eval.c (evaluate_subexp_for_sizeof): Add enum noside argument.
(evaluate_subexp_standard): Pass noside argument.
(evaluate_subexp_for_sizeof) <BINOP_SUBSCRIPT>: Handle subscript case
if noside equals EVAL_NORMAL. If the subscript yields a vla type
re-evaluate subscript operation with EVAL_NORMAL to enable sideffects.
* gdbtypes.c (resolve_dynamic_bounds): Mark bound as evaluated.
* gdbtypes.h (enum range_flags): Add RANGE_EVALUATED case.
testsuite/gdb.base/
* vla-sideeffect.c: New file.
* vla-sideeffect.exp: New file.
A variable location might be a constant value and therefore no inferior memory
access is needed to read the content. In this case try to resolve the type
bounds.
* findvar.c (default_read_var_value): Resolve dynamic bounds if location
points to a constant blob.
This patch adds support for DW_AT_count as requested in the code review:
https://sourceware.org/ml/gdb-patches/2013-11/msg00200.html
* dwarf2read.c (read_subrange_type): Convert DW_AT_count to a dynamic
property and store it as the high bound and flag the range accordingly.
* gdbtypes.c (resolve_dynamic_bounds): If range is flagged as
RANGE_UPPER_BOUND_IS_COUNT assign low + high - 1 as the new high bound.
* gdbtypes.h (enum range_flags): New enum.
(struct range_bounds): Add flags member.
1| void foo (size_t n) {
2| int vla[n];
3| }
Given the following expression
(gdb) ptype &vla
Gdb evaluates the expression with EVAL_AVOID_SIDE_EFFECTS and thus
does not resolve the bounds information and misinterprets the high
bound as a constant. The current output is:
type = int (*)[1289346]
this patch deals with this case and prints:
type = int (*)[variable length]
instead.
* c-typeprint.c (c_type_print_varspec_suffix): Added
check for not yet resolved high bound. If unresolved, print
"variable length" string to the console instead of random
length.
Constructing a value based on a type and address might change the type
of the newly constructed value. Thus re-fetch type via value_type to ensure
we have the correct type at hand.
* ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value.
(ada_template_to_fixed_record_type_1): Likewise.
(ada_to_fixed_type_1): Likewise.
* cp-valprint.c (cp_print_value_fields_rtti): Likewise.
(cp_print_value): Likewise.
* d-valprint.c (dynamic_array_type): Likewise.
* eval.c (evaluate_subexp_with_coercion): Likewise.
* findvar.c (address_of_variable): Likewise.
* jv-valprint.c (java_value_print): Likewise.
* valops.c (value_ind): Likewise.
* value.c (coerce_ref): Likewise.
This patch enables the sizeof operator for indirections:
1| void foo (size_t n) {
2| int vla[n];
3| int *vla_ptr = &vla;
4| }
(gdb) p sizeof(*vla_ptr)
yields sizeof (size_t) * n.
* eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
value and retrieve the dynamic type size.
In C99 the sizeof operator computes the size of a variable length array
at runtime (6.5.3.4 The sizeof operator). This patch reflects the semantic
change in the debugger.
We now are able to get the size of a vla:
1| void foo (size_t n) {
2| int vla[n];
3| }
(gdb) p sizeof(vla)
yields N * sizeof(int).
* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
passed to sizeof is dynamic evaluate the argument to compute the length.
The dwarf standard allow certain attributes to be expressed as dwarf
expressions rather than constants. For instance upper-/lowerbound attributes.
In case of a c99 variable length array the upperbound is a dynamic attribute.
With this change c99 vla behave the same as with static arrays.
1| void foo (size_t n) {
2| int ary[n];
3| memset(ary, 0, sizeof(ary));
4| }
(gdb) print ary
$1 = {0 <repeats 42 times>}
* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
(dwarf2_evaluate_property): New function.
* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
* dwarf2read.c (attr_to_dynamic_prop): New function.
(read_subrange_type): Use attr_to_dynamic_prop to read high bound
attribute.
* gdbtypes.c: Include dwarf2loc.h.
(is_dynamic_type): New function.
(resolve_dynamic_type): New function.
(resolve_dynamic_bounds): New function.
(get_type_length): New function.
(check_typedef): Use get_type_length to compute type length.
* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
(TYPE_LOW_BOUND_KIND): New macro.
(is_dynamic_type): New function prototype.
* value.c (value_from_contents_and_address): Call resolve_dynamic_type
to resolve dynamic properties of the type. Update comment.
* valops.c (get_value_at, value_at, value_at_lazy): Update comment.
The rational behind this patch is to get started to implement the feature
described in dwarf4 standard (2.19) Static and Dynamic Values of Attributes.
It adds new BOUND_PROP to store either a constant, exprloc, or reference to
describe an upper-/lower bound of a subrange. Other than that no new features
are introduced.
* dwarf2read.c (read_subrange_type): Use struct bound_prop for
declaring high/low bounds and change uses accordingly. Call
create_range_type instead of create_static_range_type.
* gdbtypes.c (create_range_type): New function.
(create_range_type): Convert bounds into struct bound_prop and pass
them to create_range_type.
* gdbtypes.h (struct bound_prop): New struct.
(create_range_type): New function prototype.
(struct range_bounds): Use struct bound_prop instead of LONGEST for
high/low bounds. Remove low_undefined/high_undefined and adapt all uses.
(TYPE_LOW_BOUND,TYPE_HIGH_BOUND): Adapt macros to refer to the static
part of the bound.
* parse.c (follow_types): Set high bound kind to BOUND_UNDEFINED.
* gdbtypes.c (create_static_range_type): Renamed from create_range_type.
* gdbtypes.h (create_static_range_type): Renamed from create_range_type.
* ada-lang.c: All uses of create_range_type updated.
* coffread.c: All uses of create_range_type updated.
* dwarf2read.c: All uses of create_range_type updated.
* f-exp.y: All uses of create_range_type updated.
* m2-valprint.c: All uses of create_range_type updated.
* mdebugread.c: All uses of create_range_type updated.
* stabsread.c: All uses of create_range_type updated.
* valops.c: All uses of create_range_type updated.
* valprint.c: All uses of create_range_type updated.
Doug told me that there are some regressions in gdb.base/completion.exp.
They are caused by my recent change, and can be reproduced via:
$ make check-parallel TESTS=gdb.base/completion.exp
FAIL: gdb.base/completion.exp: complete target core ./gdb.base/completion
FAIL: gdb.base/completion.exp: complete target tfile ./gdb.base/completion
FAIL: gdb.base/completion.exp: complete target exec ./gdb.base/completion
Current tests assume that gdb.base/completion exists but that is wrong
in a parallel run, because binary file and object files are placed
in outputs/gdb.base/completion/.
This patch is to check file exists on two candidate directories,
"gdb.base" and "outputs/gdb.base/completion/", and run tests with files
existed in either of them.
gdb/testsuite:
2014-04-11 Yao Qi <yao@codesourcery.com>
* gdb.base/completion.exp: Check file exists before running tests
on file completion.
While trying to fix hbreak2.exp against GDBserver I noticed this...
(gdb) hbreak main if 1
Sending packet: $m400580,40#2e...Packet received: e8d2ffffff5dc3554889e54883ec10c745fc00000000eb0eb800000000e8c1ffffff8345fc01817dfce70300007ee9b800000000c9c3662e0f1f840000000000
Sending packet: $m40058f,1#31...Packet received: c7
Hardware assisted breakpoint 1 at 0x40058f: file ../../../src/gdb/testsuite/gdb.base/break-idempotent.c, line 46.
Sending packet: $Z1,40058f,1;X3,220127#9b...
*hangs forever*
The issue is that nothing advances the packet pointer if
add_breakpoint_condition either fails to parse the agent expression,
or fails to find the breakpoint, resulting in an infinite loop in
process_point_options. The latter case should really be fixed by
GDBserver tracking GDB Z1 breakpoints in its breakpoint structures
like Z0 breakpoints are, but the latter case still needs handling.
add_breakpoint_commands has the same issue, though at present I don't
know any way to trigger it other than sending a manually cooked
packet.
Unbelievably, it doesn't look like we have any test that tries setting
a conditional hardware breakpoint. Looking at cond-eval-mode.exp, it
looks like the file was meant to actually test something, but it's
mostly empty today. This patch adds tests that tries all sorts of
conditional breakpoints and watchpoints. The test hangs/fails without
the GDBserver fix.
Tested on x86_64 Fedora 17.
gdb/gdbserver/
2014-04-10 Pedro Alves <palves@redhat.com>
* mem-break.c (add_breakpoint_condition, add_breakpoint_commands):
Check if the condition or command is NULL before checking if the
breakpoint is known. On success, return true.
* mem-break.h (add_breakpoint_condition): Document return.
(add_breakpoint_commands): Add describing comment.
* server.c (skip_to_semicolon): New function.
(process_point_options): Use it.
gdb/testsuite/
2014-04-10 Pedro Alves <palves@redhat.com>
* gdb.base/cond-eval-mode.c: New file.
* gdb.base/cond-eval-mode.exp: Use standard_testfile. Adjust
prepare_for_testing to build the new file. Check result of
runto_main.
(test_break, test_watch): New procedures.
(top level): Use them.
Breakpoints are supposed to be transparent to memory accesses. For
all kinds of breakpoints breakpoint_xfer_memory hides the breakpoint
instructions. However, sss breakpoints aren't tracked like all other
breakpoints, and nothing is taking care of hiding them from memory
reads.
Say, as is, a background step + disassemble will see breakpoints
instructions on software step targets. E.g., stepping over this line:
while (1);
with s&
and then "disassemble" would show sss breakpoints.
Actually, that's still not be possible to see today, because:
- in native Linux, you can't read memory while the program
is running.
- with Linux gdbserver, you can, but in the all-stop RSP you
can't talk to the server while the program is running...
- and with non-stop, on software step targets, we presently
force the use of displaced-stepping for all single-steps,
so no single-step breakpoints are used...
I've been working towards making non-stop not force displaced stepping
on sss targets, and I noticed the issue then. With that, I indeed see
this:
(gdb) set remote Z-packet off
(gdb) s&
(gdb) disassemble main
Dump of assembler code for function main:
0x000000000040049c <+0>: push %rbp
0x000000000040049d <+1>: mov %rsp,%rbp
0x00000000004004a0 <+4>: int3
0x00000000004004a1 <+5>: (bad)
End of assembler dump.
Instead of the correct:
(gdb) disassemble main
Dump of assembler code for function main:
0x000000000040049c <+0>: push %rbp
0x000000000040049d <+1>: mov %rsp,%rbp
0x00000000004004a0 <+4>: jmp 0x4004a0 <main+4>
This is actually one thing that my v1 of the recent "fix a bunch of
run control bugs" series was fixing, because it made sss breakpoints
be regular breakpoints in the breakpoint chain. But dropped it in the
version that landed in the tree, due to some problems.
So instead of making sss breakpoints regular breakpoints, go with a
simpler fix (at least for now) -- make breakpoint_xfer_memory take
software single-step breakpoints into account. After the patch, I get
the correct disassemble output.
Tested on x86_64 Fedora 17, and also on top of my "use software
single-step on x86" series.
Also fixes the issue pointed out by Yao at
https://sourceware.org/ml/gdb-patches/2014-04/msg00045.html, where the
prologue analysis/frame sniffing manages to see software step
breakpoint instructions.
gdb/
2014-04-10 Pedro Alves <palves@redhat.com>
* breakpoint.c (single_step_breakpoints)
(single_step_gdbarch): Move up in the file.
(one_breakpoint_xfer_memory): New function, factored out from ...
(breakpoint_xfer_memory): ... here. Also process single-step
breakpoints.
sh-linux-gnu-gcc (...) src/gdb/gdbserver/linux-low.c
.../src/gdb/gdbserver/linux-low.c: In function 'linux_read_loadmap':
.../src/gdb/gdbserver/linux-low.c:5284:13: error: 'struct lwp_info' has no member named 'entry'
make[1]: *** [linux-low.o] Error 1
gdb/gdbserver/
2014-04-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_read_loadmap): Pass current_inferior directly
to lwpid_of.
Due to a thinko, a message could be not understood and ignored. The result
was a dead-lock (gdb is waiting for an event that never happen). The port
of the thread was deallocated before new threads are discovered. As a
consequence, the origin of the message was unknown (instead of being
linked to the newly created thread).
gdb/
* darwin-nat.c (darwin_check_new_threads): Fix port leak, add
comments.
(darwin_decode_exception_message): Free port only after use.
* avr-tdep.c (struct gdbarch_tdep): Mention avrxmega in the comment.
(avr_gdbarch_init): Add xmega architectures given by bfd_architecture
when setting the size of call_length.
On mingw host, we have seen two fails as below,
p int1dim[0]^V@2
Invalid character '^V' in expression.
(gdb) FAIL: gdb.base/printcmds.exp: p int1dim[0]@2
p int1dim[0]^V@2^V@3
Invalid character '^V' in expression.
(gdb) FAIL: gdb.base/printcmds.exp: p int1dim[0]@2@3
In the test, the comment says "# Send \026@ instead of just @ in case
the kill character is @". Historically, kill character was @, and
Ctrl-V (\026) is to escape the next character. However, we don't have
to do so on mingw. This patch is to disable ctrl-v usage on mingw
hots. With this patch applied, it becomes:
p int1dim[0]@2
$607 = {0, 1}
(gdb) PASS: gdb.base/printcmds.exp: p int1dim[0]@2
p int1dim[0]@2@3
$608 = {{0, 1}, {2, 3}, {4, 5}}
Note that this patch is picked from Pierre's submission,
[RFC 6/6] Fix remaining failures in gdb.base/printcmds.exp for mingw hosts.
https://www.sourceware.org/ml/gdb-patches/2013-09/msg00943.html
gdb/testsuite:
2014-04-08 Pierre Muller <muller@sourceware.org>
* gdb.base/printcmds.exp (test_artificial_arrays): Disable
Ctrl-V use for mingw hosts.
gdb.Value.dynamic_type is supposed to work for reference and pointer
values. However, the value object in the function 'valpy_get_dynamic_type'
was being dereferenced using 'value_ind' irrespective of the value type
being TYPE_CODE_PTR or TYPE_CODE_REF. This patch fixes that to use
'coerce_ref' for TYPE_CODE_REF values.
ChangeLog:
* python/py-value.c (valpy_get_dynamic_type): Use coerce_ref to
dereference TYPE_CODE_REF values.
testsuite/
* gdb.python/py-value.c: Improve test case.
* gdb.python/py-value.exp: Add new test.
Hi,
On windows host, we see the following ERROR,
(gdb) PASS: gdb.base/setshow.exp: set history filename ~/foobar.baz
ERROR OCCURED: couldn't compile regular expression pattern: invalid escape \ seq
uence
while executing
"expect -nobrace -i exp13 -timeout 10 -re {.*A problem internal to GDB has been
detected} {
fail "$message (GDB internal error)"
gdb_internal..."
invoked from within
"expect {
-i exp13 -timeout 10
-re ".*A problem internal to GDB has been detected" {
fail "$message (GDB internal error)"
gdb_internal_erro..."
("uplevel" body line 1)
invoked from within
"uplevel $body" REGEXP REG_EESCAPE {invalid escape \ sequence} couldn't compile
regular expression pattern: invalid escape \ sequenceERROR: Process no longer ex
ists
which leads to
UNRESOLVED: gdb.base/setshow.exp: show history filename (~/foobar.baz)
and this error is thrown from this test below:
gdb_test "show history filename" \
"The filename in which to record the command history is \"$HOME/foobar.baz\"..*" \
"show history filename (~/foobar.baz)"
HOME is a windows path, like C:\foo\bar. When it is used in gdb_test to match
output, the error is thrown because backslash is a special character in
regular expression. This patch is to escape backslash to fix this
error by using string_to_regexp.
gdb/testsuite:
2014-04-03 Yao Qi <yao@codesourcery.com>
* gdb.base/setshow.exp: Invoke string_to_regexp to HOME and PWD.
When a VDSO gets large enough that it doesn't entirely fit in one page,
but not so large that the part described by the program header exceeds
one page, then gdb/BFD doesn't read the section headers and symbol
table information. This patch cures that by passing the size of the
vdso to BFD, and fixes a number of other issues in the BFD code.
bfd/
* elfcode.h (bfd_from_remote_memory): Add "size" parameter.
Consolidate code handling possible section headers past end of
segment. Don't use p_align for page size guess, instead use
minpagesize. Take note of ld.so clearing section headers when
p_memsz > p_filesz. Handle file header specifying no section
headers. Handle zero p_align throughout. Default loadbase to
zero. Add comments. Rename contents_size to high_offset, and
make it a bfd_vma. Delete unnecessary bfd_set_error calls.
* bfd-in.h (bfd_elf_bfd_from_remote_memory): Update prototpe.
* elf-bfd.h (struct elf_backend_data <elf_backend_from_remote_memory>):
Likewise.
(_bfd_elf32_bfd_from_remote_memory): Likewise.
(_bfd_elf64_bfd_from_remote_memory): Likewise.
* elf.c (bfd_elf_bfd_from_remote_memory): Adjust.
* bfd-in2.h: Regnerate.
gdb/
* symfile-mem.c (symbol_file_add_from_memory): Add size parameter.
Pass to bfd_elf_bfd_from_remote_memory. Adjust all callers.
(struct symbol_file_add_from_memory_args): Add size field.
(find_vdso_size): New function.
(add_vsyscall_page): Attempt to find vdso size.
it is possible that gdb gets mach exceptions from an unknown inferior. This
happens when an inferior creates a child and that child gets a signal.
So instead of reporting messages with unknown origins, simply reply to these
notifications. The kernel will then post the unix signal.
gdb/
* darwin-nat.c (darwin_encode_reply): Add prototype.
(darwin_decode_exception_message): Reply to unknown inferiors.
(darwin_decode_message): Handle message by id. Ignore message
to unknown inferior.
(darwin_wait): Discard unknown messages, add debug trace.
The current ppc64 single step over atomic sequence testcase is written
in C and breaks with some versions of gcc. Convert the test to
assembly and use stepi to step through it.
gdb/testsuite/
2014-04-01 Anton Blanchard <anton@samba.org>
* gdb.arch/ppc64-atomic-inst.c: Remove.
* gdb.arch/ppc64-atomic-inst.S: New file.
* gdb.arch/ppc64-atomic-inst.exp: Adapt for asm based testcase.
* NEWS: Mention it.
* solib.c (solib_read_symbols): Only print symbol loading messages
if requested.
(solib_add): If symbol loading is in "brief" mode, notify user
symbols are being loaded.
(reload_shared_libraries_1): Ditto.
* symfile.c (print_symbol_loading_off): New static global.
(print_symbol_loading_brief): New static global.
(print_symbol_loading_full): New static global.
(print_symbol_loading_enums): New static global.
(print_symbol_loading): New static global.
(print_symbol_loading_p): New function.
(symbol_file_add_with_addrs): Only print symbol loading messages
if requested.
(_initialize_symfile): Register "print symbol-loading" set/show
command.
* symfile.h (print_symbol_loading_p): Declare.
doc/
* gdb.texinfo (Symbols): Document set/show print symbol-loading.
testsuite/
* gdb.base/print-symbol-loading-lib.c: New file.
* gdb.base/print-symbol-loading-main.c: New file.
* gdb.base/print-symbol-loading.exp: New file.
Hi,
I find two fails in source-dir.exp on mingw32 host.
(gdb) directory /nOtExStInG/a /nOtExStInG/b /nOtExStInG/c^M
Warning: /nOtExStInG/a: No such file or directory.^M
Warning: /nOtExStInG/b: No such file or directory.^M
Warning: /nOtExStInG/c: No such file or directory.^M
Source directories searched: /nOtExStInG/a;/nOtExStInG/b;/nOtExStInG/c;$cdir;$cwd^M
(gdb) FAIL: gdb.base/source-dir.exp: directory /nOtExStInG/a /nOtExStInG/b /nOtExStInG/c
directory /nOtExStInG/b /nOtExStInG/d /nOtExStInG/c^M
Warning: /nOtExStInG/b: No such file or directory.^M
Warning: /nOtExStInG/d: No such file or directory.^M
Warning: /nOtExStInG/c: No such file or directory.^M
Source directories searched: /nOtExStInG/b;/nOtExStInG/d;/nOtExStInG/c;/nOtExStInG/a;$cdir;$cwd^M
(gdb) FAIL: gdb.base/source-dir.exp: directory /nOtExStInG/b /nOtExStInG/d /nOtExStInG/c
The regular expression expects ':' and ';' is path separator on Windows.
This patch is to allow ';' as a path separator in regular expression.
This patch is similar to Dan's patch to fix a similar problem here
Re: directory separators on minGW hosts
https://sourceware.org/ml/gdb-patches/2006-02/msg00359.html
It is obvious. Pushed it in.
gdb/testsuite:
2014-03-31 Yao Qi <yao@codesourcery.com>
* gdb.base/source-dir.exp: Allow ';' as a directory separator.
Given the following variable...
BT : Bounded := New_Bounded (Low => 1, High => 3);
... where type Bounded is defined as a simple unconstrained array:
type Bounded is array (Integer range <>) of Integer;
Creating a varobj for that variable, and immediately asking for
varobj updates, GDB says that our varobj changed types!
(gdb)
-var-create bt * bt
^done,name="bt",numchild="3",value="[3]",type="<ref> array (1 .. 3) of integer",has_more="0"
(gdb)
-var-update 1 *
^done,changelist=[{name="bt",value="[3]",in_scope="true",type_changed="true",new_type="<ref> array (1 .. 3) of integer",new_num_children="3",has_more="0"}]
The expected output for the -var-update command is, in this case:
(gdb)
-var-update 1 *
^done,changelist=[]
The problem occurs because the ada-varobj module does not handle
references, and while the references gets stripped when the varobj
gets created, it doesn't when computing varobj updates.
More specifically, when creating the varobj, varobj_create creates
a new value which is a reference to a TYPE_CODE_ARRAY. It then calls
install_new_value which calls coerce_ref with the following comment:
/* We are not interested in the address of references, and given
that in C++ a reference is not rebindable, it cannot
meaningfully change. So, get hold of the real value. */
if (value)
value = coerce_ref (value);
This leaves the varobj's type component still a ref, while
the varobj's value is now our array, without the ref. This explains
why the "value" field in the varobj indicates an array with 3 elements
"[3]" while the "type" field shows a ref to an array. Generally
speaking, most users have said that showing the ref was a useful
piece of information, so this patch is not touching this part.
Next, when the user issues the -var-update request, varobj_update
calls value_of_root to compute the varobj's new value as well as
determine whether the value's type has changed or not. What happens
in a nutshell is that it calls value_of_root_1 (which re-evaluates
the expression and returns the corresponding new value), finds that
the new value is not NULL, and thus asks whether it has mutated:
else if (varobj_value_has_mutated (var, value, value_type (value)))
This then indirectly delegates the determination to the language-specific
callback, which fails, because it does not handle references.
This patch fixes the issue by adjusting varobj_value_has_mutated to
expect references, and strip them when seen. This allows the various
language-specific implementations to remain unaware of references.
gdb/ChangeLog:
* varobj.c (varobj_value_has_mutated): If NEW_VALUE is
a reference, strip the reference layer before calling
the lang_ops value_has_mutated callback.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_dyn_arr: New testcase.
nios2 uses software single step, so GDB is unable to single step to
the signal handler. In order to reflect this, teach
can_single_step_to_signal_handler to return zero for nios2 target.
gdb/testsuite:
2014-03-27 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (can_single_step_to_signal_handler): Return zero
if target is nios2-*-*.
The completion feature and other features on readline depend on the
readline library. However, readline library is not always used, for
example, running testsuite like
make check RUNTESTFLAGS="--host_board=local-remote-host"
the input stream is not a tty, and GDB doesn't use readline library
as a result.
This patch is to skip tests on completion and readline if
'show editing' is off, which means readline isn't used. Note that
some tests in gdb.base/completion.exp test command complete, which
isn't related to readline, so these tests aren't affected by readline
library. This patch also moves these tests up, run them
unconditionally, and run the rest if readline library is used.
gdb/testsuite:
2014-03-26 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (readline_is_used): New proc.
* gdb.base/completion.exp: Move tests on command complete up.
Skip the rest of tests if readline is not used.
* gdb.ada/complete.exp: Skp the test if readline is not
used.
* gdb.base/filesym.exp: Likewise.
* gdb.base/macscp.exp: Likewise.
* gdb.base/readline-ask.exp: Likewise.
* gdb.base/readline.exp: Likewise.
* gdb.python/py-cmd.exp: Likewise.
* gdb.trace/tfile.exp: Likewise.
When I do something else, I find code format in gdb.base/macscp.exp is
messy. This patch is to fix various code format issues in it.
Pushed as it is obvious.
gdb/testsuite:
2014-03-26 Yao Qi <yao@codesourcery.com>
* gdb.base/macscp.exp: Fix code format issues.
Add new powerpc64le.inc file appropriate for the ELFv2 ABI and
use it to support the asm-source.exp test case on powerpc64le.
gdb/testsuite/
2014-03-25 Ulrich Weigand <uweigand@de.ibm.com>
* gdb.asm/asm-source.exp: Handle powerpc64le-* targets.
* gdb.asm/powerpc64le.inc: New file.
Sourcing a GDB script that runs foreground execution commands in
succession fails if the target can async:
Breakpoint 1, main () at ../../../src/gdb/testsuite/gdb.base/source-execution.c:36
36 func1 ();
(gdb) source ../../../src/gdb/testsuite/gdb.base/source-execution.gdb
../../../src/gdb/testsuite/gdb.base/source-execution.gdb:21: Error in sourced command file:
Cannot execute this command while the selected thread is running.
(gdb) FAIL: gdb.base/source-execution.exp: source source-execution.gdb
That is, after a foreground execution command, GDB moves on to the
following command immediately before waiting for the previous command
to complete.
https://sourceware.org/ml/gdb-patches/2011-09/msg00037.html (b4a14fd0)
addressed this for command lists, Python's gdb.execute, etc., but
missed "source". Fixed now in the same way.
gdb/
2014-03-25 Pedro Alves <palves@redhat.com>
* cli/cli-script.c (script_from_file): Force the interpreter to
sync mode.
gdb/testsuite/
2014-03-25 Pedro Alves <palves@redhat.com>
Doug Evans <dje@google.com>
* gdb.base/source-execution.c: New file.
* gdb.base/source-execution.exp: New file.
* gdb.base/source-execution.gdb: New file.
After a previous patch that was committed by Pedro (0000e5cc), trying
to set a dprintf with with a GDBserver that doesn't support agent
commands at all now throws an error. But the dprintf tests still fail
with some GDBserver targets because they doesn't try to handle the
case of the server reporting support for breakpoint commands, but not
be able to use those in combination with Z0 (because Z0 isn't actually
supported, for example):
FAIL: gdb.base/dprintf.exp: 1st dprintf, agent
FAIL: gdb.base/dprintf.exp: 2nd dprintf, agent
FAIL: gdb.base/dprintf.exp: dprintf info 2 (pattern 4)
Similarly for the MI test.
This patch makes the tests handle this scenario.
Tested with native, and native gdbserver on x86_64 Fedora 17.
Also tested with the native-gdbserver.exp board hacked with:
set GDBFLAGS "${GDBFLAGS} -ex \"set remote breakpoint-commands off\""
(actually, "set remote breakpoint-commands off" is presently broken,
so this was on top of a fix for that command.)
which results in:
(gdb) PASS: gdb.base/dprintf.exp: 2nd dprintf, gdb
set dprintf-style agent
warning: Target cannot run dprintf commands, falling back to GDB printf
warning: Target cannot run dprintf commands, falling back to GDB printf
(gdb) UNSUPPORTED: gdb.base/dprintf.exp: set dprintf style to agent
gdb.sum:
Running target native-gdbserver
Running ../../../src/gdb/testsuite/gdb.base/dprintf.exp ...
PASS: gdb.base/dprintf.exp: dprintf
PASS: gdb.base/dprintf.exp: dprintf foo
PASS: gdb.base/dprintf.exp: dprintf 29
PASS: gdb.base/dprintf.exp: dprintf foo,"At foo entry\n"
PASS: gdb.base/dprintf.exp: ignore $bpnum 1
PASS: gdb.base/dprintf.exp: dprintf 26,"arg=%d, g=%d\n", arg, g
PASS: gdb.base/dprintf.exp: dprintf info 1
PASS: gdb.base/dprintf.exp: break 27
PASS: gdb.base/dprintf.exp: 1st dprintf, gdb
PASS: gdb.base/dprintf.exp: 2nd dprintf, gdb
UNSUPPORTED: gdb.base/dprintf.exp: set dprintf style to agent
PASS: gdb.base/dprintf.exp: Set dprintf style to an unrecognized type
And also with the native-gdbserver.exp board hacked with:
set GDBFLAGS "${GDBFLAGS} -ex \"set remote Z-packet off\""
which results in:
(gdb) continue
Continuing.
Warning:
Cannot insert breakpoint 3: Target doesn't support breakpoints that have target side commands.
Cannot insert breakpoint 4: Target doesn't support breakpoints that have target side commands.
(gdb) UNSUPPORTED: gdb.base/dprintf.exp: 1st dprintf, agent
gdb.sum:
Running target native-gdbserver
Running ../../../src/gdb/testsuite/gdb.base/dprintf.exp ...
PASS: gdb.base/dprintf.exp: dprintf
PASS: gdb.base/dprintf.exp: dprintf foo
PASS: gdb.base/dprintf.exp: dprintf 29
PASS: gdb.base/dprintf.exp: dprintf foo,"At foo entry\n"
PASS: gdb.base/dprintf.exp: ignore $bpnum 1
PASS: gdb.base/dprintf.exp: dprintf 26,"arg=%d, g=%d\n", arg, g
PASS: gdb.base/dprintf.exp: dprintf info 1
PASS: gdb.base/dprintf.exp: break 27
PASS: gdb.base/dprintf.exp: 1st dprintf, gdb
PASS: gdb.base/dprintf.exp: 2nd dprintf, gdb
PASS: gdb.base/dprintf.exp: set dprintf style to agent
UNSUPPORTED: gdb.base/dprintf.exp: 1st dprintf, agent
PASS: gdb.base/dprintf.exp: Set dprintf style to an unrecognized type
(One of the new comments mentions breakpoint always-inserted mode.
Actually testing with breakpoint always-inserted mode fails these
dprintf tests, due to the way they are written. But that'll take a
more substancial rewrite of the tests, so I'm leaving that for another
day.)
gdb/testsuite/
2014-03-24 Hui Zhu <hui@codesourcery.com>
Pedro Alves <palves@redhat.com>
PR breakpoints/16101
* gdb.base/dprintf.exp: Use unsupported rather than changing the
test pass/fail messages. Detect missing support for dprintf when
breakpoints are actually inserted.
* gdb.base/mi-dprintf.exp: Detect missing support for dprintf when
breakpoints are actually inserted.
* lib/mi-support.exp (mi_run_cmd_full): Return -1 if continue
fails.
That "set debug lin-lwp 1" command even is not needed for the functionality of
this testcase.
This patch does fix a testcase error on aarch64-none-elf.
gdb/testsuite/
2014-03-24 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.base/gdb-sigterm.exp (do_test): Remove "set debug lin-lwp 1".
Message-ID: <20140323165745.GA23830@host2.jankratochvil.net>
As we move code on reading unavailable memory to target side, GDB core
side doesn't need the "switching momentarily out of tfind mode" dance.
The target remote knows how to read live memory (through remote_ops).
Remove set_traceframe_number and
make_cleanup_restore_traceframe_number, since they are no longer used.
gdb:
2014-03-22 Yao Qi <yao@codesourcery.com>
* remote.c (target_read_live_memory): Remove.
(memory_xfer_live_readonly_partial): Rename it to
remote_xfer_live_readonly_partial. Remove argument 'object'.
All callers updated. Call remote_read_bytes_1
instead of target_read_live_memory.
* tracepoint.c (set_traceframe_number): Remove.
(make_cleanup_restore_traceframe_number): Likewise .
* tracepoint.h (set_traceframe_number): Remove declaration.
(make_cleanup_restore_traceframe_number): Likewise.
This patch moves code in remote_read_bytes on reading from the remote
stub to a new function remote_read_bytes_1.
gdb:
2014-03-22 Yao Qi <yao@codesourcery.com>
* remote.c (remote_read_bytes): Move code on reading from the
remote stub to ...
(remote_read_bytes_1): ... here. New function.
As a follow-up to
[PATCH 7/8] Adjust read_value_memory to use to_xfer_partial
https://sourceware.org/ml/gdb-patches/2014-02/msg00384.html
this patch moves traceframe_available_memory down to the target side.
After this patch, the gdb core code is cleaner, and code on handling
unavailable memory is moved to remote/tfile/ctf targets.
In details, this patch moves traceframe_available_memory code from
memory_xfer_partial_1 to remote target only, so remote target still
uses traceframe_info mechanism to check unavailable memory, and use
remote_ops to read them from read-only sections. We don't use
traceframe_info mechanism for tfile and ctf target, because it is
fast to iterate all traceframes from trace file, so the summary
information got from traceframe_info is not necessary.
This patch also moves two functions to remote.c from target.c,
because they are only used in remote.c. I'll clean them up in another
patch.
gdb:
2014-03-22 Yao Qi <yao@codesourcery.com>
* ctf.c (ctf_xfer_partial): Check the return value of
exec_read_partial_read_only, if it is not TARGET_XFER_OK,
return TARGET_XFER_UNAVAILABLE.
* tracefile-tfile.c (tfile_xfer_partial): Likewise.
* target.c (target_read_live_memory): Move it to remote.c.
(memory_xfer_live_readonly_partial): Likewise.
(memory_xfer_partial_1): Move some code to remote_read_bytes.
* remote.c (target_read_live_memory): Moved from target.c.
(memory_xfer_live_readonly_partial): Likewise.
(remote_read_bytes): New, factored out from
memory_xfer_partial_1.
This fixes:
FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
ERROR: tcl error sourcing .../gdb/testsuite/gdb.threads/thread-specific.exp.
ERROR: can't read "this_breakpoint": no such variable
while executing
"gdb_test_multiple "info breakpoint $this_breakpoint" "info on bp" {
-re ".*stop only in thread (\[0-9\]*).*$gdb_prompt $" {
set this_thread $expe..."
(file ".../gdb/testsuite/gdb.threads/thread-specific.exp" line 108)
invoked from within
"source .../gdb/testsuite/gdb.threads/thread-specific.exp"
("uplevel" body line 1)
invoked from within
"uplevel #0 source .../gdb/testsuite/gdb.threads/thread-specific.exp"
invoked from within
"catch "uplevel #0 source $test_file_name""
and then:
FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
UNTESTED: gdb.threads/thread-specific.exp: info on bp
ERROR: tcl error sourcing .../gdb/testsuite/gdb.threads/thread-specific.exp.
ERROR: can't read "this_thread": no such variable
while executing
"gdb_test {print $_thread} ".* = $this_thread" "thread var at break""
(file ".../gdb/testsuite/gdb.threads/thread-specific.exp" line 119)
invoked from within
"source .../gdb/testsuite/gdb.threads/thread-specific.exp"
("uplevel" body line 1)
invoked from within
"uplevel #0 source .../gdb/testsuite/gdb.threads/thread-specific.exp"
invoked from within
"catch "uplevel #0 source $test_file_name""
Final results:
FAIL: gdb.threads/thread-specific.exp: continue to thread-specific breakpoint (timeout)
UNTESTED: gdb.threads/thread-specific.exp: info on bp
UNTESTED: gdb.threads/thread-specific.exp: thread var at break
Of course the first failure best wasn't there, but failing that the script
shouldn't crash.
* gdb.threads/thread-specific.exp: Handle the lack of usable
$this_breakpoint and $this_thread.
ps -e | grep a.out
28886 pts/12 00:00:00 a.out
gdb -p 28886
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x0000003b0ccbc970 in __nanosleep_nocancel () from /lib64/libc.so.6
../../binutils-gdb/gdb/cleanups.c:265: internal-warning: restore_my_cleanups has found a stale cleanup
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
The backtrace of this issue:
(gdb) bt
file=0x8b0c10 "s' failed.", line=265, fmt=0x8b0c38 "nutils-gdb/gdb/cleanups.c",
ap=0x7fff803e3ed8) at ../../binutils-gdb/gdb/utils.c:748
fmt=0x8b0c38 "nutils-gdb/gdb/cleanups.c", ap=0x7fff803e3ed8)
at ../../binutils-gdb/gdb/utils.c:799
string=0x8b0c38 "nutils-gdb/gdb/cleanups.c") at ../../binutils-gdb/gdb/utils.c:809
at ../../binutils-gdb/gdb/cleanups.c:265
at ../../binutils-gdb/gdb/cleanups.c:276
at ../../binutils-gdb/gdb/exceptions.c:142
at ../../binutils-gdb/gdb/exceptions.c:203
command=0x5d5fb8 <attach_command_continuation_free_args+18>, arg=0x7fff803e525b "2914",
from_tty=1, mask=RETURN_MASK_ALL) at ../../binutils-gdb/gdb/exceptions.c:549
---Type <return> to continue, or q <return> to quit---
func_args=0x7fff803e4280, errstring=0x8cf2e4 "/local/bin", mask=RETURN_MASK_ALL)
at ../../binutils-gdb/gdb/exceptions.c:522
This is a new issue. It is introduced by commit https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=8bc2fe488957946d2cdccda3ce8d4f39e4003ea0
It removed the discard_cleanups (back_to) inside attach_command.
Then restore_my_cleanups will throw a internal_warning.
https://sourceware.org/ml/gdb-patches/2014-03/msg00374.html
2014-03-21 Hui Zhu <hui@codesourcery.com>
Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_pid_to_exec_file): Change xmalloc to
static buffer.
* fbsd-nat.c (fbsd_pid_to_exec_file): Ditto.
* linux-nat.c (linux_child_pid_to_exec_file): Ditto.
* nbsd-nat.c (nbsd_pid_to_exec_file): Ditto.
-- Initial message by Tom Tromey:
While testing on AIX, I happened to notice an internal error coming
from parse_probes. This happens because there are no probes defined
on this platform. This patch fixes the problem by changing an assert
into an ordinary error, and then changing the relevant caller to cope.
This fixes a few tests on AIX; also regtested on x86-64 Fedora 18.
-- Followup by Sergio Durigan Junior:
By reading the patch (and the original code), I found it a little bit
obscure, so I took the liberty to try to improve it. Here's the patch.
Could you please take a look and see if it works on AIX (and also if you
like the approach)?
gdb/
2014-03-20 Tom Tromey <tromey@redhat.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* probe.c (parse_probes): Turn assert into an ordinary error.
* break-catch-throw.c (re_set_exception_catchpoint): Ignore
exceptions when parsing probes. Rearrange the code for clarity.
With target async enabled, py-finish-breakpoint.exp triggers an
assertion failure.
The failure occurs because execute_command re-enters the event loop in
some circumstances, and in this case resets the sync_execution flag.
Then later GDB reaches this assertion in normal_stop:
gdb_assert (sync_execution || !target_can_async_p ());
In detail:
#1 - A synchronous execution command is run. sync_execution is set.
#2 - A python breakpoint is hit (TARGET_WAITKIND_STOPPED), and the
corresponding Python breakpoint's stop method is executed. When
and while python commands are executed, interpreter_async is
forced to 0.
#3 - The Python stop method happens to execute a not-execution-related
gdb command. In this case, "where 1".
#4 - Seeing that sync_execution is set, execute_command nests a new
event loop (although that wasn't necessary; this is the problem).
#5 - The linux-nat target's pipe in the event loop happens to be
marked. That's normal, due to this in linux_nat_wait:
/* If we requested any event, and something came out, assume there
may be more. If we requested a specific lwp or process, also
assume there may be more. */
The nested event loop thus immediately wakes up and calls
target_wait. No thread is actually executing in the inferior, so
the target returns TARGET_WAITKIND_NO_RESUMED.
#6 - normal_stop is reached. GDB prints "No unwaited-for children
left.", and resets the sync_execution flag (IOW, there are no
resumed threads left, so the synchronous command is considered
completed.) This is already bogus. We were handling a
breakpoint!
#7 - the nested event loop unwinds/ends. GDB is now back to handling
the python stop method (TARGET_WAITKIND_STOPPED), which decides
the breakpoint should stop. normal_stop is called for this
event. However, normal_stop actually works with the _last_
reported target status:
void
normal_stop (void)
{
struct target_waitstatus last;
ptid_t last_ptid;
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
...
get_last_target_status (&last_ptid, &last);
...
if (last.kind == TARGET_WAITKIND_NO_RESUMED)
{
gdb_assert (sync_execution || !target_can_async_p ());
target_terminal_ours_for_output ();
printf_filtered (_("No unwaited-for children left.\n"));
}
And due to the nesting in execute command, the last event is now
TARGET_WAITKIND_NO_RESUMED, not the actual breakpoint event being
handled. This could be seen to be broken in itself, but we can
leave fixing that for another pass. The assertion is reached, and
fails.
execute_command has a comment explaining when it should synchronously
wait for events:
/* If the interpreter is in sync mode (we're running a user
command's list, running command hooks or similars), and we
just ran a synchronous command that started the target, wait
for that command to end. */
However, the code did not follow this comment -- it didn't check to
see if the command actually started the target, just whether the
target was executing a sync command at this point.
This patch fixes the problem by noting whether the target was
executing in sync_execution mode before running the command, and then
augmenting the condition to test this as well.
2014-03-20 Tom Tromey <tromey@redhat.com>
PR gdb/14135
* top.c (execute_command): Only dispatch events if the command
started the target.
When target-async is enabled, dprintf.exp fails:
Running ../../../src/gdb/testsuite/gdb.base/dprintf.exp ...
FAIL: gdb.base/dprintf.exp: 1st dprintf, call
FAIL: gdb.base/dprintf.exp: 2nd dprintf, call
FAIL: gdb.base/dprintf.exp: Set dprintf function
FAIL: gdb.base/dprintf.exp: 1st dprintf, fprintf
FAIL: gdb.base/dprintf.exp: 2nd dprintf, fprintf
Breakpoint 2, main (argc=1, argv=0x7fffffffd3f8) at ../../../src/gdb/testsuite/gdb.base/dprintf.c:33
33 int loc = 1234;
(gdb) continue
Continuing.
kickoff 1234
also to stderr 1234
At foo entry
(gdb) FAIL: gdb.base/dprintf.exp: 1st dprintf, call
The problem is that GDB gave the prompt back to the user too early.
This happens when calling functions while handling an event that
doesn't cause a user visible stop. dprintf with "set dprintf-style
gdb" is one such case. This patch adds a test case that has a
breakpoint with a condition that calls a function that returns false,
so that regression testing isn't dependent on the implementation of
dprintf.
The problem happens because run_inferior_call causes GDB to forget
that it is running in sync_execution mode, so any event that runs an
inferior call causes fetch_inferior_event to display the prompt, even
if the event should not result in a user visible stop (that is, gdb
resumes the inferior and waits for the next event).
This patch fixes the issue by noticing when GDB was in sync_execution
mode in run_inferior_call, and taking care to restore this state
afterward.
gdb/
2014-03-20 Tom Tromey <tromey@redhat.com>
PR cli/15718
* infcall.c: Include event-top.h.
(run_inferior_call): Call async_disable_stdin if needed.
gdb/testsuite/
2014-03-20 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
PR cli/15718
* gdb.base/condbreak-call-false.c: New file.
* gdb.base/condbreak-call-false.exp: New file.
This test now uses pthread_kill instead of the host's kill command, so
no longer need to block signals, or store the the inferior's PID.
gdb/testsuite/
2014-03-20 Pedro Alves <palves@redhat.com>
* gdb.threads/signal-while-stepping-over-bp-other-thread.c (pid):
Delete.
(block_signals, unblock_signals): Delete.
(child_function_2, main): Remove references to deleted variable
and functions.
Use pthread_kill instead of the host's "kill". The reason the test
wasn't written that way to begin with, is that done this way, before
the previous fixes to make GDB step-over all other threads before the
stepping thread, the test would fail...
Tested on x86_64 Fedora 17, native and gdbserver.
gdb/testsuite/
2014-03-20 Pedro Alves <palves@redhat.com>
* gdb.threads/signal-while-stepping-over-bp-other-thread.c (main):
Use pthread_kill to signal thread 2.
* gdb.threads/signal-while-stepping-over-bp-other-thread.exp:
Adjust to make the test send itself a signal rather than using the
host's "kill" command.
This test fails with current mainline.
If the program stopped for a breakpoint in thread 1, and then the user
switches to thread 2, and resumes the program, GDB first switches back
to thread 1 to step it over the breakpoint, in order to make progress.
However, that logic only considers the last reported event, assuming
only one thread needs that stepping over dance.
That's actually not true when we play with scheduler-locking. The
patch adds an example to the testsuite of multiple threads needing a
step-over before the stepping thread can be resumed. With current
mainline, the program re-traps the same breakpoint it had already
trapped before.
E.g.:
Breakpoint 2, main () at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:99
99 wait_threads (); /* set wait-threads breakpoint here */
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: continue to breakpoint: run to breakpoint
info threads
Id Target Id Frame
3 Thread 0x7ffff77c9700 (LWP 4310) "multiple-step-o" 0x00000000004007ca in child_function_3 (arg=0x1) at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:43
2 Thread 0x7ffff7fca700 (LWP 4309) "multiple-step-o" 0x0000000000400827 in child_function_2 (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:60
* 1 Thread 0x7ffff7fcb740 (LWP 4305) "multiple-step-o" main () at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:99
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: info threads shows all threads
set scheduler-locking on
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: set scheduler-locking on
break 44
Breakpoint 3 at 0x4007d3: file ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c, line 44.
(gdb) break 61
Breakpoint 4 at 0x40082d: file ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c, line 61.
(gdb) thread 3
[Switching to thread 3 (Thread 0x7ffff77c9700 (LWP 4310))]
#0 0x00000000004007ca in child_function_3 (arg=0x1) at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:43
43 (*myp) ++;
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: thread 3
continue
Continuing.
Breakpoint 3, child_function_3 (arg=0x1) at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:44
44 callme (); /* set breakpoint thread 3 here */
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: continue to breakpoint: run to breakpoint in thread 3
p *myp = 0
$1 = 0
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: unbreak loop in thread 3
thread 2
[Switching to thread 2 (Thread 0x7ffff7fca700 (LWP 4309))]
#0 0x0000000000400827 in child_function_2 (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:60
60 (*myp) ++;
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: thread 2
continue
Continuing.
Breakpoint 4, child_function_2 (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:61
61 callme (); /* set breakpoint thread 2 here */
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: continue to breakpoint: run to breakpoint in thread 2
p *myp = 0
$2 = 0
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: unbreak loop in thread 2
thread 1
[Switching to thread 1 (Thread 0x7ffff7fcb740 (LWP 4305))]
#0 main () at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:99
99 wait_threads (); /* set wait-threads breakpoint here */
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: thread 1
set scheduler-locking off
(gdb) PASS: gdb.threads/multiple-step-overs.exp: step: set scheduler-locking off
At this point all thread are stopped for a breakpoint that needs stepping over.
(gdb) step
Breakpoint 2, main () at ../../../src/gdb/testsuite/gdb.threads/multiple-step-overs.c:99
99 wait_threads (); /* set wait-threads breakpoint here */
(gdb) FAIL: gdb.threads/multiple-step-overs.exp: step
But that "step" retriggers the same breakpoint instead of making
progress.
The patch teaches GDB to step over all breakpoints of all threads
before resuming the stepping thread.
Tested on x86_64 Fedora 17, against pristine mainline, and also my
branch that implements software single-stepping on x86.
gdb/
2014-03-20 Pedro Alves <palves@redhat.com>
* infrun.c (prepare_to_proceed): Delete.
(thread_still_needs_step_over): New function.
(find_thread_needs_step_over): New function.
(proceed): If the current thread needs a step-over, set its
steping_over_breakpoint flag. Adjust to use
find_thread_needs_step_over instead of prepare_to_proceed.
(process_event_stop_test): For BPSTAT_WHAT_STOP_NOISY and
BPSTAT_WHAT_STOP_SILENT, assume the thread stopped for a
breakpoint.
(switch_back_to_stepped_thread): Step over breakpoints of all
threads not the stepping thread, before switching back to the
stepping thread.
gdb/testsuite/
2014-03-20 Pedro Alves <palves@redhat.com>
* gdb.threads/multiple-step-overs.c: New file.
* gdb.threads/multiple-step-overs.exp: New file.
* gdb.threads/signal-while-stepping-over-bp-other-thread.exp:
Adjust expected infrun debug output.
Even with deferred_step_ptid out of the way, GDB can still lose
watchpoints.
If a watchpoint triggers and the PC points to an address where a
thread-specific breakpoint for another thread is set, the thread-hop
code triggers, and we lose the watchpoint:
if (ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_TRAP)
{
int thread_hop_needed = 0;
struct address_space *aspace =
get_regcache_aspace (get_thread_regcache (ecs->ptid));
/* Check if a regular breakpoint has been hit before checking
for a potential single step breakpoint. Otherwise, GDB will
not see this breakpoint hit when stepping onto breakpoints. */
if (regular_breakpoint_inserted_here_p (aspace, stop_pc))
{
if (!breakpoint_thread_match (aspace, stop_pc, ecs->ptid))
thread_hop_needed = 1;
^^^^^^^^^^^^^^^^^^^^^
}
And on software single-step targets, even without a thread-specific
breakpoint in the way, here in the thread-hop code:
else if (singlestep_breakpoints_inserted_p)
{
...
if (!ptid_equal (singlestep_ptid, ecs->ptid)
&& in_thread_list (singlestep_ptid))
{
/* If the PC of the thread we were trying to single-step
has changed, discard this event (which we were going
to ignore anyway), and pretend we saw that thread
trap. This prevents us continuously moving the
single-step breakpoint forward, one instruction at a
time. If the PC has changed, then the thread we were
trying to single-step has trapped or been signalled,
but the event has not been reported to GDB yet.
There might be some cases where this loses signal
information, if a signal has arrived at exactly the
same time that the PC changed, but this is the best
we can do with the information available. Perhaps we
should arrange to report all events for all threads
when they stop, or to re-poll the remote looking for
this particular thread (i.e. temporarily enable
schedlock). */
CORE_ADDR new_singlestep_pc
= regcache_read_pc (get_thread_regcache (singlestep_ptid));
if (new_singlestep_pc != singlestep_pc)
{
enum gdb_signal stop_signal;
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: unexpected thread,"
" but expected thread advanced also\n");
/* The current context still belongs to
singlestep_ptid. Don't swap here, since that's
the context we want to use. Just fudge our
state and continue. */
stop_signal = ecs->event_thread->suspend.stop_signal;
ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0;
ecs->ptid = singlestep_ptid;
ecs->event_thread = find_thread_ptid (ecs->ptid);
ecs->event_thread->suspend.stop_signal = stop_signal;
stop_pc = new_singlestep_pc;
}
else
{
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog,
"infrun: unexpected thread\n");
thread_hop_needed = 1;
stepping_past_singlestep_breakpoint = 1;
saved_singlestep_ptid = singlestep_ptid;
}
}
}
we either end up with thread_hop_needed, ignoring the watchpoint
SIGTRAP, or switch to the stepping thread, again ignoring that the
SIGTRAP could be for some other event.
The new test added by this patch exercises both paths.
So the fix is similar to the deferred_step_ptid fix -- defer the
thread hop to _after_ the SIGTRAP had a change of passing through the
regular bpstat handling. If the wrong thread hits a breakpoint, we'll
just end up with BPSTAT_WHAT_SINGLE, and if nothing causes a stop,
keep_going starts a step-over.
Most of the stepping_past_singlestep_breakpoint mechanism is really
not necessary -- setting the thread to step over a breakpoint with
thread->trap_expected is sufficient to keep all other threads locked.
It's best to still keep the flag in some form though, because when we
get to keep_going, the software single-step breakpoint we need to step
over is already gone -- an optimization done by a follow up patch will
check whether a step-over is still be necessary by looking to see
whether the breakpoint is still there, and would find the thread no
longer needs a step-over, while we still want it.
Special care is still needed to handle the case of PC of the thread we
were trying to single-step having changed, like in the old code. We
can't just keep_going and re-step it, as in that case we can over-step
the thread (if it was already done with the step, but hasn't reported
it yet, we'd ask it to step even further). That's now handled in
switch_back_to_stepped_thread. As bonus, we're now using a technique
that doesn't lose signals, unlike the old code -- we now insert a
breakpoint at PC, and resume, which either reports the breakpoint
immediately, or any pending signal.
Tested on x86_64 Fedora 17, against pristine mainline, and against a
branch that implements software single-step on x86.
gdb/
2014-03-20 Pedro Alves <palves@redhat.com>
* breakpoint.c (single_step_breakpoint_inserted_here_p): Make
extern.
* breakpoint.h (single_step_breakpoint_inserted_here_p): Declare.
* infrun.c (saved_singlestep_ptid)
(stepping_past_singlestep_breakpoint): Delete.
(resume): Remove stepping_past_singlestep_breakpoint handling.
(proceed): Store the prev_pc of the stepping thread too.
(init_wait_for_inferior): Adjust. Clear singlestep_ptid and
singlestep_pc.
(enum infwait_states): Delete infwait_thread_hop_state.
(struct execution_control_state) <hit_singlestep_breakpoint>: New
field.
(handle_inferior_event): Adjust.
(handle_signal_stop): Delete stepping_past_singlestep_breakpoint
handling and the thread-hop code. Before removing single-step
breakpoints, check whether the thread hit a single-step breakpoint
of another thread. If it did, the trap is not a random signal.
(switch_back_to_stepped_thread): If the event thread hit a
single-step breakpoint, unblock it before switching to the
stepping thread. Handle the case of the stepped thread having
advanced already.
(keep_going): Handle the case of the current thread moving past a
single-step breakpoint.
gdb/testsuite/
2014-03-20 Pedro Alves <palves@redhat.com>
* gdb.threads/step-over-trips-on-watchpoint.c: New file.
* gdb.threads/step-over-trips-on-watchpoint.exp: New file.
Say the program is stopped at a breakpoint, and the user sets a
watchpoint. When the program is next resumed, GDB will first step
over the breakpoint, as explained in the manual:
@value {GDBN} normally ignores breakpoints when it resumes
execution, until at least one instruction has been executed. If it
it did not do this, you would be unable to proceed past a breakpoint
without first disabling the breakpoint. This rule applies whether
or not the breakpoint already existed when your program stopped.
However, GDB currently also removes watchpoints, catchpoints, etc.,
and that means that the first instruction off the breakpoint does not
trigger the watchpoint, catchpoint, etc.
testsuite/gdb.base/watchpoint.exp has a kfail for this.
The PR proposes installing watchpoints only when stepping over a
breakpoint, but that misses catchpoints, etc.
A better fix would instead work from the opposite direction -- remove
only real breakpoints, leaving all other kinds of breakpoints
inserted.
But, going further, it's really a waste to constantly remove/insert
all breakpoints when stepping over a single breakpoint (generating a
pair of RSP z/Z packets for each breakpoint), so the fix goes a step
further and makes GDB remove _only_ the breakpoint being stepped over,
leaving all others installed. This then has the added benefit of
reducing breakpoint-related RSP traffic substancialy when there are
many breakpoints set.
gdb/
2014-03-20 Pedro Alves <palves@redhat.com>
PR breakpoints/7143
* breakpoint.c (should_be_inserted): Don't insert breakpoints that
are being stepped over.
(breakpoint_address_match): Make extern.
* breakpoint.h (breakpoint_address_match): New declaration.
* inferior.h (stepping_past_instruction_at): New declaration.
* infrun.c (struct step_over_info): New type.
(step_over_info): New global.
(set_step_over_info, clear_step_over_info)
(stepping_past_instruction_at): New functions.
(handle_inferior_event): Clear the step-over info when
trap_expected is cleared.
(resume): Remove now stale comment.
(clear_proceed_status): Clear step-over info.
(proceed): Adjust step-over handling to set or clear the step-over
info instead of removing all breakpoints.
(handle_signal_stop): When setting up a thread-hop, don't remove
breakpoints here.
(stop_stepping): Clear step-over info.
(keep_going): Adjust step-over handling to set or clear step-over
info and then always inserting breakpoints, instead of removing
all breakpoints when stepping over one.
gdb/testsuite/
2014-03-20 Pedro Alves <palves@redhat.com>
PR breakpoints/7143
* gdb.base/watchpoint.exp: Mention bugzilla bug number instead of
old gnats gdb/38. Remove kfail. Adjust to use gdb_test instead
of gdb_test_multiple.
* gdb.cp/annota2.exp: Remove kfail for gdb/38.
* gdb.cp/annota3.exp: Remove kfail for gdb/38.
Consider the case of the user doing "step" in thread 2, while thread 1
had previously stopped for a breakpoint. In order to make progress,
GDB makes thread 1 step over its breakpoint first (with all other
threads stopped), and once that is over, thread 2 then starts stepping
(with thread 1 and all others running free, by default). If GDB
didn't do that, thread 1 would just trip on the same breakpoint
immediately again. This is what the prepare_to_proceed /
deferred_step_ptid code is all about.
However, deferred_step_ptid code resumes the target with:
resume (1, GDB_SIGNAL_0);
prepare_to_wait (ecs);
return;
Recall we were just stepping over a breakpoint when we get here. That
means that _nothing_ had installed breakpoints yet! If there's
another breakpoint just after the breakpoint that was just stepped,
we'll miss it. The fix for that would be to use keep_going instead.
However, there are more problems. What if the instruction that was
just single-stepped triggers a watchpoint? Currently, GDB just
happily resumes the thread, losing that too...
Missed watchpoints will need yet further fixes, but we should keep
those in mind.
So the fix must be to let the trap fall through the regular bpstat
handling, and only if no breakpoint, watchpoint, etc. claims the trap,
shall we switch back to the stepped thread.
Now, nowadays, we have code at the tail end of trap handling that does
exactly that -- switch back to the stepped thread
(switch_back_to_the_stepped_thread).
So the deferred_step_ptid code is just standing in the way, and can
simply be eliminated, fixing bugs in the process. Sweet.
The comment about spurious "Switching to ..." made me pause, but is
actually stale nowadays. That isn't needed anymore.
previous_inferior_ptid used to be re-set at each (internal) event, but
now it's only touched in proceed and normal stop.
The two tests added by this patch fail without the fix.
Tested on x86_64 Fedora 17 (also against my software single-stepping
on x86 branch).
gdb/
2014-03-20 Pedro Alves <palves@redhat.com>
* infrun.c (previous_inferior_ptid): Adjust comment.
(deferred_step_ptid): Delete.
(infrun_thread_ptid_changed, prepare_to_proceed)
(init_wait_for_inferior): Adjust.
(handle_signal_stop): Delete deferred_step_ptid handling.
gdb/testsuite/
2014-03-20 Pedro Alves <palves@redhat.com>
* gdb.threads/step-over-lands-on-breakpoint.c: New file.
* gdb.threads/step-over-lands-on-breakpoint.exp: New file.
There's no reason not to enable this test anymore.
Even if the current output isn't ideal (we mess up the prompt), it's what
we have today. We can adjust the test if the output improves.
gdb/testsuite/
2014-03-19 Pedro Alves <palves@redhat.com>
* gdb.base/async.exp: Remove early return.
This test is currently racy:
PASS: gdb.base/async.exp: step&
stepi&
(gdb) 0x0000000000400547 14 x = 5; x = 5;
completed.
PASS: gdb.base/async.exp: stepi&
nexti&
(gdb) 15 y = 3;
completed.FAIL: gdb.base/async.exp: nexti&
The problem is here:
-re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" {
pass "$command"
}
-re "$gdb_prompt.*completed\.$" {
fail "$command"
}
Note how the fail pattern is a subset of the pass pattern. If the
expect buffer happens to end up with:
"^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\."
that is, the final "\r\n" has't reached the expect buffer yet, but
"completed." has, then the fail pattern matches...
gdb/testsuite/
2014-03-19 Pedro Alves <palves@redhat.com>
* gdb.base/async.exp (test_background): Expect \r\n after
"completed." in the fail pattern.
All the tests here follow the same pattern (and they all have the same
problem, not fixed here yet). Add a new procedure, factoring out the
pattern to a simple place.
gdb/testsuite/
2014-03-19 Pedro Alves <palves@redhat.com>
* gdb.base/async.exp (test_background): New procedure.
Use it for all background execution command tests.
Currently the test assumes that "stepi" over:
13 x = 5;
end up somewhere midline. But, (at least) on x86, that assignment
ends up compiled as just one movl instruction, so a stepi stops at the
next line already:
completed.
PASS: gdb.base/async.exp: step &
step&
(gdb) foo () at ../../../src/gdb/testsuite/gdb.base/async.c:13
13 x = 5;
completed.
PASS: gdb.base/async.exp: step &
stepi&
(gdb) 14 y = 3;
completed.
FAIL: gdb.base/async.exp: (timeout) stepi &
nexti&
(gdb) 16 return x + y;
completed.
FAIL: gdb.base/async.exp: (timeout) nexti &
finish&
Run till exit from #0 foo () at ../../../src/gdb/testsuite/gdb.base/async.c:16
This patch fixes it, by making sure there's more than one instruction
in that line.
gdb/testsuite/
2014-03-19 Pedro Alves <palves@redhat.com>
* gdb.base/async.c (foo): Make 'x' volatile. Write to it twice in
the same line.
gdb/testsuite/
2014-03-19 Pedro Alves <palves@redhat.com>
* gdb.base/async.c (main): Add "jump here" and "until here" line
marker comments.
* gdb.base/async.exp (jump_here): New global.
(jump& test): Use it.
(until_here): New global.
(until& test): Use it.
Many eons ago, async was only implemented in the remote target, and
you'd activate it by doing "target async" rather than "target remote".
That's long gone now, replaced by "set target-async on".
gdb/testsuite/
2014-03-19 Pedro Alves <palves@redhat.com>
* gdb.base/async.exp: Don't frob gdb_protocol.