This change eliminates some failures on simulator targets and makes
the test run a bit quicker too - without this change, we have to wait
for timeouts.
gdb/testsuite/ChangeLog:
* gdb.base/async.exp (proc test_background): Add case
for asynchronous execution not supported.
This set of patches add support for the zero-padded hexadecimal format for
varobj's, defined as "zero-hexadecimal". We currently only support regular
non-zero-padded hexadecimal.
Talking with IDE developers, they would like to have this option that is
already available to GDB's print/x commands, in the CLI, as 'z'.
gdb/ChangeLog:
2015-12-09 Luis Machado <lgustavo@codesourcery.com>
* gdb/mi/mi-cmd-var.c (mi_parse_format): Handle new "zero-hexadecimal"
format.
* gdb/varobj.c (varobj_format_string): Add "zero-hexadecimal" entry.
(format_code): Add 'z' entry.
(varobj_set_display_format): Handle FORMAT_ZHEXADECIMAL.
* gdb/varobj.h (varobj_display_formats) <FORMAT_ZHEXADECIMAL>: New enum
field.
* NEWS: Add new note to MI changes citing the new zero-hexadecimal
format for -var-set-format.
gdb/doc/ChangeLog:
2015-12-09 Luis Machado <lgustavo@codesourcery.com>
* gdb.texinfo (GDB/MI Variable Objects): Update text to mention
-var-set-format's new zero-hexadecimal format.
gdb/testsuite/ChangeLog:
2015-12-09 Luis Machado <lgustavo@codesourcery.com>
* gdb.mi/mi-var-display.exp: Add new checks for the zero-hexadecimal
format and change test names to make them unique.
When `info float` is used on an AMD64 system, GDB prints
floating-point values of x87 registers with raw contents like
0x361a867a8e0527397ce0 or 0xc4f988454a1ddd3cfdab wrongly.
This happens due to truncation to double, after which the former
becomes 0.0, and the latter becomes negative infinity. This is caused
by failed detection of x86-64 host, which results in setting
gdb_host_{float,double,long_double}_format to zeros.
This commit fixes this misdetection, and adds a test to make sure
future commits don't introduce a regression here.
gdb/ChangeLog:
2015-12-09 Ruslan Kabatsayev <b7.10110111@gmail.com>
PR gdb/18702
* configure.host: Fix detection of x86_64 host when setting
floatformats.
gdb/testsuite/ChangeLog:
2015-12-09 Ruslan Kabatsayev <b7.10110111@gmail.com>
Pedro Alves <pedro@redhat.com>
PR gdb/18702
Add checking of floatformats setup on x86_64 hosts.
* gdb.arch/i386-float.S (main): Load bigval and smallval.
(smallval, bigval): New labels/constants.
* gdb.arch/i386-float.exp: Use with_test_prefix and test "info
float" after loading bigval and smallval.
So far, trying to evaluate an expression involving a function call for
which GDB could find multiple function candidates outputs a menu so that
the user can select the one to run. For instance, with the two
following functions:
type New_Integer is new Integer;
function F (I : Integer) return Boolean;
function F (I : New_Integer) return Boolean;
Then we get the following GDB session:
(gdb) print f(1)
Multiple matches for f
[0] cancel
[1] foo.f at foo.adb:23
[2] foo.f at foo.adb.28
>
While the source location information is sufficient in order to
determine which one to select, one has to look for them in source files,
which is not convenient.
This commit tunes this menu in order to also include the list of formal
and return types (if any) in each entry. The above then becomes:
(gdb) print f(1)
Multiple matches for f
[0] cancel
[1] foo.f (integer) return boolean at foo.adb:23
[2] foo.f (foo.new_integer) return boolean at foo.adb.28
>
Since this output is more verbose than previously, this change also
introduces an option (set/show ada print-signatures) to get the original
output.
gdb/ChangeLog:
* ada-lang.c (print_signatures): New.
(ada_print_symbol_signature): New.
(user_select_syms): Add signatures to the output of candidate
symbols using ada_print_symbol_signature.
(_initialize_ada_language): Add a "set/show ada
print-signatures" boolean option.
gdb/testsuite/ChangeLog:
* gdb.ada/fun_overload_menu.exp: New testcase.
* gdb.ada/fun_overload_menu/foo.adb: New testcase.
Tested on x86_64-linux, no regression.
Rename target_ops.arch_setup to .post_create_inferior. In the Linux
hook, continue calling the low arch setup, then also set ptrace flags.
This corrects the possibility of running without flags, demonstrated by
a new test that would fail to catch a fork before.
gdb/gdbserver/ChangeLog:
2015-12-04 Josh Stone <jistone@redhat.com>
* target.h (struct target_ops) <arch_setup>: Rename to ...
(struct target_ops) <post_create_inferior>: ... this.
(target_arch_setup): Rename to ...
(target_post_create_inferior): ... this, calling post_create_inferior.
* server.c (start_inferior): Update target_arch_setup calls to
target_post_create_inferior.
* linux-low.c (linux_low_ptrace_options): Forward declare.
(linux_arch_setup): Update its comment for general use.
(linux_post_create_inferior): New, run arch_setup and setup ptrace.
(struct linux_target_ops): Use linux_post_create_inferior.
* lynx-low.c (struct lynx_target_ops): Update arch_setup stub comment
to post_create_inferior.
* nto-low.c (struct nto_target_ops): Likewise.
* spu-low.c (struct spu_target_ops): Likewise.
* win32-low.c (struct win32_target_ops): Likewise.
gdb/testsuite/ChangeLog:
2015-12-04 Josh Stone <jistone@redhat.com>
* gdb.base/catch-fork-static.exp: New.
In my remote cross testing (x86_64 host and aarch64 target), the test
gdb.base/sizeof.exp is skipped because gdb,noinferiorio is defined in
my gdbserver board file. Tests are skipped because the test checks
the expected value from the program's output, but I don't see why must
do it this way. With my patch applied, we can save the result in variable
in the program, and check the variable then. Then, the test doesn't rely
on inferiorio.
gdb/testsuite:
2015-12-03 Yao Qi <yao.qi@linaro.org>
* gdb.base/sizeof.c: Don't include stdio.h and
../lib/unbuffer_output.c.
(main): New variable 'size' and 'value'. Remove printf and
gdb_unbuffer_output. Assign return value to size and value.
* gdb.base/sizeof.exp: Remove the checking to gdb,noinferiorio
at the beginning.
(check_sizeof): Check the result by printing variable 'size'.
(check_valueof): Check the result by printing variable 'value'.
Testing with "maint set target-non-stop on" causes regressions in
tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on
the RSP. In real all-stop, gdbserver detects the situation and
reporst error to GDB, and so the tests (e.g.,
gdb.threads/no-unwaited-for-left.exp) at fail quickly. But with
"maint set target-non-stop on", GDB instead hangs forever waiting for
a stop reply that never comes, and so the tests take longer to time
out.
This adds a new "N" stop reply packet that maps 1-1 to
TARGET_WAITKIND_NO_RESUMED.
gdb/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
PR 14618
* NEWS (New remote packets): Mention the N stop reply.
* remote.c (remote_protocol_features): Add "no-resumed" entry.
(remote_query_supported): Report no-resumed+ support.
(remote_parse_stop_reply): Handle 'N'.
(process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED.
(remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED.
(_initialize_remote): Register "set/show remote
no-resumed-stop-reply" commands.
gdb/doc/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
PR 14618
* gdb.texinfo (Stop Reply Packets): Document the N stop reply.
(Remote Configuration): Add the "set/show remote
no-resumed-stop-reply" to the available settings table.
(General Query Packets): Document the "no-resumed" qSupported
feature.
gdb/gdbserver/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
PR 14618
* linux-low.c (linux_wait_1): If the last resumed thread is gone,
report TARGET_WAITKIND_NO_RESUMED.
* remote-utils.c (prepare_resume_reply): Handle
TARGET_WAITKIND_NO_RESUMED.
* server.c (report_no_resumed): New global.
(handle_query) <qSupported>: Handle "no-resumed+". Report
"no-resumed+" support.
(resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only
return error if the client doesn't support no-resumed events.
(push_stop_notification): New function.
(handle_target_event): Use it. Report TARGET_WAITKIND_NO_RESUMED
events if the client supports them.
gdb/testsuite/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
The range-stepping tests fail with "maint set target-non-stop on" mode
because exec_cmd_expect_vCont_count doesn't know that in non-stop
mode, vCont's reply is simply "OK".
gdb/testsuite/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* lib/range-stepping-support.exp (exec_cmd_expect_vCont_count):
Handle non-stop mode vCont replies.
Testing with the extended-remote board with "maint set target-non-stop
on" shows a dprintf-non-stop.exp regression. The issue is simply that
the test is expecting output that is only valid for the native target:
native:
[process 8676] #1 stopped.
remote:
[Thread 8900.8900] #1 stopped.
In order to expose this without "maint set target-non-stop on", this
restarts gdb with non-stop mode already enabled.
gdb/testsuite/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* gdb.base/dprintf-non-stop.exp: Use build_executable instead of
prepare_for_testing. Start gdb with "set non-stop on" appended to
GDBFLAGS. Lax expected stop output.
Testing with "maint set target-non-stop on" makes mi-nonstop.exp run
with the extended-remote board. That reveals that mi-nonstop.exp is
using the wrong predicate to check for "using remote protocol".
This is not visible today because non-stop tests all fail to run with
extended-remote board, because they spawn gdb and then do "set
non-stop on". However, with that board, gdb connects to the gdbserver
from within mi_gdb_start, and changing non-stop when already connected
doesn't work. Fix that by instead enabling non-stop mode on gdb's
command line.
gdb/testsuite/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-nonstop.exp: Append "set non-stop on" to GDBFLAGS
instead of issuing "-gdb-set non-stop 1" after starting gdb.
Use mi_is_target_remote instead of checking "is_remote target".
* lib/gdb.exp (gdb_is_target_remote): Rename to ...
(gdb_is_target_remote_prompt): ... this, and add 'prompt_regexp'
parameter.
(gdb_is_target_remote): Reimplement.
* lib/mi-support.exp (mi_is_target_remote): New procedure.
Both ARM and AArch64 have defined some SIMD data types in arm_neon.h,
but we don't have a test case for passing them and returning them in
inferior call. This test also covers passing and returning
homogeneous short vector aggregate (defined by AArch64 ABI document)
in inferior call too.
gdb/testsuite:
* gdb.arch/arm-neon.exp: New.
* gdb.arch/arm-neon.c: New.
Hi,
I see one fail on aarch64-linux testing,
FAIL: gdb.cp/annota2.exp: watch triggered on a.x (timeout)
because GDB prints two frames-invalid annotation but the test expects
only one.
next^M
^M
^Z^Zpost-prompt^M
^M
^Z^Zstarting^M
^M
^Z^Zframes-invalid^M
^M
^Z^Zframes-invalid^M
^M
Note I also see the fail on Debian-s390x-m64 too.
https://sourceware.org/ml/gdb-testers/2015-q4/msg07291.html
The test shouldn't only expect one frames-invalid annotation, because
there can be multiple times of stop/resume before the user visible
stop. Ulrich did something similar before
https://www.sourceware.org/ml/gdb-patches/2009-06/msg00118.html
This patch only changes ${frames_invalid} to \(${frames_invalid}\)*
in the regexp pattern.
The patch below fixes the fail on aarch64-linux.
gdb/testsuite:
2015-11-27 Yao Qi <yao.qi@linaro.org>
* gdb.cp/annota2.exp: Allow multiple occurrences of the
frames-invalid annotation.
Variable frames_invalid was defined, but wasn't used much. This patch
is to replace the literals in the regexp with ${frames_invalid}.
gdb/testsuite:
2015-11-27 Yao Qi <yao.qi@linaro.org>
* gdb.cp/annota2.exp: Use ${frames_invalid}.
I couldn't find a test that verified the thread name functionality, so I
created a new one.
A target board can define gdb,no_thread_names if it doesn't support thread
names and wants to skip the tests that uses them.
This test has been made with Linux in mind. Not all platforms use
pthread_setname_np to set the thread name, but some #ifdefs can be added
later in order to support other platforms.
Tested on x86-64 Ubuntu 14.04, native and remote.
gdb/testsuite/ChangeLog:
* gdb.threads/names.exp: New file.
* gdb.threads/names.c: New file.
* README: Mention gdb,no_thread_names.
If GDB has been configured without libipt support, i.e. HAVE_LIBIPT is
undefined, and is running on a system that supports Intel(R) Processor Trace,
GDB will run into an internal error when trying to decode the trace.
(gdb) record btrace
(gdb) s
usage (name=0x7fffffffe954 "fib-64")
at src/fib.c:12
12 fprintf(stderr, "usage: %s <num>\n", name);
(gdb) info record
Active record target: record-btrace
Recording format: Intel(R) Processor Trace.
Buffer size: 16kB.
gdb/btrace.c:971: internal-error: Unexpected branch trace format.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
This requires a system with Linux kernel 4.1 or later running on a 5th
Generation Intel Core processor or later.
The issue is documented as PR 19297.
When trying to enable branch tracing, in addition to checking the target
support for the requested branch tracing format, also check whether GDB
supports. it.
gdb/
* btrace.c (btrace_enable): Check whether HAVE_LIBIPT is defined.
testsuite/
* lib/gdb.exp (skip_btrace_pt_tests): Check for a "GDB does not
support" error.
Before:
(gdb) info display
Auto-display expressions now in effect:
Num Enb Expression
3: y 1
2: y 1
1: y 1
After:
(gdb) info display
Auto-display expressions now in effect:
Num Enb Expression
1: y 1
2: y 1
3: y 1
gdb/ChangeLog:
2015-11-24 Pedro Alves <palves@redhat.com>
PR 17539
* printcmd.c (display_command): Append new display at the end of
the list.
gdb/testsuite/ChangeLog:
2015-11-24 Pedro Alves <palves@redhat.com>
PR 17539
* gdb.base/display.exp: Expect displays to be sorted in ascending
order. Use multi_line.
* gdb.base/solib-display.exp: Likewise.
Before:
(gdb) info checkpoints
3 process 29132 at 0x4008ad, file foo.c, line 81
2 process 29131 at 0x4008ad, file foo.c, line 81
1 process 29130 at 0x4008ad, file foo.c, line 81
* 0 Thread 0x7ffff7fc5740 (LWP 29128) (main process) at 0x4008ad, file foo.c, line 81
After:
(gdb) info checkpoints
* 0 Thread 0x7ffff7fc5740 (LWP 29128) (main process) at 0x4008ad, file foo.c, line 81
1 process 29130 at 0x4008ad, file foo.c, line 81
2 process 29131 at 0x4008ad, file foo.c, line 81
3 process 29132 at 0x4008ad, file foo.c, line 81
gdb/ChangeLog:
2015-11-24 Pedro Alves <palves@redhat.com>
PR 17539
* printcmd.c (display_command): Append new display at the end of
the list.
gdb/testsuite/ChangeLog:
2015-11-24 Pedro Alves <palves@redhat.com>
PR 17539
* gdb.base/display.exp: Expect displays to be sorted in ascending
order. Use multi_line.
* gdb.base/solib-display.exp: Likewise.
Before:
(gdb) info threads
Id Target Id Frame
3 Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30
2 Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60
* 1 Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92
After:
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92
2 Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60
3 Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30
gdb/doc/ChangeLog:
2015-11-24 Pedro Alves <palves@redhat.com>
PR 17539
* gdb.texinfo (Inferiors and Programs): Adjust "maint info
program-spaces" example to ascending order listing.
(Threads): Adjust "info threads" example to ascending order
listing.
(Forks): Adjust "info inferiors" example to ascending order
listing.
gdb/ChangeLog:
2015-11-24 Pedro Alves <palves@redhat.com>
PR 17539
* inferior.c (add_inferior_silent): Append the new inferior to the
end of the list.
* progspace.c (add_program_space): Append the new pspace to the
end of the list.
* thread.c (new_thread): Append the new thread to the end of the
list.
gdb/testsuite/ChangeLog:
2015-11-24 Pedro Alves <palves@redhat.com>
PR 17539
* gdb.base/foll-exec-mode.exp: Adjust to GDB listing inferiors and
threads in ascending order.
* gdb.base/foll-fork.exp: Likewise.
* gdb.base/foll-vfork.exp: Likewise.
* gdb.base/multi-forks.exp: Likewise.
* gdb.mi/mi-nonstop.exp: Likewise.
* gdb.mi/mi-nsintrall.exp: Likewise.
* gdb.multi/base.exp: Likewise.
* gdb.multi/multi-arch.exp: Likewise.
* gdb.python/py-inferior.exp: Likewise.
* gdb.threads/break-while-running.exp: Likewise.
* gdb.threads/execl.exp: Likewise.
* gdb.threads/gcore-thread.exp: Likewise.
* gdb.threads/info-threads-cur-sal.exp: Likewise.
* gdb.threads/kill.exp: Likewise.
* gdb.threads/linux-dp.exp: Likewise.
* gdb.threads/multiple-step-overs.exp: Likewise.
* gdb.threads/next-bp-other-thread.exp: Likewise.
* gdb.threads/step-bg-decr-pc-switch-thread.exp: Likewise.
* gdb.threads/step-over-lands-on-breakpoint.exp: Likewise.
* gdb.threads/step-over-trips-on-watchpoint.exp: Likewise.
* gdb.threads/thread-find.exp: Likewise.
* gdb.threads/tls.exp: Likewise.
* lib/mi-support.exp (mi_reverse_list): Delete.
(mi_check_thread_states): No longer reverse list.
When trying to save fast tracepoints to file, gdb returns internal failure:
gdb/breakpoint.c:13446: internal-error: unhandled tracepoint type 27
A problem internal to GDB has been detected, further debugging may prove unreliable.
And no file including the fast tracepoints definition is created.
The patch also extends save-trace.exp to test saving tracepoint with a
fast tracepoint in there. Note that because this test doesn't actually
inserts the tracepoints in the program, we can run it with targets that
don't actually support fast tracepoints (or tracepoints at all).
gdb/ChangeLog:
* breakpoint.c (tracepoint_print_recreate): Fix logic error
if -> else if.
gdb/testsuite/ChangeLog:
* gdb.trace/actions.c: Include trace-common.h.
(main): Add a location for a fast tracepoint.
* gdb.trace/save-trace.exp: Set a fast tracepoint in addition to
the normal tracepoints.
(gdb_verify_tracepoints): Adjust number of expected tracepoints.
Some code is duplicated, to run the test twice with absolute and
relative paths, so I factored it out in a few procs. It uses
with_test_prefix to differentiate between test runs.
I replaced usages of "save-tracepoints" with "save tracepoint", since
the former is deprecated.
I also removed the "10.x", as it doesn't make much sense anymore. It
isn't used in general in the testsuite, and I don't think it's really
useful.
gdb/testsuite/ChangeLog:
* save-trace.exp: Factor out code to these...
(gdb_save_tracepoints): New.
(gdb_load_tracepoints): New.
(do_save_load_test): New.
The comment for the code in question says:
/* If the minimal symbol has a zero size, save it
but keep scanning backwards looking for one with
a non-zero size. A zero size may mean that the
symbol isn't an object or function (e.g. a
label), or it may just mean that the size was not
specified. */
As written, the code in question will only scan past the first symbol
of zero size. My change fixes the implementation to match the
comment.
Having this correct is important when the compiler generates several
local labels that are left in place by the linker. (I've been told
that the linker should eliminate these symbols, but I know of one
architecture for which this is not happening.)
I've created a test case called asmlabel.c. It's pretty simple:
main (int argc, char **argv)
{
asm ("L0:");
v = 0;
asm ("L1:");
v = 1; /* set L1 breakpoint here */
asm ("L2:");
v = 2; /* set L2 breakpoint here */
return 0;
}
If breakpoints are placed on the lines indicated by the comments,
this is the behavior of GDB built without my patch:
(gdb) continue
Continuing.
Breakpoint 2, L1 () at asmlabel.c:26
26 v = 1; /* set L1 breakpoint here */
Note that L1 appears as the function instead of main. This is not
what we want to happen. With my patch in place, we see the desired
behavior instead:
(gdb) continue
Continuing.
Breakpoint 2, main (argc=1, argv=0x7fffffffdb88) at asmlabel.c:26
26 v = 1; /* set L1 breakpoint here */
gdb/ChangeLog:
* minsyms.c (lookup_minimal_symbol_by_pc_section_1): Scan backwards
over all zero-sized symbols.
gdb/testsuite/ChangeLog:
* gdb.base/asmlabel.exp: New test.
* gdb.base/asmlabel.c: New test case.
One of our users reported an internal error using the "bt full"
command. In their situation, reproducing involved the following
scenario:
(gdb) frame 1
(gdb) bt full
#0 0xf7783430 in __kernel_vsyscall ()
No symbol table info available.
#1 0xf5550aeb in waitpid () at ../sysdeps/unix/syscall-template.S:81
No locals.
[...]
#6 0x0fe83139 in xxxx (arg=...)
[...some locals printed, and then...]
<S17b> =
[...]/dwarf2loc.c:364: internal-error: dwarf_expr_frame_base: Assertion
`framefunc != NULL' failed.
As shown above, the error happens while GDB is trying to print the value
of <S17b>, which is a local string internally generated by the compiler.
For that, it finds that the array lives in memory, and therefore tries
to create a struct value for it via:
case DWARF_VALUE_MEMORY:
{
CORE_ADDR address = dwarf_expr_fetch_address (ctx, 0);
[...]
retval = value_at_lazy (type, address + byte_offset);
Unfortunately for us, TYPE happens to be an array whose bounds
are dynamic. More precisely, the bounds of our arrays are described
in the debugging info as being...
<4><2c1985e>: Abbrev Number: 33 (DW_TAG_subrange_type)
<2c1985f> DW_AT_type : <0x2c1989c>
<2c19863> DW_AT_lower_bound : <0x2c19835>
<2c19867> DW_AT_upper_bound : <0x2c19841>
... which are references to a pair of local variables. For instance,
the lower bound is a reference to the following DIE
<3><2c19835>: Abbrev Number: 32 (DW_TAG_variable)
<2c19836> DW_AT_name : [...]
<2c1983a> DW_AT_type : <0x2c198b4>
<2c1983e> DW_AT_artificial : 1
<2c1983e> DW_AT_location : 2 byte block: 91 58 (DW_OP_fbreg: -40)
As a result of the above, value_at_lazy indirectly triggers
a resolution of TYPE (via value_from_contents_and_address),
which means a resolution of TYPE's bounds, and as seen in
the DW_AT_location attribute above for our bounds, computing
the bound's location requires the frame (its location expression
uses DW_OP_fbreg).
Unfortunately for us, value_at_lazy does not get passed a frame,
we've lost the relevant frame when we try to resolve the array's
bounds. Instead, resolve_dynamic_range gets calls dwarf2_evaluate_property
with NULL as the frame:
static struct type *
resolve_dynamic_range (struct type *dyn_range_type,
struct property_addr_info *addr_stack)
{
[...]
if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
^^^^
... which then handles this by using the selected frame instead:
if (frame == NULL && has_stack_frames ())
frame = get_selected_frame (NULL);
In our case, the selected frame happens to be frame #1, which is
a frame where we have a minimal amount of debugging info, and in
particular, no debug info for the function itself. And because of that,
when we try to determine the frame's base...
static void
dwarf_expr_frame_base (void *baton, const gdb_byte **start,
size_t * length)
{
struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
const struct block *bl = get_frame_block (debaton->frame, NULL);
[...]
framefunc = block_linkage_function (bl);
... framefunc ends up being NULL, which triggers the assert
in that same function:
gdb_assert (framefunc != NULL);
This patches avoids the issue by temporarily setting the selected_frame
before printing the locals of each frames.
This patch also adds a small testcase, which reproduces the same
issue, but with a slightly different outcome:
(gdb) bt full
#0 0x000000000040049a in opaque_routine ()
No symbol table info available.
#1 0x0000000000400532 in main () at wrong_frame_bt_full-main.c:20
my_table_size = 3
my_table = <error reading variable my_table (frame address is not available.)>
With this patch, the output becomes:
(gdb) bt full
[...]
my_table = {0, 1, 2}
gdb/ChangeLog:
* stack.c (print_frame_local_vars): Temporarily set the selected
frame to FRAME while printing the frame's local variables.
gdb/testsuite/ChangeLog:
* gdb.base/wrong_frame_bt_full-main.c: New file.
* gdb.base/wrong_frame_bt_full-opaque.c: New file.
* gdb.base/wrong_frame_bt_full.exp: New file.
Using the gdb.ada/var_rec_arr.exp test, where the program declares
an array of variant records...
type Record_Type (I : Small_Type := 0) is record
S : String (1 .. I);
end record;
type Array_Type is array (Integer range <>) of Record_Type;
... and then a variable A1 of type Array_Type, the following command
ocassionally trigger an internal error trying to allocate more memory
than we have left:
(gdb) ptype a1(1)
[...]/utils.c:1089: internal-error: virtual memory exhausted.
A problem internal to GDB has been detected,
[...]
What happens is that recent versions of GNAT are able to generate
DWARF expressions for type Record_Type, and therefore the record's
DW_AT_byte_size is not a constant, which unfortunately breaks
an assumption made by dwarf2read.c:read_structure_type when it does:
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr)
{
TYPE_LENGTH (type) = DW_UNSND (attr);
}
As a result of this, when ada_evaluate_subexp tries to create
a value_zero for a1(1) while processing the OP_FUNCALL operator
as part of evaluating the subscripting operation in no-side-effect
mode, we try to allocate a value with a bogus size, potentially
triggering the out-of-memory internal error.
This patch avoids this issue by setting the length to zero in
this case. Until we decide to start supporting dynamic type
lengths in GDB's type struct, and it's not clear yet that
this is worth the effort (see added comment), that's probably
the best we can do.
gdb/ChangeLog:
* dwarf2read.c (read_structure_type): Set the type's length
to zero if it has a DW_AT_byte_size attribute which is not
a constant.
gdb/testsuite/ChangeLog:
* testsuite/gdb.ada/var_rec_arr.exp: Add "ptype a1(1)" test.
The Linux kernel disables the FPU upon returning to userland. This
introduces spurious failures in the register preservation tests in
callfuncs.exp, since the pstate.PEF bit gets cleared after system
calls.
This patch filters out the pstate register in sparc64-*-linux-gnu
targets, so the relevant tests are no longer fooled and pass.
gdb/testsuite/ChangeLog:
2015-11-20 Jose E. Marchesi <jose.marchesi@oracle.com>
* gdb.base/callfuncs.exp (fetch_all_registers): Filter out the
pstate register when comparing registers values in
sparc64-*-linux-gnu targets to avoid spurious differences.
This patch adds a missing include that makes the test program to not
be built (--Wimplicit-function-declaration).
gdb/testsuite/ChangeLog:
2015-11-20 Jose E. Marchesi <jose.marchesi@oracle.com>
* gdb.arch/sparc-sysstep.c: Include unistd.h for getpid.
This patch fixes all occurences of left-shifting negative constants in C cod
which is undefined by the C standard.
gdb/testsuite/ChangeLog:
* lib/dwarf.exp (_note): Fix left shift of negative value.
* gdb.trace/trace-condition.exp: Likewise.
This patch removes the leftover of the d10v stuff in the testsuite
directory. The d10v port was removed in GDB 6.7, but I happen to see
that there are still some leftovers about d10v in testsuite.
gdb/testsuite:
2015-11-13 Yao Qi <yao.qi@linaro.org>
* gdb.base/call-sc.exp (test_scalar_returns): Remove the
comments about d10v.
(test_scalar_returns): Likewise.
* gdb.base/d10v.ld: Remove.
* gdb.base/overlays.exp: Remove the target triplet checking for
d10v-*-*.
* gdb.base/structs.exp (test_struct_returns): Remove the
comments about d10v.
(test_struct_calls): Likewise.
gdb.base/gnu_vector.c printf the vector and gdb.base/gnu_vector.exp
expects the output by gdb_test_multiple. Nowadays, the test doesn't
expect the output from inferior_spawn_id, which is wrong. Even we
change the test to expect from inferior_spawn_id for the inferior
output, it is still possible the inferior exit before tcl/expect gets
the inferior output. We see this fail on both s390x-linux and
ppc-linux on buildbot,
FAIL: gdb.base/gnu_vector.exp: verify vector return value (the program exited)
https://sourceware.org/ml/gdb-testers/2015-q4/msg04922.htmlhttps://sourceware.org/ml/gdb-testers/2015-q4/msg04952.html
In order to address these two shortcomings above in gnu_vector.exp,
this patch rewrites the test a little bit. Get rid of checking the
inferior output, and instead checking them by printing them. In this
way, the test can also be run on the target without inferior io
(gdb,noinferiorio is set in the board file).
gdb/testsuite:
2015-11-13 Yao Qi <yao.qi@linaro.org>
* gdb.base/gnu_vector.exp: Check the return value by "p res".
* gdb.base/gnu_vector.c: Don't include stdio.h.
(main): Don't print res and call add_some_intvecs.
The assembly code for emitting the proper tracepointable instruction
was duplicated in many places. Keep it in one place, to reduce work
needed for new targets.
gdb/testsuite/ChangeLog:
* gdb.trace/change-loc.h: include "trace-common.h", remove SYMBOL
macro.
(func5): Removed.
(func4): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/ftrace-lock.c: include "trace-common.h", remove SYMBOL
macro.
(func): Removed.
(thread_function): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/ftrace.c: include "trace-common.h", remove SYMBOL macro.
(func): Remove.
(marker): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/pendshr1.c: include "trace-common.h", remove SYMBOL macro.
(pendfunc1): Remove.
(pendfunc): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/pendshr2.c: include "trace-common.h", remove SYMBOL macro.
(foo): Remove.
(pendfunc2): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/trace-break.c: include "trace-common.h", remove SYMBOL
macro.
(func): Remove.
(marker): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/trace-common.h: New header.
* gdb.trace/trace-condition.c: include "trace-common.h", remove SYMBOL
macro.
(func): Remove.
(marker): Use FAST_TRACEPOINT_LABEL.
* gdb.trace/trace-mt.c: include "trace-common.h", remove SYMBOL macro.
(func): Remove.
(thread_function): Use FAST_TRACEPOINT_LABEL.
These variables were used in many gdb.trace tests. Keep them in one place,
to reduce work needed for new targets.
gdb/testsuite/ChangeLog:
* gdb.trace/backtrace.exp: Use global fpreg/spreg definition, add $
in front.
* gdb.trace/change-loc.exp: Use global pcreg definition.
* gdb.trace/collection.exp: Use global pcreg/fpreg/spreg definition.
* gdb.trace/entry-values.exp: Use global spreg definition, add $
in front.
* gdb.trace/mi-trace-frame-collected.exp: Use global pcreg definition.
* gdb.trace/pending.exp: Likewise.
* gdb.trace/report.exp: Use global pcreg/fpreg/spreg definition.
* gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-condition.exp: Use global pcreg definition, add $
in front.
* gdb.trace/unavailable.exp: Use global pcreg/fpreg/spreg definition.
* gdb.trace/while-dyn.exp: Use global fpreg definition, add $
in front.
* lib/trace-support.exp: Define fpreg, spreg, pcreg variables.
Consider a function with the following signature...
function F (R : out Rec_Type) return Enum_Type;
... where Rec_Type is a simple record:
type Rec_Type is record
Cur : Integer;
end record;
Trying to "finish" from that function causes GDB to SEGV:
(gdb) fin
Run till exit from #0 bar.f (r=...) at bar.adb:5
0x00000000004022fe in foo () at foo.adb:5
5 I : Enum_Type := F (R);
[1] 18949 segmentation fault (core dumped) /[..]/gdb
This is related to the fact that funtion F has a parameter (R)
which is an "out" parameter being passed by copy. For those,
GNAT transforms the return value to be a record with multiple
fields: The first one is called "RETVAL" and contains the return
value shown in the source, and the remaining fields have the same
name as the "out" or "in out" parameters which are passed by copy.
So, in the example above, function F returns a struct that has
one field who name is "r".
Because "RETVAL" starts with "R", GDB thinks it's a wrapper field,
because it looks like the encoding used for variant records:
-- member_name ::= {choice} | others_choice
-- choice ::= simple_choice | range_choice
-- simple_choice ::= S number
-- range_choice ::= R number T number <<<<<----- here
-- number ::= {decimal_digit} [m]
-- others_choice ::= O (upper case letter O)
See ada_is_wrapper_field:
return (name != NULL
&& (startswith (name, "PARENT")
|| strcmp (name, "REP") == 0
|| startswith (name, "_parent")
|| name[0] == 'S' || name[0] == 'R' || name[0] == 'O'));
As a result of this, when trying to print the RETURN value,
we think that RETVAL is a wrapper, and thus recurse into
print_field_values...
if (ada_is_wrapper_field (type, i))
{
comma_needed =
print_field_values (TYPE_FIELD_TYPE (type, i),
valaddr,
(offset
+ TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT),
stream, recurse, val, options,
comma_needed, type, offset, language);
... which is a problem since print_field_values assumes that
the type it is given ("TYPE_FIELD_TYPE (type, i)" here), is also
a record type. However, that's not the case, since RETVAL is
an enum. That eventually leads GDB to a NULL type when trying to
extract fields out of the enum, which then leads to a SEGV when
trying to dereference it.
Ideally, we'd want to be a little more careful in identifying
wrapper fields, by enhancing ada_is_wrapper_field to be a little
more complete in its analysis of the field name before declaring
it a variant record wrapper. However, it's not super easy to do
so, considering that the choices can be combined together when
complex choices are used. Eg:
-- [...] the choice 1 .. 4 | 7 | -10 would be represented by
-- R1T4S7S10m
Given that we are working towards getting rid of GNAT encodings,
which means that the above will eventually disappear, we took
the more pragmatic approach is just treating RETVAL as a special
case.
gdb/ChangeLog:
* ada-lang.c (ada_is_wrapper_field): Add special handling
for fields called "RETVAL".
gdb/testsuite/ChangeLog:
* gdb.ada/fin_fun_out: New testcase.
Some of the source code for the test cases in the GDB testsuite
reside in .S files containing assembly code. These files typically
define a symbol - such as main - which may, depending on the target,
require a prefix such as underscore.
For example, gdb.dwarf2/dw-compdir-oldgcc.S defines the symbol main:
main: .globl main
Some targets, such as rx-elf, require main to have an underscore
prefix. (If it doesn't, a linker error results due to not being able
to find _main required by crt0.o.) So, instead, the above should look
like this for rx-elf and other targets with this same requirement:
_main: .globl _main
This patch defines a new tcl proc in lib/gdb named
gdb_target_symbol_prefix_flags_asm. This proc returns a string
which will - assuming everything else is wired up correctly - cause
-DSYMBOL_PREFIX=_ to be passed on the command line to the compiler.
The test cases are augmented with a macro definition for SYMBOL
as follows:
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
#ifdef SYMBOL_PREFIX
# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
#else
# define SYMBOL(str) str
#endif
Symbols, such as main shown in the example earlier are then wrapped
with SYMBOL like this:
SYMBOL(main): .globl SYMBOL(main)
The net effect will be to add a prefix for those targets which need
it and add no prefix for those targets which do not.
It should be noted that there was already a proc in lib/gdb.exp
called gdb_target_symbol_prefix_flags. It still exists, but has
been significantly rewritten. (There is only one small difference
between the two versions.)
That proc used to explicitly list targets which were known to
require an underscore prefix. This is no longer done; the recently
added proc, gdb_target_symbol_prefix, is now invoked to dynamically
discover whether or not a prefix is required for that particular
target.
The difference between gdb_target_symbol_prefix_flags_asm
and gdb_target_symbol_prefix_flags is that the former returns
a bare prefix while the latter returns the prefix enclosed in
double quotes. I.e. assuming that the discovered prefix is
underscore, gdb_target_symbol_prefix_flags_asm returns:
additional_flags=-DSYMBOL_PREFIX=_
while gdb_target_symbol_prefix_flags returns:
additional_flags=-DSYMBOL_PREFIX="_"
The double-quoted version is not suitable for using with .S files
containing assembly code; there is no way to strip the double quotes
using C preprocessor constructs.
It would be possible to use the bare (non double quoted) version in
C source code. However, the supporting macros become more complicated
and therefore more difficult to maintain.
gdb/testsuite/ChangeLog:
* lib/gdb (gdb_target_symbol_prefix_flags_asm): New proc.
(gdb_target_symbol_prefix_flags): Define in terms of _asm
version.
* gdb.arch/i386-float.exp, gdb.arch/i386-permbkpt.exp,
gdb.dwarf2/dw2-canonicalize-type.exp,
gdb.dwarf2/dw2-compdir-oldgcc.exp, gdb.dwarf2/dw2-minsym-in-cu.exp,
gdb.dwarf2/dw2-op-stack-value.exp, gdb.dwarf2/dw2-unresolved.exp,
gdb.dwarf2/fission-reread.exp, gdb.dwarf2/pr13961.exp: Use flags
provided by gdb_target_symbol_prefix_flags_asm.
* gdb.dwarf2/dw2-canonicalize-type.S, gdb.dwarf2/dw2-compdir-oldgcc.S,
testsuite/gdb.dwarf2/dw2-minsym-in-cu.S,
testsuite/gdb.dwarf2/dw2-unresolved-main.c,
testsuite/gdb.dwarf2/dw2-unresolved.S, gdb.dwarf2/fission-reread.S,
gdb.dwarf2/pr13961.S: Define and use SYMBOL macro (and supporting
macros where needed). Use this macro for symbols which require
the prefix provided by SYMBOL_PREFIX.
Some of the tests in gdb.dwarf2 which use Dwarf::assemble refer to
(minimal/linker) symbols created in the course of building a small
test program. Some targets use a prefix such as underscore ("_") on
these symbols. Many of the tests in gdb.dwarf2 do not take this into
account. As a consequence, these tests fail to build, resulting
either in failures or untested testcases.
Here is an example from gdb.dwarf2/dw2-regno-invalid.exp:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc main DW_FORM_addr}
{high_pc main+0x10000 DW_FORM_addr}
} {
...
}
For targets which require an underscore prefix on linker symbols,
the two occurrences of "main" would have to have a prepended underscore,
i.e. _main instead of main.
For the above case, a call to the new proc gdb_target_symbol is used
prepend the correct prefix to the symbol. I.e. the above code is
rewritten (as shown in the patch) as follows:
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
{low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
} {
...
}
I also found it necessary to make an adjustment to lib/dwarf.exp so that
expressions of more than just one list element can be used in DW_TAG_...
constructs. Both atomic-type.exp and dw2-bad-mips-linkage-name.exp require
this new functionality.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_target_symbol_prefix, gdb_target_symbol):
New procs.
* lib/dwarf.exp (_handle_DW_TAG): Handle attribute values,
representing expressions, of more than one list element.
* gdb.dwarf2/atomic-type.exp (Dwarf::assemble): Use gdb_target_symbol
to prepend linker symbol prefix to f.
* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Likewise, for
table_1 and table_2.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp (Dwarf::assemble):
Likewise, for f and g.
* gdb.dwarf2/dw2-ifort-parameter.exp (Dwarf::assemble): Likewise,
for ptr.
* gdb.dwarf2/dw2-regno-invalid.exp (Dwarf::assemble): Likewise,
for main.
* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Likewise, for
table_1_ptr and table_2_ptr.
allocate (vla1 (5)) ! vla1-not-allocated
l = allocated(vla1) ! vla1-allocated <------------------
Expecting: ^(510-data-evaluate-expression vla1[^M
]+)?(510\^done,value="\(0, 0, 0, 0, 0\)"[^M
]+[(]gdb[)] ^M
[ ]*)
510-data-evaluate-expression vla1^M
510^done,value="(1.82987403e-09, 7.8472714e-44, 1.82987403e-09, 7.8472714e-44, 2.67929926e+20)"^M
(gdb) ^M
FAIL: gdb.mi/mi-vla-fortran.exp: evaluate allocated vla
gcc-4.9.2-6.fc21.x86_64
I think some older gfortran did initialize allocated memory but that is an
unspecified behavior. I haven't found any initialization mentioned
in Fortran 90 standard (draft) and it is also clearly stated here:
https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/268786
Initialization to 0 of allocated arrays (of integers) is an
implementation issue. i.e. do not rely on it.
Joel Brobecker wrote:
I am wondering if it might be better to just relax instead the regexp to allow
any number rather than just remove the test altogether. The test allows us to
verify that, as soon as we're past the "allocate" call, we no longer say "not
allocated".
gdb/testsuite/ChangeLog
2015-11-03 Jan Kratochvil <jan.kratochvil@redhat.com>
Joel Brobecker <brobecker@adacore.com>
* gdb.mi/mi-vla-fortran.exp (evaluate allocated vla): Permit any data.
gdb/ChangeLog:
PR/18376
* gdb/configure.tgt: Add linux-record.o to s390*-linux.
* gdb/s390-linux-tdep.c: #include "linux-record.h", "record-full.h"
(s390_linux_record_tdep): New static global variable.
(s390x_linux_record_tdep): New static global variable.
(s390_all_but_pc_registers_record): New function.
(s390_canonicalize_syscall): New function.
(s390_linux_syscall_record): New function.
(s390_linux_record_signal): New function.
(s390_record_calc_disp_common): New function.
(s390_record_calc_disp): New function.
(s390_record_calc_disp_vsce): New function.
(s390_record_calc_rl): New function.
(s390_record_gpr_g): New function.
(s390_record_gpr_h): New function.
(s390_record_vr): New function.
(s390_process_record): New function.
(s390_init_linux_record_tdep): New function.
(s390_gdbarch_init): Fill record function slots.
gdb/testsuite/ChangeLog:
* gdb.reverse/s390-mvcle.c: New test.
* gdb.reverse/s390-mvcle.exp: New file.
* lib/gdb.exp: Enable reverse tests on s390*-linux.
The breakpoint presented in the return statement was not activated while
compiling the test with gcc 4.9.2. Added a dummy statement to allow the
breakpoint again.
2015-10-14 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/testsuite:
* i386-mpx-map.c (foo): Add dummy statement to trigger breakpoint.
Change-Id: I5293ca1c7f82a631e1e41cb650c30dd2d09ef3c2
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
Adapts tests to use actual GCC flags, previous used flags were
related to an internal GCC release.
2015-06-18 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/testsuite:
* gdb.arch/i386-mpx-map.exp (comp_flags): Use released GCC flags.
* gdb.arch/i386-mpx.exp (comp_flags): Use released GCC flags.
Change-Id: Id4c4551693a8df071ed4b71bb5dfb46a526ed5db
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
continue_to_breakpoint always continues to the next breakpoint, not to the
one named in parameter. This rendered the tests effectively useless, since
marker2 was never reached.
gdb/testsuite/ChangeLog:
* gdb.reverse/fstatat-reverse.exp: Set breakpoint on marker1 after
reaching marker2.
* gdb.reverse/getresuid-reverse.exp: Likewise.
* gdb.reverse/pipe-reverse.exp: Likewise.
* gdb.reverse/readv-reverse.exp: Likewise.
* gdb.reverse/recvmsg-reverse.exp: Likewise.
* gdb.reverse/time-reverse.exp: Likewise.
* gdb.reverse/waitpid-reverse.exp: Likewise and add KFAILs.
Nowadays, test gdb.threads/wp-replication.exp uses a while loop to
repeatedly insert HW watchpoint, resume and check no error message
coming out, in order to count HW watchpoints There are some
drawbacks in this way,
- the loop could be endless. I think this is use to making trouble
to S/390, since we had such comment
# Some targets (like S/390) behave as though supporting
# unlimited hardware watchpoints. In this case we just take a
# safe exit out of the loop.
I hit this today too because a GDB internal error is triggered
on "continue" in the loop, and $done is 0 invariantly, so the loop
can't end.
- the code counting hardware watchpoint is too complicated. We can
use "set breakpoint always-inserted on" to get the result of inserting
HW watchpoint without resuming the inferior. In this way,
watch_count_done and empty_cycle in c file is no longer needed.
In this patch, I change to use "set breakpoint always-inserted on" trick,
and only iterate $NR_THREADS times, to count the HW watchpoint. In this
way, the loop can't be endless, and GDB doesn't need to resume the inferior.
gdb/testsuite:
2015-10-30 Yao Qi <yao.qi@linaro.org>
* gdb.threads/wp-replication.c (watch_count_done): Remove.
(empty_cycle): Remove.
(main): Don't call empty_cycle. Don't use watch_count_done.
* gdb.threads/wp-replication.exp: Don't set breakpoint on
empty_cycle. Rewrite the code counting HW watchpoints.
gdb/testsuite/ChangeLog:
* gdb.reverse/fstatat-reverse.c: New test.
* gdb.reverse/fstatat-reverse.exp: New file.
* gdb.reverse/getresuid-reverse.c: New test.
* gdb.reverse/getresuid-reverse.exp: New file.
* gdb.reverse/pipe-reverse.c: New test.
* gdb.reverse/pipe-reverse.exp: New file.
* gdb.reverse/readv-reverse.c: New test.
* gdb.reverse/readv-reverse.exp: New file.
* gdb.reverse/recvmsg-reverse.c: New test.
* gdb.reverse/recvmsg-reverse.exp: New file.
* gdb.reverse/time-reverse.c: New test.
* gdb.reverse/time-reverse.exp: New file.
* gdb.reverse/waitpid-reverse.c: New test.
* gdb.reverse/waitpid-reverse.exp: New file.
Running ./gdb.ada/access_to_packed_array.exp ...
ERROR: tcl error sourcing ./gdb.ada/access_to_packed_array.exp.
ERROR: extra characters after close-quote
while executing
"gdb_test "print pack.a" "\\(0 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\)")"
(file "./gdb.ada/access_to_packed_array.exp" line 29)
invoked from within
"source ./gdb.ada/access_to_packed_array.exp"
("uplevel" body line 1)
invoked from within
"uplevel #0 source ./gdb.ada/access_to_packed_array.exp"
invoked from within
"catch "uplevel #0 source $test_file_name""
Unrelated to the typos I have changed the print expectations s/"x"/" = x"/
as for example expectation "3" should not match " = 43".
2015-10-27 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.ada/access_to_packed_array.exp: Fix typos erroring the testfile.
gdb/ChangeLog:
PR python/18938
* cli/cli-cmds (source_script_fron_sctream): New arg file_to_open.
All callers updated.
gdb/testsuite/ChangeLog:
* gdb.python/python.exp: Add test for symlink from .py file to .notpy
file.
Since 7.4, gdb doesn't allow calling .fields() on a function type, even
though the documentation states it should return a list corresponding to
the function's parameters. This patch restores the intended behaviour
and adds a test for it.
Reg-tested on Arch Linux x86-64.
gdb/ChangeLog:
PR python/18073
* python/py-type.c (typy_get_composite): Allow returning a
function type.
gdb/testsuite/ChangeLog:
PR python/18073
* gdb.python/py-type.c (C::a_method): New.
(C::a_const_method): New.
(C::a_static_method): New.
(a_function): New.
* gdb.python/py-type.exp (test_fields): Test getting fields
from function and method.
Fortran provide types whose values may be dynamically allocated
or associated with a variable under explicit program control.
The purpose of this commit is:
* to read allocated/associated DWARF tags and store them in
the dynamic property list of main_type.
* enable GDB to print the value of a dynamic array in Fortran
in case the type is allocated or associated (pointer to
dynamic array).
Examples:
(gdb) p vla_not_allocated
$1 = <not allocated>
(gdb) p vla_allocated
$1 = (1, 2, 3)
(gdb) p vla_ptr_not_associated
$1 = <not associated>
(gdb) p vla_ptr_associated
$1 = (1, 2, 3)
Add basic test coverage for most dynamic array use-cases in Fortran.
The commit contains the following tests:
* Ensure that values of Fortran dynamic arrays
can be evaluated correctly in various ways and states.
* Ensure that Fortran primitives can be evaluated
correctly when used as a dynamic array.
* Dynamic arrays passed to subroutines and handled
in different ways inside the routine.
* Ensure that the ptype of dynamic arrays in
Fortran can be printed in GDB correctly.
* Ensure that dynamic arrays in different states
(allocated/associated) can be evaluated.
* Dynamic arrays passed to functions and returned from
functions.
* History values of dynamic arrays can be accessed and
printed again with the correct values.
* Dynamic array evaluations using MI protocol.
* Sizeof output of dynamic arrays in various states.
The patch was tested using the test suite on Ubuntu 12.04 64bit.
gdb/ChangeLog:
* dwarf2read.c (set_die_type): Add read of
DW_AT_allocated and DW_AT_associated.
* f-typeprint.c: New include of typeprint.h
(f_print_type): Add check for allocated/associated
status of type.
(f_type_print_varspec_suffix): Add check for
allocated/associated status of type.
* gdbtypes.c (create_array_type_with_stride):
Add check for valid data location of type in
case allocated or associated attributes are set.
Length of an array should be only calculated if
allocated or associated is resolved as true.
(is_dynamic_type_internal): Add check for allocated/
associated.
(resolve_dynamic_array): Evaluate allocated/associated
properties.
* gdbtypes.h (enum dynamic_prop_node_kind): <DYN_PROP_ALLOCATED>
<DYN_PROP_ASSOCIATED>: New enums.
(TYPE_ALLOCATED_PROP, TYPE_ASSOCIATED_PROP): New macros.
(type_not_allocated): New function.
(type_not_associated): New function.
* valarith.c (value_subscripted_rvalue): Add check for
allocated/associated.
* valprint.c: New include of typeprint.h.
(valprint_check_validity): Add check for allocated/associated.
(value_check_printable): Add check for allocated/
associated.
* typeprint.h (val_print_not_allocated): New function.
(val_print_not_associated): New function.
* typeprint.c (val_print_not_allocated): New function.
(val_print_not_associated): New function.
gdb/testsuite/ChangeLog:
* gdb.fortran/vla-alloc-assoc.exp: New file.
* gdb.fortran/vla-datatypes.exp: New file.
* gdb.fortran/vla-datatypes.f90: New file.
* gdb.fortran/vla-history.exp: New file.
* gdb.fortran/vla-ptype-sub.exp: New file.
* gdb.fortran/vla-ptype.exp: New file.
* gdb.fortran/vla-sizeof.exp: New file.
* gdb.fortran/vla-sub.f90: New file.
* gdb.fortran/vla-value-sub-arbitrary.exp: New file.
* gdb.fortran/vla-value-sub-finish.exp: New file.
* gdb.fortran/vla-value-sub.exp: New file.
* gdb.fortran/vla-value.exp: New file.
* gdb.fortran/vla-ptr-info.exp: New file.
* gdb.mi/mi-vla-fortran.exp: New file.
* gdb.mi/vla.f90: New file.
Nowadays, in the range-stepping tests, we check not only the number of
vCont;r packets but also the number of vCont;s packets, because we think
the remote target which can do range stepping must support single step.
However, if we turn displaced stepping on, the remote target (GDBserver)
can do range stepping, and support single step, but GDB may decide to
resume instructions in the scratchpad rather than single step them one
by one for displaced stepping. For example, when aarch64 GDB debugs
arm linux program with aarch64 GDBserver, GDBserver supports both range
stepping and single step, but GDB (with the gdbarch for arm-linux)
decides resume instructions in the scratchpad, so in the RSP traffic,
there is no vCont;s packet at all, and some range-stepping.exp tests
fail,
FAIL: gdb.base/range-stepping.exp: multi insns: next: vCont;s=1 vCont;r=1
This patch is to get rid of the checking to the number of vCont;s in
exec_cmd_expect_vCont_count.
gdb/testsuite:
2015-10-21 Yao Qi <yao.qi@linaro.org>
* lib/range-stepping-support.exp (exec_cmd_expect_vCont_count):
Remove argument exp_vCont_s.
* gdb.base/range-stepping.exp: Callers updated.
* gdb.trace/range-stepping.exp: Likewise.
The existing logic was simply to flip syscall entry/return state when a
syscall trap was seen, and even then only with active 'catch syscall'.
That can get out of sync if 'catch syscall' is toggled at odd times.
This patch updates the entry/return state for all syscall traps,
regardless of catching state, and also updates known syscall state for
other kinds of traps. Almost all PTRACE_EVENT stops are delivered from
the middle of a syscall, so this can act like an entry. Every other
kind of ptrace stop is only delivered outside of syscall event pairs, so
marking them ignored ensures the next syscall trap looks like an entry.
Three new test scenarios are added to catch-syscall.exp:
- Disable 'catch syscall' from an entry to deliberately miss the return
event, then re-enable to make sure a new entry is recognized.
- Enable 'catch syscall' for the first time from a vfork event, which is
a PTRACE_EVENT_VFORK in the middle of the syscall. Make sure the next
syscall event is recognized as the return.
- Make sure entry and return are recognized for an ENOSYS syscall. This
is to defeat a common x86 hack that uses the pre-filled ENOSYS return
value as a sign of being on the entry side.
gdb/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* linux-nat.c (linux_handle_syscall_trap): Always update entry/
return state, even when not actively catching syscalls at all.
(linux_handle_extended_wait): Mark syscall_state like an entry.
(wait_lwp): Set syscall_state ignored for other traps.
(linux_nat_filter_event): Likewise.
gdb/testsuite/ChangeLog:
2015-10-19 Josh Stone <jistone@redhat.com>
* gdb.base/catch-syscall.c: Include <sched.h>.
(unknown_syscall): New variable.
(main): Trigger a vfork and an unknown syscall.
* gdb.base/catch-syscall.exp (vfork_syscalls): New variable.
(unknown_syscall_number): Likewise.
(check_call_to_syscall): Accept an optional syscall pattern.
(check_return_from_syscall): Likewise.
(check_continue): Likewise.
(test_catch_syscall_without_args): Check for vfork and ENOSYS.
(test_catch_syscall_skipping_return): New test toggling off 'catch
syscall' to step over the syscall return, then toggling back on.
(test_catch_syscall_mid_vfork): New test turning on 'catch syscall'
during a PTRACE_EVENT_VFORK stop, in the middle of a vfork syscall.
(do_syscall_tests): Call test_catch_syscall_without_args and
test_catch_syscall_mid_vfork.
(test_catch_syscall_without_args_noxml): Check for vfork and ENOSYS.
(fill_all_syscalls_numbers): Initialize unknown_syscall_number.
The func command, available when starting gdb in dbx mode, is supposed
to take a function name and locate the frame for that function in the
stack. This has been broken for a while due to an invalid check of the
arguments within the worker function. Fixed in this commit.
gdb/ChangeLog:
* stack.c (func_command): Return early when there is no ARG
string.
gdb/testsuite/ChangeLog:
* gdb.base/dbx.exp (test_func): Remove xfails, update expected
results.
This patch adds a new test case which uses gdb.arch/insn-reloc.c too
to test displaced stepping. Nowadays, tests are for x86, x86_64 and
aarch64.
gdb/testsuite:
2015-10-12 Yao Qi <yao.qi@linaro.org>
* gdb.arch/disp-step-insn-reloc.exp: New test case.
This patch adds more tests in gdb.arch/insn-reloc.c to cover
instruction BL and cover B.CON when CON is false. These new added
tests can be used for displaced stepping too.
gdb/testsuite:
2015-10-12 Yao Qi <yao.qi@linaro.org>
* gdb.arch/insn-reloc.c (can_relocate_bcond): Rename to ...
(can_relocate_bcond_true): ... it.
(can_relocate_bcond_false): New function.
(foo): Likewise.
(can_relocate_bl): Likewise.
(testcases) [__aarch64__]: Add can_relocate_bcond_false and
can_relocate_bl.
Assume foo_array is a pointer to a C structure. GDB must evaluate the
following expression properly, but it does not currently:
(gdb) print 1 && &foo_array[1].a
Attempt to take address of value not located in memory.
The problem is that in EVAL_AVOID_SIDE_EFFECTS mode,
eval.c:evaluate_subexp_standard always returns a not_lval value as the
result for a STRUCTOP_STRUCT operation. As a consequence, the rest of
the code believes that one cannot take the address of the returned
value.
This patch fixes STRUCTOP_STRUCT handling so that the VALUE_LVAL
attribute for the returned value is properly initialized. After this
change, the above session becomes:
(gdb) print 1 && &foo_array[1].a
$1 = 1
gdb/ChangeLog:
* eval.c (evaluate_subexp_standard) <STRUCTOP_STRUCT>: If
EVAL_AVOID_SIDE_EFFECTS mode, forward the VALUE_LVAL attribute
to the returned value.
gdb/testsuite/ChangeLog:
* gdb.base/nested-addr.c: New file.
* gdb.base/nested-addr.exp: New testcase.
Tested on x86_64-linux, no regression.
The vdso.exp test checks that we can access the VDSO memory when replaying.
Depending on the line information generated by the compiler, runto_main may run
to the line marked with bp.1 or stop before that line. The test incorrectly
assumes that it will always run to the marked line and fails if it doesn't.
The test does not really care about what is traced. It does care that GDB is
replaying when capturing the second disassemble output.
Reflect that in the test by ignoring the output of the stepping and record goto
begin commands and by checking that GDB is actually replaying.
testsuite/
* gdb.btrace/vdso.c (main): Remove breakpoint markers.
* gdb.btrace/vdso.exp: Change stepping command to "next" and ignore
its output. Ignore the output of "record goto begin" and instead
check that GDB is replaying.
This patch fixes this racy failure, with the native-extended-gdbserver
board:
(gdb) run
Starting program: build/gdb/testsuite/outputs/gdb.base/a2-run/a2-run
Remote debugging from host 127.0.0.1
Process build/gdb/testsuite/outputs/gdb.base/a2-run/a2-run created; pid = 23832
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
Reading /lib64/libm.so.6 from remote target...
Reading /lib64/libc.so.6 from remote target...
[Inferior 1 (process 23832) exited with code 01]
(gdb) FAIL: gdb.base/a2-run.exp: run "a2-run" with no args
PASS: gdb.base/a2-run.exp: no spurious messages at program exit
run 5
Starting program: build/gdb/testsuite/outputs/gdb.base/a2-run/a2-run 5
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
usage: factorial <number>
Child exited with status 1
Note that the output is correct; it's just that inferior output
appeared after gdb's output, and the test doesn't handle that
correctly.
This comment isn't really correct, unfortunately:
# waiting. If we had already seen the status wrapper exit,
# gdb_test_multiple/expect has no spawn ids left, and thus
# returns.
That's true of expect in general, but I had missed / forgot that
gdb_test_multiple internally has extra matches using "-i
$gdb_spawn_id", so even if the caller clears all the indirect spawn id
lists, gdb_test_multiple will continue waiting.
So do a conditional exp_continue manually instead.
gdb/testsuite/ChangeLog:
2015-10-09 Pedro Alves <palves@redhat.com>
* gdb.base/a2-run.exp (maybe_exp_continue): New procedure.
(top level): Use it in the run with no args test.
gdb/ChangeLog:
* d-exp.y: (UnaryExpression): Support `type.sizeof' expressions.
(PostfixExpression): Support `expr.sizeof' expressions.
(PrimaryExpression): Support `typeof(expr)' expressions.
gdb/testsuite/ChangeLog:
* gdb.dlang/properties.exp: New file.
2015-10-02 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.dwarf2/staticvirtual.exp: Generalize regexp so it can match
whether or not address 0x1000 is mapped on the target.
I noticed this while working on the test case. I believe it would make
sense to skip running the tests if the binary failed to build. Although
I would understand the opposite argument: if the binary does not build
for some reason, we probably want to know about it, and some catastrophic
failures in the tests might alarm us better than a timid "UNTESTED".
gdb/testsuite/ChangeLog:
* gdb.python/py-type.exp: Do not run tests if binaries fail to
build.
If the atomic section in x86-tsx.S is aborted, the tsx.exp test will fail
even if the traced output is actually correct.
Consider abort scenarios in the test.
testsuite/
* gdb.btrace/tsx.exp: Consider multiple correct outputs in the record
instruction-history test.
2015-09-24 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.cp/classes.exp (test_enums): Generalize regexp to allow
short or char as base type.
Compilers can materialize renamings of arrays (or of accesses to arrays)
in Ada into variables whose types are references to the actual array
types. Before this change, trying to use such an array renaming yielded
an error in GDB:
(gdb) print my_array(1)
cannot subscript or call a record
(gdb) print my_array_ptr(1)
cannot subscript or call something of type `(null)'
This behavior comes from bad handling for array renamings, in particular
the OP_FUNCALL expression operator handling from ada-lang.c
(ada_evaluate_subexp): in one place we turn the reference into a
pointer, but the code that follows expect the value to be an array.
This patch fixes how we handle references in call/subscript evaluation
so that we turn these references into the actual array values instead of
pointers to them.
gdb/ChangeLog:
* ada-lang.c (ada_evaluate_subexp) <OP_FUNCALL>: When the input
value is a reference, actually dereference it in order to get
the underlying value.
gdb/testsuite/ChangeLog:
* gdb.ada/array_ptr_renaming.exp: New testcase.
* gdb.ada/array_ptr_renaming/foo.adb: New file.
* gdb.ada/array_ptr_renaming/pack.ads: New file.
Tested on x86_64-linux, no regression.
When installing a fast tracepoint, we create a jump pad with a
spin-lock. This way, only one thread can collect a given tracepoint at
any time. This test case checks that this lock actually works as
expected.
This test works by creating a function which overrides the in-process
agent library's gdb_collect function. On start up, GDBserver will ask
GDB with the 'qSymbol' packet about symbols present in the inferior.
GDB will reply with the gdb_agent_gdb_collect function from the test
case instead of the one from the agent.
gdb/testsuite/ChangeLog:
* gdb.trace/ftrace-lock.c: New file.
* gdb.trace/ftrace-lock.exp: New file.
This test case makes sure that relocating PC relative instructions does
not change their behaviors. All PC relative AArch64 instructions are
covered. While call and jump (32 bit relative) instructions are covered
on x86.
The test case creates a static array of function pointers for each
supported architecture. Each function in this array tests a specific
instruction using inline assembly. They all need to contain a symbol in
the form of 'set_point\[0-9\]+' and finish by either calling pass or
fail. The number of 'set_pointN' needs to go from 0 to
(ARRAY_SIZE - 1).
The test will:
- look up the number of function pointers in the static array.
- set fast tracepoints on each 'set_point\[0-9\]+' symbol, one in each
functions from 0 to (ARRAY_SIZE - 1).
- run the trace experiment and make sure the pass function is called for
every function.
gdb/testsuite/ChangeLog:
* gdb.arch/insn-reloc.c: New file.
* gdb.arch/ftrace-insn-reloc.exp: New file.
bfd/ChangeLog:
* targets.c (enum bfd_flavour): Add comment.
(bfd_flavour_name): New function.
* bfd-in2.h: Regenerate.
gdb/ChangeLog:
* findvar.c (default_read_var_value) <LOC_UNRESOLVED>: Include the
kind of minimal symbol in the error message.
* objfiles.c (objfile_flavour_name): New function.
* objfiles.h (objfile_flavour_name): Declare.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-bad-unresolved.c: New file.
* gdb.dwarf2/dw2-bad-unresolved.exp: New file.
2015-09-18 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.mi/mi-pending.exp: Don't use directory prefix when setting
the pending breakpoint. Remove timeout override for "Run till
MI pending breakpoint on pendfunc3 on thread 2" test.
In all-stop mode, record btrace maintains the old behaviour of an implicit
scheduler-locking on.
Now that we added a scheduler-locking mode to model this old behaviour, we
don't need the respective code in record btrace anymore. Remove it.
For all-stop targets, step inferior_ptid and continue other threads matching
the argument ptid. Assert that inferior_ptid matches the argument ptid.
This should make record btrace honour scheduler-locking.
gdb/
* record-btrace.c (record_btrace_resume): Honour scheduler-locking.
testsuite/
* gdb.btrace/multi-thread-step.exp: Test scheduler-locking on, step,
and replay.
This patch adds a test case for tracepoints with a condition expression.
Each case will test a condition against the number of frames that should
have been traced. Some of these tests fail on x86_64 and others on
i386, which have been marked as known failures for now, see PR/18955.
gdb/testsuite/ChangeLog:
2015-09-17 Pierre Langlois <pierre.langlois@arm.com>
Yao Qi <yao.qi@linaro.org>
* gdb.trace/trace-condition.c: New file.
* gdb.trace/trace-condition.exp: New file.
This patch fixes the argument passed to compiled_cond. It should be
regs buffer instead of tracepoint_hit_ctx. Test case is added as
well for testing compiled-cond.
gdb/gdbserver/ChangeLog
2015-09-16 Wei-cheng Wang <cole945@gmail.com>
* tracepoint.c (eval_result_type): Change prototype.
(condition_true_at_tracepoint): Fix argument to compiled_cond.
gdb/testsuite/ChangeLog
2015-09-16 Wei-cheng Wang <cole945@gmail.com>
* gdb.trace/ftrace.exp: (test_ftrace_condition) New function
for testing bytecode compilation.
On software single-step targets that don't support displaced stepping,
threads keep hitting each other's single-step breakpoints, and then
GDB needs to pause all threads to step past those. The end result is
that progress in the main thread will be slower and it may take a bit
longer for the signal to be queued. This patch bumps the timeout on
such targets.
gdb/testsuite/ChangeLog:
2015-09-16 Pedro Alves <palves@redhat.com>
Sandra Loosemore <sandra@codesourcery.com>
* gdb.threads/non-stop-fair-events.c (timeout): New global.
(SECONDS): Redefine.
(main): Call pthread_kill and alarm early.
* gdb.threads/non-stop-fair-events.exp: Probe displaced stepping
support.
(test): If the target can't hardware step and doesn't support
displaced stepping, increase the timeout.
If we enable infrun debug running this test, it quickly fails with a
full expect buffer. That can be simply handled with a couple
exp_continues. As it's annoying to hack this every time we need to
debug the test, this patch adds bits to enable debugging support
easily, with a one-line change.
And then, if any iteration of the test fails, we end up with a long
cascade of time outs. Just bail out when we see the first fail.
gdb/testsuite/
2015-09-16 Pedro Alves <palves@redhat.com>
* gdb.threads/non-stop-fair-events.exp (gdb_test_no_anchor)
(enable_debug): New procedures.
(test): Use them. Bail out if waiting for threads fails.
(top level): Bail out if a test fails.
This patch adds gdb.asm/aarch64.inc, so asm-source.exp isn't skipped
on aarch64 any more.
gdb/testsuite:
2015-09-16 Yao Qi <yao.qi@linaro.org>
* gdb.asm/asm-source.exp: Set asm-arch for
aarch64*-*-* target.
* gdb.asm/aarch64.inc: New file.
This change is relevant only for standard DWARF (as opposed to the GNAT
encodings extensions): at the time of writing it only makes a difference
with GCC patches that are to be integrated: see the patch series
submission at
<https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01353.html>.
Given the following Ada declarations:
subtype Small_Int is Natural range 0 .. 100;
type R_Type (L : Small_Int := 0) is record
S : String (1 .. L);
end record;
type A_Type is array (Natural range <>) of R_Type;
A : A_Type := (1 => (L => 0, S => ""),
2 => (L => 2, S => "ab"));
Before this change, we would get the following GDB session:
(gdb) ptype a
type = array (1 .. 2) of foo.r_type <packed: 838-bit elements>
This is wrong: "a" is not a packed array. This output comes from the
fact that, because R_Type has a dynamic size (with a maximum), the
compiler has to describe in the debugging information the size allocated
for each array element (i.e. the stride, in DWARF parlance: see
DW_AT_byte_stride). Ada type printing currently assumes that arrays
with a stride are packed, hence the above output.
In practice, GNAT never performs bit-packing for arrays that contain
variable-sized elements. Leveraging this fact, this patch enhances type
printing so that ptype does not pretend that arrays are packed when they
have a stride and they contain dynamic elements. After this change, we
get the following expected output:
(gdb) ptype a
type = array (1 .. 2) of foo.r_type
gdb/ChangeLog:
* ada-typeprint.c (print_array_type): Do not describe arrays as
packed when they embed dynamic elements.
gdb/testsuite/ChangeLog:
* gdb.ada/array_of_variable_length.exp: New testcase.
* gdb.ada/array_of_variable_length/foo.adb: New file.
* gdb.ada/array_of_variable_length/pck.adb: New file.
* gdb.ada/array_of_variable_length/pck.ads: New file.
Tested on x86_64-linux, no regression.
clang names the local variable t_structs_a.buf.
gdb/testsuite/ChangeLog:
* gdb.base/callfuncs.exp (do_function_calls): Handle clang naming
of function static local variable.
ppc64le loses control when stepping between two PLT-called functions inside
a shared library:
29 shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
^M
Program received signal SIGABRT, Aborted.^M
0x00003fffb7cbe578 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56^M
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);^M
(gdb) FAIL: gdb.base/solib-intra-step.exp: second-hit
->
29 shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
shlib_second () at ./gdb.base/solib-intra-step-lib.c:23^M
23 abort (); /* second-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: second-hit
This is because gdbarch_skip_trampoline_code() will resolve the final function
as shlib_second+0 and place there the breakpoint, but ld.so will jump after
the breakpoint - at shlib_second+8 - as it is ELFv2 local symbol optimization:
Dump of assembler code for function shlib_second:
0x0000000000000804 <+0>: addis r2,r12,2
0x0000000000000808 <+4>: addi r2,r2,30668
0x000000000000080c <+8>: mflr r0
Currently gdbarch_skip_entrypoint() has been called in skip_prologue_sal() and
fill_in_stop_func() but that is not enough. I believe
gdbarch_skip_entrypoint() should be called after every
gdbarch_skip_trampoline_code().
gdb/ChangeLog
2015-09-15 Jan Kratochvil <jan.kratochvil@redhat.com>
* linespec.c (minsym_found): Call gdbarch_skip_entrypoint.
* ppc64-tdep.c (ppc64_skip_trampoline_code): Rename to ...
(ppc64_skip_trampoline_code_1): ... here.
(ppc64_skip_trampoline_code): New wrapper function.
* symtab.c (find_function_start_sal): Call gdbarch_skip_entrypoint.
gdb/testsuite/ChangeLog
2015-09-15 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.opt/solib-intra-step-lib.c: New file.
* gdb.opt/solib-intra-step-main.c: New file.
* gdb.opt/solib-intra-step.exp: New file.
gdb.threads/non-ldr-exc-3.exp is sometimes failing like this:
[Switching to Thread 6831.6832]
Breakpoint 2, thread_execler (arg=0x0) at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/non-ldr-exc-3.c:41
41 if (execl (image, image, argv1, NULL) == -1) /* break-here */
PASS: gdb.threads/non-ldr-exc-3.exp: lock-sched=on,non-stop=off: continue to breakpoint
(gdb) set scheduler-locking on
(gdb) FAIL: gdb.threads/non-ldr-exc-3.exp: lock-sched=on,non-stop=off: set scheduler-locking on
The problem is that the gdb_test_multiple is missing the prompt
anchor. The problem was introduced by 2fd33e9448. This reverts the
hunk that introduced the problem, reverting back to
gdb_continue_to_breakpoint.
gdb/testsuite/ChangeLog:
2015-09-15 Pedro Alves <palves@redhat.com>
* gdb.threads/non-ldr-exc-3.exp (do_test): Use
gdb_continue_to_breakpoint instead of gdb_test_multiple.
This patch, relative to a tree with
https://sourceware.org/ml/gdb-patches/2015-08/msg00295.html, fixes
issues/crashes that trigger if something unexpected happens during a
hook-stop.
E.g., if the inferior disappears while running the hook-stop, we hit
failed assertions:
(gdb) define hook-stop
Type commands for definition of "hook-stop".
End with a line saying just "end".
>kill
>end
(gdb) si
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
/home/pedro/gdb/mygit/build/../src/gdb/thread.c:88: internal-error: inferior_thread: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
I noticed that if a hook-stop issues a synchronous execution command,
we print the same stop event twice:
(gdb) define hook-stop
Type commands for definition of "hook-stop".
End with a line saying just "end".
>si
>end
(gdb) si
0x000000000040074a 42 args[i] = 1; /* Init value. */ <<<<<<< once
0x000000000040074a 42 args[i] = 1; /* Init value. */ <<<<<<< twice
(gdb)
In MI:
*stopped,reason="end-stepping-range",frame={addr="0x000000000040074a",func="main",args=[],file="threads.c",fullname="/home/pedro/gdb/tests/threads.c",line="42"},thread-id="1",stopped-threads="all",core="0"
*stopped,reason="end-stepping-range",frame={addr="0x000000000040074a",func="main",args=[],file="threads.c",fullname="/home/pedro/gdb/tests/threads.c",line="42"},thread-id="1",stopped-threads="all",core="0"
(gdb)
The fix has GDB stop processing the event if the context changed. I
don't expect people to be doing crazy things from the hook-stop.
E.g., it gives me headaches to try to come up a proper behavior for
handling a thread change from a hook-stop... (E.g., imagine the
hook-stop does thread N; step, with scheduler-locing on). I think the
most important bit here is preventing crashes.
The patch adds a new hook-stop.exp test that covers the above and also
merges in the old hook-stop-continue.exp and hook-stop-frame.exp into
the same framework.
gdb/ChangeLog:
2015-09-14 Pedro Alves <palves@redhat.com>
* infrun.c (current_stop_id): New global.
(get_stop_id, new_stop_id): New functions.
(fetch_inferior_event): Handle normal_stop proceeding the target.
(struct stop_context): New.
(save_stop_context, release_stop_context_cleanup)
(stop_context_changed): New functions.
(normal_stop): Return true if the hook-stop changes the stop
context.
* infrun.h (get_stop_id): Declare.
(normal_stop): Now returns int. Add documentation.
gdb/testsuite/ChangeLog:
2015-09-14 Pedro Alves <palves@redhat.com>
* gdb.base/hook-stop-continue.c: Delete.
* gdb.base/hook-stop-continue.exp: Delete.
* gdb.base/hook-stop-frame.c: Delete.
* gdb.base/hook-stop-frame.exp: Delete.
* gdb.base/hook-stop.c: New file.
* gdb.base/hook-stop.exp: New file.
This change is relevant only for standard DWARF (as opposed to the GNAT
encodings extensions): at the time of writing it only makes a difference
with GCC patches that are to be integrated: see in particular
<https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01364.html>.
Given the following Ada declarations:
type Small is mod 2 ** 6;
type Array_Type is array (0 .. 9) of Small
with Pack;
type Array_Access is access all Array_Type;
A : aliased Array_Type := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
AA : constant Array_Type := A'Access;
Before this change, we would get the following GDB session:
(gdb) print aa.all(2)
$1 = 3
(gdb) print aa(2)
$2 = 16
This is wrong: both expression should yield the same value: 3. The
problem is simply that the routine which handles accesses to arrays lack
general handling for packed arrays. After this patch, we have the
expected output:
(gdb) print aa.all(2)
$1 = 3
(gdb) print aa(2)
$2 = 3
gdb/ChangeLog:
* ada-lang.c (ada_value_ptr_subscript): Update the heading
comment. Handle packed arrays.
gdb/testsuite/ChangeLog:
* gdb.ada/access_to_packed_array.exp: New testcase.
* gdb.ada/access_to_packed_array/foo.adb: New file.
* gdb.ada/access_to_packed_array/pack.adb: New file.
* gdb.ada/access_to_packed_array/pack.ads: New file.
Tested on x86_64-linux, no regression.
The gdb.btrace/buffer-size.exp test starts recording with an unlimited
buffer size. This will, for a short time, use up most if not all BTS
resources.
I don' think this test is necessary. Remove it.
testsuite/
* gdb.btrace/buffer-size.exp: Remove recording with unlimited BTS
buffer size test.
This patch updates several exec-related tests and some of the library
functions in order to get them running with extended-remote. There were
three changes that were required, as follows:
In gdb.base/foll-exec.exp, use 'clean_start' in place of proc 'zap_session'
to reset the state of the debugger between tests. This sets 'remote
exec-file' to execute the correct binary file in each subsequent test.
In gdb.base/pie-execl.exp, there is an expect statement with an expression
that is used to match output from both gdb and the program under debug.
For the remote target, this had to be split into two expressions, using
$inferior_spawn_id to match the output from the program.
Because I had encountered problems with extended-remote exec events in
non-stop mode in my manual testing, I added non-stop testing to the
non-ldr-exc-[1234].exp tests. In order to set non-stop mode for remote
targets, it is necessary to 'set non-stop on' after gdb has started, but
before it connects to gdbserver. This is done using 'save_vars' to set
non-stop mode in GDBFLAGS, so GDB sets non-stop mode on startup.
gdb/testsuite/ChangeLog:
* gdb.base/foll-exec.c: Add copyright header. Fix
formatting issues.
* gdb.base/foll-exec.exp (zap_session): Delete proc.
(do_exec_tests): Use clean_restart in place of zap_session,
and for test initialization. Fix formatting issues. Use
fail in place of perror.
* gdb.base/pie-execl.exp (main): Use 'inferior_spawn_id' in
an expect statement to match an expression with output from
the program under debug.
* gdb.threads/non-ldr-exc-1.exp (do_test, main): Add
non-stop tests and pass stop mode argument to clean_restart.
Use save_vars to enable non-stop in GDBFLAGS.
* gdb.threads/non-ldr-exc-2.exp: Likewise.
* gdb.threads/non-ldr-exc-3.exp: Likewise.
* gdb.threads/non-ldr-exc-4.exp: Likewise.
This adds an object oriented replacement for the "struct continuation"
mechanism, and converts the stepping commands (step, next, stepi,
nexti) and the "finish" commands to use it.
It adds a new thread "class" (struct thread_fsm) that contains the
necessary info and callbacks to manage the state machine of a thread's
execution command.
This allows getting rid of some hacks. E.g., in fetch_inferior_event
and normal_stop we no longer need to know whether a thread is doing a
multi-step (e.g., step N). This effectively makes the
intermediate_continuations unused -- they'll be garbage collected in a
separate patch. (They were never a proper abstraction, IMO. See how
fetch_inferior_event needs to check step_multi before knowing whether
to call INF_EXEC_CONTINUE or INF_EXEC_COMPLETE.)
The target async vs !async uiout hacks in mi_on_normal_stop go away
too.
print_stop_event is no longer called from normal_stop. Instead it is
now called from within each interpreter's normal_stop observer. This
clears the path to make each interpreter print a stop event the way it
sees fit. Currently we have some hacks in common code to
differenciate CLI vs TUI vs MI around this area.
The "finish" command's FSM class stores the return value plus that
value's position in the value history, so that those can be printed to
both MI and CLI's streams. This fixes the CLI "finish" command when
run from MI -- it now also includes the function's return value in the
CLI stream:
(gdb)
~"callee3 (strarg=0x400730 \"A string argument.\") at src/gdb/testsuite/gdb.mi/basics.c:35\n"
~"35\t}\n"
+~"Value returned is $1 = 0\n"
*stopped,reason="function-finished",frame=...,gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0"
-FAIL: gdb.mi/mi-cli.exp: CLI finish: check CLI output
+PASS: gdb.mi/mi-cli.exp: CLI finish: check CLI output
gdb/ChangeLog:
2015-09-09 Pedro Alves <palves@redhat.com>
* Makefile.in (COMMON_OBS): Add thread-fsm.o.
* breakpoint.c (handle_jit_event): Print debug output.
(bpstat_what): Split event callback handling to ...
(bpstat_run_callbacks): ... this new function.
(momentary_bkpt_print_it): No longer handle bp_finish here.
* breakpoint.h (bpstat_run_callbacks): Declare.
* gdbthread.h (struct thread_info) <step_multi>: Delete field.
<thread_fsm>: New field.
(thread_cancel_execution_command): Declare.
* infcmd.c: Include thread-fsm.h.
(struct step_command_fsm): New.
(step_command_fsm_ops): New global.
(new_step_command_fsm, step_command_fsm_prepare): New functions.
(step_1): Adjust to use step_command_fsm_prepare and
prepare_one_step.
(struct step_1_continuation_args): Delete.
(step_1_continuation): Delete.
(step_command_fsm_should_stop): New function.
(step_once): Delete.
(step_command_fsm_clean_up, step_command_fsm_async_reply_reason)
(prepare_one_step): New function, based on step_once.
(until_next_command): Remove step_multi reference.
(struct return_value_info): New.
(print_return_value): Rename to ...
(print_return_value_1): ... this. New struct return_value_info
parameter. Adjust.
(print_return_value): Reimplement as wrapper around
print_return_value_1.
(struct finish_command_fsm): New.
(finish_command_continuation): Delete.
(finish_command_fsm_ops): New global.
(new_finish_command_fsm, finish_command_fsm_should_stop): New
functions.
(finish_command_fsm_clean_up, finish_command_fsm_return_value):
New.
(finish_command_continuation_free_arg): Delete.
(finish_command_fsm_async_reply_reason): New.
(finish_backward, finish_forward): Change symbol parameter to a
finish_command_fsm. Adjust.
(finish_command): Create a finish_command_fsm. Adjust.
* infrun.c: Include "thread-fsm.h".
(clear_proceed_status_thread): Delete the thread's FSM.
(infrun_thread_stop_requested_callback): Cancel the thread's
execution command.
(clean_up_just_stopped_threads_fsms): New function.
(fetch_inferior_event): Handle the event_thread's should_stop
method saying the command isn't done yet.
(process_event_stop_test): Run breakpoint callbacks here.
(print_stop_event): Rename to ...
(print_stop_location): ... this.
(restore_current_uiout_cleanup): New function.
(print_stop_event): Reimplement.
(normal_stop): No longer notify the end_stepping_range observers
here handle "step N" nor "finish" here. No longer call
print_stop_event here.
* infrun.h (struct return_value_info): Forward declare.
(print_return_value): Declare.
(print_stop_event): Change prototype.
* thread-fsm.c: New file.
* thread-fsm.h: New file.
* thread.c: Include "thread-fsm.h".
(thread_cancel_execution_command): New function.
(clear_thread_inferior_resources): Call it.
* cli/cli-interp.c (cli_on_normal_stop): New function.
(cli_interpreter_init): Install cli_on_normal_stop as normal_stop
observer.
* mi/mi-interp.c: Include "thread-fsm.h".
(restore_current_uiout_cleanup): Delete.
(mi_on_normal_stop): If the thread has an FSM associated, and it
finished, ask it for the async-reply-reason to print. Always call
print_stop_event here, regardless of the top-level interpreter.
Check bpstat_what to tell whether an asynchronous breakpoint hit
triggered.
* tui/tui-interp.c (tui_on_normal_stop): New function.
(tui_init): Install tui_on_normal_stop as normal_stop observer.
gdb/testsuite/ChangeLog:
2015-09-09 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-cli.exp: Add CLI finish tests.
2015-09-08 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.threads/hand-call-in-threads.exp: Make sure the thread
command actually switches threads. Give up on remaining
tests if target fails to stop at breakpoint.
Before this change, trying to call an overloaded function with at least
one character literal in argument would fail. For instance, given these
two functions:
function F (C : Character) return Integer is
begin
return Character'Pos (C);
end F;
function F (I : Integer) return Integer is
begin
return -I;
end F;
We would get the following GDB session:
(gdb) p f('A')
$1 = -65
(gdb) p f(1)
$1 = -1
This is wrong because the first call should select the first F function
and thus return 65.
The root problem is that ada-lang.c:ada_language_arch_info stores in
string_char_type a type whose code is TYPE_CODE_INT instead of
TYPE_CODE_CHAR. As a result, all parsed character literals are turned
into integer values and during overload matching, the TYPE_CODE_CHAR
formal rejects the TYPE_CODE_INT actual.
This change turns string_char_type into a true TYPE_CODE_CHAR type in
ada-lang.c so that we have instead the expected:
(gdb) p f('A')
$1 = 65
gdb/ChangeLog:
* ada-lang.c (ada_language_arch_info): Create a TYPE_CODE_CHAR
type instead of a TYPE_CODE_INT one for the string_char_type
and the ada_primitive_type_char types.
gdb/testsuite/ChangeLog:
* gdb.ada/funcall_char.exp: New testcase.
* gdb.ada/funcall_char/foo.adb: New file.
Tested on x86_64-linux, no regression.
Before this change, trying to complete an expression ending with an
ambiguous function name (i.e. for which there are multiple matches)
would display a menu with a prompt for the user to pick one. For
instance:
(gdb) p func<tab>Multiple matches for func
[0] cancel
[1] pack2.func at pack2.adb:5
[2] pack.func at pack.adb:5
>
This is not user friendly and actually triggered a segmentation fault
after the user did pick one. It is not clear whether the segmentation
fault needs a separate fix, but this is the only known case which
exhibits it at the moment, and this case must be fixed itself.
The problem lies in ada-lang.c (ada_resolve_function): when we got
multiple matches, we should not display the menu if we are in completion
mode. This patch adjusts the corresponding condition accordingly.
gdb/ChangeLog:
* ada-lang.c (ada_resolve_function): Do not ask the user what
match to use when in completion mode.
gdb/testsuite/ChangeLog:
* gdb.ada/complete.exp: Add "pck.ambiguous_func" to the relevant
expected outputs. Add two testcases for completing ambiguous
functions.
* gdb.ada/complete/aux_pck.adb: New file.
* gdb.ada/complete/aux_pck.ads: New file.
* gdb.ada/complete/foo.adb: Pull Aux_Pck and call the two
Ambiguous_Func functions.
* gdb.ada/complete/pck.ads: Add an Ambiguous_Func function.
* gdb.ada/complete/pck.adb: Likewise.
Tested on x86_64-linux, no regression.
The gdb.cell testcases use the predicate skip_cell_tests defined in
lib/cell.exp to determine whether Cell/B.E. test cases ought to be
run. This tests verifies that we have a toolchain that supports
generating combined Cell/B.E. binaries, and that the target machine
actually is a Cell/B.E.
In order to do so, a small test program is built and run (under the
debugger). Any failure is taken as a sign that we don't have a
Cell/B.E. machine and the tests are to be skipped.
This has the unfortunate effect that a serious bug in GDB that causes
internal compiler errors even on the trivial test program does not
lead to any failures in the testsuite, since now all gdb.cell test
are simply skipped.
This patch changes skip_cell_tests to at least report UNRESOLVED
in cases where execution of the test program fails in unexpected
ways.
testsuite/ChangeLog:
* lib/cell.exp (skip_cell_tests): Report UNRESOLVED on unexpected
failures to run the test program under GDB.
Due to the lack of debug information in the binary, GDB is unable to figure
out what language is being used. This may be a problem when doing remote
debugging and the binary stops at the entry point containing asm code.
In this case GDB will switch to asm as current language and will not switch
back to C when it reaches main, which in turn causes the compile feature check
to malfunction.
This is solved by forcing the language to C after reaching main.
gdb/testsuite/ChangeLog:
2015-08-26 Luis Machado <lgustavo@codesourcery.com>
* gdb.compile/compile-ifunc.exp (with_test_prefix): Force language
to C.
We currently set attach_flag when attaching to a process, so we should
make sure to unset it when forking a new process. Otherwise attach_flag
would remain set after forking, if the previous process associated with
the inferior was attached to.
gdb/ChangeLog:
* target.c (target_pre_inferior): Unset attach_flag.
gdb/testsuite/ChangeLog:
* gdb.base/run-after-attach.exp: New test file.
* gdb.base/run-after-attach.c: New test file.
This patch implements a new GDB test for follow-exec-mode. Although
there is a GDB test for debugging across an exec, there is no test for
follow-exec-mode. This test is derived from gdb.base/foll-exec.exp,
and re-uses execd-prog.c as the program to exec.
The following behavior is tested:
follow-exec-mode == "same"
- 'next' over the exec, check for one inferior
- 'continue' past the exec to a breakpoint, check for one inferior
- after the exec, use a 'run' command to run the current binary
follow-exec-mode == "new"
- 'next' over the exec, check for two inferiors
- 'continue' past the exec to a breakpoint, check for two inferiors
- after the exec, use a 'run' command to run the current binary
- after the exec, use the 'inferior' command to switch inferiors,
then use a 'run' command to run the current binary
Note that single-step breakpoints do not survive across an exec.
There has to be a breakpoint in the execed program in order for
it to stop right after the exec.
gdb/testsuite/ChangeLog:
* gdb.base/foll-exec-2.c: New test program.
* gdb.base/foll-exec-2.exp: New test.
GDB's current behavior when dealing with non-local references in the
context of nested fuctions is approximative:
- code using valops.c:value_of_variable read the first available stack
frame that holds the corresponding variable (whereas there can be
multiple candidates for this);
- code directly relying on read_var_value will instead read non-local
variables in frames where they are not even defined.
This change adds the necessary context to symbol reads (to get the block
they belong to) and to blocks (the static link property, if any) so that
GDB can make the proper decisions when dealing with non-local varibale
references.
gdb/ChangeLog:
* ada-lang.c (ada_read_var_value): Add a var_block argument
and pass it to default_read_var_value.
* block.c (block_static_link): New accessor.
* block.h (block_static_link): Declare it.
* buildsym.c (finish_block_internal): Add a static_link
argument. If there is a static link, associate it to the new
block.
(finish_block): Add a static link argument and pass it to
finish_block_internal.
(end_symtab_get_static_block): Update calls to finish_block and
to finish_block_internal.
(end_symtab_with_blockvector): Update call to
finish_block_internal.
* buildsym.h: Forward-declare struct dynamic_prop.
(struct context_stack): Add a static_link field.
(finish_block): Add a static link argument.
* c-exp.y: Remove an obsolete comment (evaluation of variables
already start from the selected frame, and now they climb *up*
the call stack) and propagate the block information to the
produced expression.
* d-exp.y: Likewise.
* f-exp.y: Likewise.
* go-exp.y: Likewise.
* jv-exp.y: Likewise.
* m2-exp.y: Likewise.
* p-exp.y: Likewise.
* coffread.c (coff_symtab_read): Update calls to finish_block.
* dbxread.c (process_one_symbol): Likewise.
* xcoffread.c (read_xcoff_symtab): Likewise.
* compile/compile-c-symbols.c (convert_one_symbol): Promote the
"sym" parameter to struct block_symbol, update its uses and pass
its block to calls to read_var_value.
(convert_symbol_sym): Update the calls to convert_one_symbol.
* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update
call to read_var_value.
* dwarf2loc.c (block_op_get_frame_base): New.
(dwarf2_block_frame_base_locexpr_funcs): Implement the
get_frame_base method.
(dwarf2_block_frame_base_loclist_funcs): Likewise.
(dwarf2locexpr_baton_eval): Add a frame argument and use it
instead of the selected frame in order to evaluate the
expression.
(dwarf2_evaluate_property): Add a frame argument. Update call
to dwarf2_locexpr_baton_eval to provide a frame in available and
to handle the absence of address stack.
* dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument.
* dwarf2read.c (attr_to_dynamic_prop): Add a forward
declaration.
(read_func_scope): Record any available static link description.
Update call to finish_block.
(read_lexical_block_scope): Update call to finish_block.
* findvar.c (follow_static_link): New.
(get_hosting_frame): New.
(default_read_var_value): Add a var_block argument. Use
get_hosting_frame to handle non-local references.
(read_var_value): Add a var_block argument and pass it to the
LA_READ_VAR_VALUE method.
* gdbtypes.c (resolve_dynamic_range): Update calls to
dwarf2_evaluate_property.
(resolve_dynamic_type_internal): Likewise.
* guile/scm-frame.c (gdbscm_frame_read_var): Update call to
read_var_value, passing it the block coming from symbol lookup.
* guile/scm-symbol.c (gdbscm_symbol_value): Update call to
read_var_value (TODO).
* infcmd.c (finish_command_continuation): Update call to
read_var_value, passing it the block coming from symbol lookup.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* language.h (struct language_defn): Add a var_block argument to
the LA_READ_VAR_VALUE method.
* objfiles.c (struct static_link_htab_entry): New.
(static_link_htab_entry_hash): New.
(static_link_htab_entry_eq): New.
(objfile_register_static_link): New.
(objfile_lookup_static_link): New.
(free_objfile): Free the STATIC_LINKS hashed map if needed.
* objfiles.h: Include hashtab.h.
(struct objfile): Add a static_links field.
(objfile_register_static_link): New.
(objfile_lookup_static_link): New.
* printcmd.c (print_variable_and_value): Update call to
read_var_value.
* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
* python/py-frame.c (frapy_read_var): Update call to
read_var_value, passing it the block coming from symbol lookup.
* python/py-framefilter.c (extract_sym): Add a sym_block
parameter and set the pointed value to NULL (TODO).
(enumerate_args): Update call to extract_sym.
(enumerate_locals): Update calls to extract_sym and to
read_var_value.
* python/py-symbol.c (sympy_value): Update call to
read_var_value (TODO).
* stack.c (read_frame_local): Update call to read_var_value.
(read_frame_arg): Likewise.
(return_command): Likewise.
* symtab.h (struct symbol_block_ops): Add a get_frame_base
method.
(struct symbol): Add a block field.
(SYMBOL_BLOCK): New accessor.
* valops.c (value_of_variable): Remove frame/block handling and
pass the block argument to read_var_value, which does this job
now.
(value_struct_elt_for_reference): Update calls to
read_var_value.
(value_of_this): Pass the block found to read_var_value.
* value.h (read_var_value): Add a var_block argument.
(default_read_var_value): Likewise.
gdb/testsuite/ChangeLog:
* gdb.base/nested-subp1.exp: New file.
* gdb.base/nested-subp1.c: New file.
* gdb.base/nested-subp2.exp: New file.
* gdb.base/nested-subp2.c: New file.
* gdb.base/nested-subp3.exp: New file.
* gdb.base/nested-subp3.c: New file.
Ref: https://sourceware.org/ml/gdb-patches/2015-08/msg00675.html
If multiprocess extensions are off (because specific gdbserver port
doesn't support them), then when gdbserver doesn't have a thread
selected yet, and GDB sends Hg packet to select one, gdbserver
crashes. That's because extracting the desired thread id out of the
packet that GDB sent depends on the current thread to fill in the
missing process id ... Fix this by getting the process id from the
first (and only) process in the processes list instead.
The GNU/Linux port doesn't trip on this because it always runs with
multiprocess extensions enabled. To make it easier to catch such
regressions going forward, this commit also adds a new smoke test that
spawns gdbserver, connects to it and runs to main with the
multiprocess extensions force-disabled.
gdb/gdbserver/ChangeLog:
2015-08-24 Pedro Alves <palves@redhat.com>
* inferiors.c (get_first_process): New function.
* inferiors.h (get_first_process): New declaration.
* remote-utils.c (read_ptid): Default to the first process in the
list, instead of to the current thread's process.
gdb/testsuite/ChangeLog:
2015-08-24 Pedro Alves <palves@redhat.com>
* gdb.server/connect-without-multi-process.c: New file.
* gdb.server/connect-without-multi-process.exp: New file.
This makes z an int for gdb/testsuite/gdb.opt/inline-markers.c.
gdb/testsuite/ChangeLog:
2015-08-24 Luis Machado <lgustavo@codesourcery.com>
* gdb.opt/inline-markers.c: Make z int.
This fixes a typo in gdb/testsuite/gdb.opt/inline-markers.c, making
z a volatile variable.
gdb/testsuite/ChangeLog:
2015-08-24 Luis Machado <lgustavo@codesourcery.com>
* gdb.opt/inline-markers.c: Make z volatile.
While doing some powerpc Linux tests on a ppc 476 board using GCC 5.2, i
noticed inline-bt.exp, inline-cmds.exp and inline-locals.exp failing.
FAIL: gdb.opt/inline-bt.exp: continue to bar (1)
FAIL: gdb.opt/inline-bt.exp: backtrace from bar (1)
FAIL: gdb.opt/inline-bt.exp: continue to bar (2)
FAIL: gdb.opt/inline-bt.exp: backtrace from bar (2)
FAIL: gdb.opt/inline-bt.exp: continue to bar (3)
FAIL: gdb.opt/inline-bt.exp: backtrace from bar (3)
FAIL: gdb.opt/inline-cmds.exp: continue to bar (1)
FAIL: gdb.opt/inline-cmds.exp: backtrace from bar (1)
FAIL: gdb.opt/inline-cmds.exp: continue to bar (2)
FAIL: gdb.opt/inline-cmds.exp: backtrace from bar (2)
FAIL: gdb.opt/inline-cmds.exp: continue to marker
FAIL: gdb.opt/inline-cmds.exp: backtrace from marker
FAIL: gdb.opt/inline-cmds.exp: step into finish marker
FAIL: gdb.opt/inline-locals.exp: continue to bar (1)
FAIL: gdb.opt/inline-locals.exp: continue to bar (2)
FAIL: gdb.opt/inline-locals.exp: backtrace from bar (2)
FAIL: gdb.opt/inline-locals.exp: continue to bar (3)
FAIL: gdb.opt/inline-locals.exp: backtrace from bar (3)
They failed because the breakpoint supposedly inserted at bar was actually
inserted at noinline.
(gdb) break inline-markers.c:20^M
Breakpoint 2 at 0x1000079c: file gdb/testsuite/gdb.opt/inline-markers.c, line 20.^M
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, noinline () at gdb/testsuite/gdb.opt/inline-markers.c:35^M
35 inlined_fn (); /* inlined */^M
As we can see, line 20 is really inside bar, not noinline:
18 void bar(void)
19 {
20 x += y; /* set breakpoint 1 here */
21 }
Further investigation shows that this is really due to GCC 5's new
ICF pass (-fipa-icf), now enabled by default at -O2, which folds bar
and marker into noinline, where the call to inlined_fn was inlined.
This breaks the testcase since it expects to stop at specific spots.
I thought about two possible fixes for this issue.
- Disable the ICF pass manually when building the binary (-fno-ipa-icf).
This has the advantage of not having to touch the testcase sources themselves,
but the disadvantage of having to add conditional blocks to test the GCC
version. If we ever change GCC's default, we will have to adjust the
conditional block again to match GCC's behavior.
- Modify the testcase sources to make the identical functions unique.
This solution doesn't touch the testcase itself, but changes the source
code slightly in order to make bar, marker and inlined_fn unique. This
causes GCC's ICF pass to ignore these functions and not fold them into
a common identical function.
I'm good with either of them, but i'm more inclined to go with the second
one.
The attached patch implements this by adding the new global variable z, set
to 0, that gets added in different ways to marker and inlined_fn. Since it
is 0, it doesn't affect any possible value checks that we may wish to do
in the future (we currently only check for values changed by bar).
Ok?
ps: I also noticed GDB doesn't do a great job at stating that the breakpoint
was actually inserted at a different source line than previously requested,
so this sounds like a bug that should be fixed, if it is not just wrong
DWARF information (did not investigate it further).
gdb/testsuite/ChangeLog:
2015-08-24 Luis Machado <lgustavo@codesourcery.com>
* gdb.opt/inline-bt.c: New volatile global z.
* gdb.opt/inline-cmds.c: Likewise.
* gdb.opt/inline-locals.c: Likewise.
* gdb.opt/inline-markers.c: New extern global z.
(marker): Use z.
(inline_fn): Likewise.
This avoids two more types of FAILs with the gnu_vector test case.
First, for POWER targets newer GCCs emit an ABI note when invoked with
"-mcpu=native". Then the test case fell back to non-native compile,
producing code for a non-vector ABI. But that is not supported by GDB.
Thus the compiler note is now suppressed with "-Wno-psabi".
Second, on s390 the test case produced FAILs after falling back to a
non-vector ABI when using "finish" or "return" in a vector-valued
function. This was due to a long-standing known bug (Bug 8549). This
case is now detected, and KFAILs are emitted instead.
gdb/testsuite/ChangeLog:
* gdb.base/gnu_vector.exp: Try compilation with "-mcpu=native
-Wno-psabi" if "-mcpu=native" fails. For the tests with "finish"
and "return" use KFAIL when GDB can not read/write the vector
return value.
GDB provides no indicator of progress during file operations, and can
appear to have locked up during slow remote transfers. This commit
updates GDB to print a warning each time a file is accessed over RSP.
An additional message detailing how to avoid remote transfers is
printed for the first transfer only.
gdb/ChangeLog:
* target.h (struct target_ops) <to_fileio_open>: New argument
warn_if_slow. Update comment. All implementations updated.
(target_fileio_open_warn_if_slow): New declaration.
* target.c (target_fileio_open): Renamed as...
(target_fileio_open_1): ...this. New argument warn_if_slow.
Pass warn_if_slow to implementation. Update debug printing.
(target_fileio_open): New function.
(target_fileio_open_warn_if_slow): Likewise.
* gdb_bfd.c (gdb_bfd_iovec_fileio_open): Use new function
target_fileio_open_warn_if_slow.
gdb/testsuite/ChangeLog:
* gdb.trace/pending.exp: Cope with remote transfer warnings.
Commit 221e1a37 (remote non-stop: Process initially stopped threads
before other commands) caused a test regression when testing with the
native-extended-gdbserver board:
FAIL: gdb.server/solib-list.exp: non-stop 1: non-stop interior stop (timeout)
This "interior stop" now happens before "target remote" prints the
prompt, so we should no longer explicitly expect it.
gdb/testsuite/ChangeLog:
2015-08-20 Pedro Alves <palves@redhat.com>
* gdb.server/solib-list.exp: No longer expect an interior stop in
non-stop mode.
The main motivation for this is making non-stop / all-stop behave
similarly on initial connection, in order to move in the direction of
reimplementing all-stop mode with the remote target always running in
non-stop mode.
When we connect to a remote target in non-stop mode, we may find
threads either running or already stopped. The act of connecting
itself does not force threads to stop. To handle that, the remote
non-stop connection is currently roughly like this:
#1 - Fetch list of remote threads (qXfer:threads:read, qfThreadInfo,
etc). All threads are assumed to be running until the target
reports an asynchronous stop reply for them.
#2 - Fetch the initial set of threads that were already stopped, with
the '?' packet. (In non-stop, this is coupled with the vStopped
mechanism to be able to retrieve the status of more than one
thread.)
The stop replies fetched in #2 are placed in the pending stop reply
queue, and left for the regular event loop to process. That is,
"target remote" finishes and returns _before_ those stops are
processed.
That means that it's possible to have GDB process further commands
before the initial set of stopped threads is reported to the user.
E.g., before the patch, note how the prompt is printed before the
frame:
Remote debugging using :9999
(gdb)
[Thread 15296] #1 stopped.
0x0000003615a011f0 in ?? ()
Even though thread #1 was not running, for a moment, the user can see
it as such:
$ gdb a.out -ex "set non-stop 1" -ex "tar rem :9999" -ex "info threads" -ex "info registers"
Remote debugging using :9999
Id Target Id Frame
* 1 Thread 4772 (running)
Target is executing. <<<<<<< info registers
(gdb)
[Thread 4772] #1 stopped.
0x0000003615a011f0 in ?? ()
To fix that, this commit makes gdb process all threads found already
stopped at connection time, before giving the prompt to the user.
The fix takes a cue from fork-child.c:startup_inferior [1], and
processes the events locally in remote.c, avoiding the whole
wait_for_inferior/handle_inferior_event path. I decided to try this
approach after noticing that:
- several cases in handle_inferior_event miss checking stop_soon.
- we don't want to fetch the thread list in normal_stop.
and trying to fix them was resulting in sprinkling stop_soon checks in
many places, and uglifying normal_stop even more.
While with this patch, I'm avoiding changing GDB's output other than
when the prompt is printed, I think this approach is more flexible if
we do want to change it. And also, it's likely easier to get rid of
the MI *running event that is still sent for threads that are
initially found stopped, if we want to.
This happens to fix the testsuite too. All non-stop tests are racy
against "target remote" / gdbserver testing currently. That is,
sometimes the tests run, but other times they're just skipped without
any indication of PASS/FAIL. When that happens, the logs show:
target remote localhost:2346
Remote debugging using localhost:2346
(gdb)
[Thread 25418] #1 stopped.
0x0000003615a011f0 in ?? ()
^CQuit
(gdb) Remote debugging from host 127.0.0.1
Killing process(es): 25418
monitor exit
(gdb) Remote connection closed
(gdb) testcase /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp completed in 61 seconds
The trouble here is that there's output after the prompt, and the
regex in question doesn't expect that:
-re "Remote debugging using .*$serialport_re.*$gdb_prompt $" {
verbose "Set target to $targetname"
return 0
}
[1] - before startup_inferior was added, we'd go through
wait_for_inferior/handle_inferior_event while going through the shell,
and that turned out problematic.
Tested on x86_64 Fedora 20, gdbserver.
gdb/ChangeLog:
2015-08-20 Pedro Alves <palves@redhat.com>
* infrun.c (print_target_wait_results): Make extern.
* infrun.h (print_target_wait_results): Declare.
* remote.c (set_stop_requested_callback): Delete.
(process_initial_stop_replies): New function.
(remote_start_remote): Use it.
(stop_reply_queue_length): New function.
gdb/testsuite/ChangeLog:
2015-08-20 Pedro Alves <palves@redhat.com>
* gdb.server/connect-stopped-target.c: New file.
* gdb.server/connect-stopped-target.exp: New file.
Here, in dwarfread.c:process_full_comp_unit:
/* Set symtab language to language from DW_AT_language. If the
compilation is from a C file generated by language preprocessors, do
not set the language if it was already deduced by start_subfile. */
if (!(cu->language == language_c
&& COMPUNIT_FILETABS (cust)->language != language_c))
COMPUNIT_FILETABS (cust)->language = cu->language;
in case start_subfile doesn't manage to deduce a language
COMPUNIT_FILETABS(cust)->language ends up as language_unknown, not
language_c. So the condition above evals false and we never set the
language from the cu's language.
gdb/ChangeLog:
2015-08-20 Pedro Alves <palves@redhat.com>
* dwarf2read.c (process_full_comp_unit): To tell whether
start_subfile managed to deduce a language, test for
language_unknown instead of language_c.
gdb/testsuite/ChangeLog:
2015-08-20 Pedro Alves <palves@redhat.com>
* gdb.dwarf2/comp-unit-lang.exp: New file.
* gdb.dwarf2/comp-unit-lang.c: New file.
Before this change, trying to evaluate the following Ada expression
yielded a syntax error, even though it's completely legal:
(gdb) p s'first = 'a'
Error in expression, near `'.
The problem lies in the lexer (gdb/ada-lex.l): at the point we reach "'a'",
we're still in the BEFORE_QUAL_QUOTE start condition (the mechanism to
distinguish character literals from other "tick" usages: qualified
expressions and attributes), so we consider that this quote is actually a
separate "tick".
This changes resets the start condition to INITIAL in the
{TICK}[a-zA-Z][a-zA-Z]+ rule (for attributes): attributes activate this
BEFORE_QUAL_QUOTE condition and in this case the above rule is always
executed rather than the <BEFORE_QUAL_QUOTE>"'" one (in flex, it's
always the longest match that is chosen). We now have instead:
(gdb) p s'first = 'a'
$1 = true
gdb/ChangeLog:
* ada-lex.l: Reset the start condition to INITIAL in the rule
that matches attributes.
gdb/testsuite/ChangeLog:
* gdb.ada/attr_ref_and_charlit.exp: New testcase.
* gdb.ada/attr_ref_and_charlit/foo.adb: New file.
Tested on x86_64-linux, no regression.
This change introduces a new function, dwarf2_string_attr(), which is
a wrapper for dwarf2_attr(). dwarf2read.c has been updated to
call dwarf2_string_attr in most instances where a string-valued
attribute is decoded to produce a string value. In most cases, it
simplifies the code; in some instances, the complexity of the code
remains unchanged.
I performed this change by looking for instances where the
result of DW_STRING was used in an assignment. Many of these
had a pattern which (roughly) looks something like this:
struct attribute *attr = NULL;
attr = dwarf2_attr (die, name, cu);
if (attr != NULL && DW_STRING (attr))
{
const char *str;
...
str = DW_STRING (attr);
... /* Use str in some fashion. */
}
Code of this form is transformed to look like this instead:
const char *str;
str = dwarf2_string_attr (die, name, cu)
if (str != NULL)
{
...
/* Use str in some fashion. */
...
}
In addition to invoking dwarf2_attr() and DW_STRING(),
dwarf2_string_attr() checks to make sure that the attribute's
`form' field matches one of DW_FORM_strp, DW_FORM_string, or
DW_FORM_GNU_strp_alt. If it does not match one of these forms,
it will return a NULL value in addition to calling complaint().
An earlier version of this patch did this type checking for one
particular instance where a string attribute was being decoded.
The situation that I was attempting to handle in that earlier patch is
this:
The Texas Instruments compiler uses the encoding for
DW_AT_MIPS_linkage_name for other purposes. TI uses the encoding,
0x2007, for TI_AT_TI_end_line which, unlike DW_AT_MIPS_linkage_name,
does not have a string-typed value. In this instance, GDB was attempting
to use an integer value as a string pointer, with predictable results.
(GDB would die with a segmentation fault.)
I've added a test which reproduces the problem that I was orignally
wanting to fix. It uses DW_AT_MIPS_linkage name with an associate
value which is a string, and again, where the value is a small
integer.
My test case causes GDB to segfault in an unpatched GDB. There
will be two PASSes in a patched GDB.
Unpatched GDB:
(gdb) ptype f
ERROR: Process no longer exists
UNRESOLVED: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype f
ERROR: Couldn't send ptype g to GDB.
UNRESOLVED: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype g
Patched GDB:
(gdb) ptype f
type = bool ()
(gdb) PASS: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype f
ptype g
type = bool ()
(gdb) PASS: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype g
I see no regressions on an x86_64 native target.
gdb/ChangeLog:
* dwarf2read.c (dwarf2_string_attr): New function.
(lookup_dwo_unit, process_psymtab_comp_unit_reader)
(dwarf2_compute_name, dwarf2_physname, find_file_and_directory)
(read_call_site_scope, namespace_name, guess_full_die_structure_name)
(anonymous_struct_prefix, prepare_one_comp_unit): Use
dwarf2_string_attr in place of dwarf2_attr and DW_STRING.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-bad-mips-linkage-name.c: New file.
* gdb.dwarf2/dw2-bad-mips-linkage-name.exp: New file.
One of the build slaves shows this error running explicit.exp:
(gdb) strace -m gdbfoobarbaz
Remote failure reply: E.In-process agent library not loaded in process.
Fast and static tracepoints unavailable.
(gdb) FAIL: gdb.linespec/explicit.exp: strace -m gdbfoobarbaz
There are two big problems with this test:
1) The expected output is actually not what the test is meant to test for.
2) This test should really only run where it is supported.
This is most easily fixed by moving the test to gdb.trace/strace.exp.
gdb/testsuite/ChangeLog
* gdb.linespec/explicit.exp: Move strace test from here ...
* gdb.trace/strace.exp: ... to here.
Invoking either of the above commands on an inferior that's not running
triggers the following assert failure:
.../binutils-gdb/gdb/thread.c:514: internal-error: any_thread_of_process: Assertion `pid != 0' failed.
The fix is straightforward. This patch also adds a test to check the
basic functionality of these commands, along with testing this fix in
particular. Tested on x86_64 Linux.
gdb/ChangeLog:
* inferior.c (detach_inferior_command): Don't call
any_thread_of_process when pid is 0.
(kill_inferior_command): Likewise.
gdb/testsuite/ChangeLog:
* gdb.base/kill-detach-inferiors-cmd.exp: New test file.
* gdb.base/kill-detach-inferiors-cmd.c: New test file.
The "source centric" /m option to the disassemble command is often
unhelpful, e.g., in the presence of optimized code.
This patch adds a /s modifier that is better.
For one, /m only prints instructions from the originating source file,
leaving out instructions from e.g., inlined functions from other files.
gdb/ChangeLog:
PR gdb/11833
* NEWS: Document new /s modifier for the disassemble command.
* cli/cli-cmds.c (disassemble_command): Add support for /s.
(_initialize_cli_cmds): Update online docs of disassemble command.
* disasm.c: #include "source.h".
(struct deprecated_dis_line_entry): Renamed from dis_line_entry.
All uses updated.
(dis_line_entry): New struct.
(hash_dis_line_entry, eq_dis_line_entry): New functions.
(allocate_dis_line_table): New functions.
(maybe_add_dis_line_entry, line_has_code_p): New functions.
(dump_insns): New arg end_pc. All callers updated.
(do_mixed_source_and_assembly_deprecated): Renamed from
do_mixed_source_and_assembly. All callers updated.
(do_mixed_source_and_assembly): New function.
(gdb_disassembly): Handle /s (DISASSEMBLY_SOURCE).
* disasm.h (DISASSEMBLY_SOURCE_DEPRECATED): Renamed from
DISASSEMBLY_SOURCE. All uses updated.
(DISASSEMBLY_SOURCE): New macro.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): New modes 4,5.
gdb/doc/ChangeLog:
* gdb.texinfo (Machine Code): Update docs for mixed source/assembly
disassembly.
(GDB/MI Data Manipulation): Update docs for new disassembly modes.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-disassemble.exp: Update.
* gdb.base/disasm-optim.S: New file.
* gdb.base/disasm-optim.c: New file.
* gdb.base/disasm-optim.h: New file.
* gdb.base/disasm-optim.exp: New file.
For some time now, GDB has permitted target-side evaluation of
breakpoint conditions. On targets that support this feature, GDB
may output an "evaluated-by" field into the breakpoint reply.
This patch adds handling for this option, and outputs a default
pattern to optionally recognize (and ignore) this pattern in the
reply.
gdb/testsuite/ChangeLog
* lib/mi-support.exp (mi_make_breakpoint): Add option/handling for
"evaluated-by".
Consider the following declaration:
function Foo (I : Integer) return Integer renames Pack.Bar;
As Foo is not materialized as a routine whose name is derived from Foo,
GDB currently cannot use it:
(gdb) print foo(0)
No definition of "foo" in current context.
However, compilers can emit DW_TAG_imported_declaration in order to
materialize the fact that Foo is actually another name for Pack.Bar.
This commit enhances the DWARF reader to record global renamings (it
used to put global ones in a static block) and enhances the Ada engine
to leverage this information during symbol lookup.
gdb/ChangeLog:
* ada-lang.c: Include namespace.h
(aux_add_nonlocal_symbols): Fix a function name in comment.
(ada_add_block_renamings): New.
(add_nonlocal_symbols): Add global renamings handling.
(ada_lookup_symbol_list_worker): Move the symbol lookup part
to...
(ada_add_all_symbols): ... this new function.
(ada_add_block_symbols): Try to match the input name against the
"using directives list", perform a recursive symbol lookup on
the matched declarations.
* block.h (struct block): Move the_namespace to top-level as
namespace_info. Remove the language_specific field.
(BLOCK_NAMESPACE): Update access to the namespace_info field.
* buildsym.h (using_directives): Rename into...
(local_using_directives): ... this.
(global_using_directives): New.
(struct context_stack): Rename the using_directives field into
local_using_directives.
* buildsym.c (finish_block_internal): Deal with the proper
using directives repository (local or global).
(prepare_for_building): Reset local_using_directives. Assert
that there is no pending global using directive.
(reset_symtab_globals): Reset global_using_directives and
local_using_directives.
(end_symtab_get_static_block): Don't ignore symtabs that have
only using directives.
(push_context): Update references to local_using_directives.
(buildsym_init): Do not reset using_directives.
* cp-support.c: Include namespace.h.
* cp-support.h (struct using_direct): Move to namespace.h.
(cp_add_using_directives): Move to namespace.h.
* cp-namespace.c: Include namespace.h
(cp_add_using_directive): Move to namespace.c, rename it to
add_using_directive, add a "using_directives" argument and use
it as the pending using directives repository. All callers
updated.
* dwarf2read.c (using_directives): New.
(read_import_statement): Call using_directives.
(read_func_scope): Update references to local_using_directives.
(read_lexical_block_scope): Likewise.
(read_namespace): Update the heading comment, call
using_directives.
* namespace.h: New file.
* namespace.c: New file.
* Makefile.in (SFILES): Add namespace.c.
(COMMON_OBS): Add namespace.o
gdb/testsuite/ChangeLog:
* gdb.ada/fun_renaming.exp: New testcase.
* gdb.ada/fun_renaming/fun_renaming.adb: New file.
* gdb.ada/fun_renaming/pack.adb: New file.
* gdb.ada/fun_renaming/pack.ads: New file.
Tested on x86_64-linux. Support for this in GCC is in the pipeline: see
<https://gcc.gnu.org/ml/gcc-patches/2015-07/msg02166.html>.
Keith reported that gdb.base/dso2dso.exp is broken, with the following
error:
| $ make check RUNTESTFLAGS=dso2dso.exp
| [snip]
| Running ../../../src/gdb/testsuite/gdb.base/dso2dso.exp ...
| ERROR: tcl error sourcing ../../../src/gdb/testsuite/gdb.base/dso2dso.exp.
| ERROR: couldn't open
| "../../../src/gdb/testsuite/gdb.base/../../../src/gdb/testsuite/gdb.base/dso2dso-dso1.c":
| no such file or directory
| while executing
| "error "$message""
| (procedure "gdb_get_line_number" line 14)
| invoked from within
| "gdb_get_line_number "STOP HERE" $srcfile_libdso1"
| (file "../../../src/gdb/testsuite/gdb.base/dso2dso.exp" line 60)
| invoked from within
| "source ../../../src/gdb/testsuite/gdb.base/dso2dso.exp"
| ("uplevel" body line 1)
| invoked from within
| "uplevel #0 source ../../../src/gdb/testsuite/gdb.base/dso2dso.exp"
| invoked from within
| "catch "uplevel #0 source $test_file_name""
This happens because gdb_get_line_number will prepend $srcdir/$subdir
if the given filename does not start with "/", and this happens when
GDB was configured using a relative path to the configure script.
When using an absolute path like I do, we avoid the pre-pending that
Keith is seeing.
gdb/testsuite/ChangeLog:
Keith Seitz <keiths@redhat.com>:
* gdb.base/dso2dso.exp: Pass basename of source file in call
to gdb_get_line_number.
Tested on x86_64-linux with both scenarios.
Making all-stop run on top of non-stop caused a small regression
in behavior. This was observed on x86_64-linux. The attached testcase
is in C whereas the investigation was done with an Ada program,
but it's the same scenario, and using a C testcase allows wider testing.
Basically: I am debugging a single-threaded program, and currently
stopped inside a function provided by a shared-library, at a line
calling a subprogram provided by a second shared library, and trying
to "next" over that function call.
Before we changed the default all-stop behavior, we had:
7 Impl_Initialize; -- Stop here and try "next" over this line
(gdb) n
8 return 5; <<-- OK
But now, "next" just stops much earlier:
(gdb) n
0x00007ffff7bd8560 in impl.initialize@plt () from /[...]/lib/libpck.so
What happens is that next stops at a call instruction, which calls
the function's PLT, and GDB fails to notice that the inferior stepped
into a subroutine, and so decides that we're done. We can see another
symptom of the same issue by looking at the backtrace at the point
GDB stopped:
(gdb) bt
#0 0x00007ffff7bd8560 in impl.initialize@plt ()
from /[...]/lib/libpck.so
#1 0x00000000f7bd86f9 in ?? ()
#2 0x00007fffffffdf50 in ?? ()
#3 0x0000000000401893 in a () at /[...]/a.adb:7
Backtrace stopped: frame did not save the PC
With a functioning GDB, the backtrace looks like the following instead:
#0 0x00007ffff7bd8560 in impl.initialize@plt ()
from /[...]/lib/libpck.so
#1 0x00007ffff7bd86f9 in sub () at /[...]/pck.adb:7
#2 0x0000000000401893 in a () at /[...]/a.adb:7
Note how, for frame #1, the address looks quite similar, except
for the high-order bits not being set:
#1 0x00007ffff7bd86f9 in sub () at /[...]/pck.adb:7 <<<-- OK
#1 0x00000000f7bd86f9 in ?? () <<<-- WRONG
^^^^
||||
Wrong
Investigating this further led me to displaced stepping.
As we are "next"-ing from a location where a breakpoint is inserted,
we need to step out of it, and since we're on non-stop mode, we need
to do it using displaced stepping. And looking at
amd64-tdep.c:amd64_displaced_step_fixup, I found the code that handles
the return address:
regcache_cooked_read_unsigned (regs, AMD64_RSP_REGNUM, &rsp);
retaddr = read_memory_unsigned_integer (rsp, retaddr_len, byte_order);
retaddr = (retaddr - insn_offset) & 0xffffffffUL;
The mask used to compute retaddr looks wrong to me, keeping only
4 bytes instead of 8, and explains why the high order bits of
the backtrace are unset. What happens is that, after the displaced
stepping has completed, GDB restores that return address at the location
where the program expects it. But because the top half bits of
the address have been masked out, the return address is now invalid.
The incorrect behavior of the "next" command and the backtrace at
that location are the first symptoms of that. Another symptom is
that this actually alters the behavior of the program, where a "cont"
from there soon leads to a SEGV when the inferior tries to jump back
to that incorrect return address:
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x00000000f7bd86f9 in ?? ()
^^^^^^^^^^^^^^^^^^
This patch fixes the issue by using a mask that seems more appropriate
for this architecture.
gdb/ChangeLog:
* amd64-tdep.c (amd64_displaced_step_fixup): Fix the mask used to
compute RETADDR.
gdb/testsuite/ChangeLog:
* gdb.base/dso2dso-dso2.c, gdb.base/dso2dso-dso2.h,
gdb.base/dso2dso-dso1.c, gdb.base/dso2dso-dso1.h, gdb.base/dso2dso.c,
gdb.base/dso2dso.exp: New files.
Tested on x86_64-linux, no regression.
Keith found out that several tests were failing when testing the
native-gdbserver board on Fedora (x86_64). Strangely, these failures
had not been reported by our BuildBot. Later, he found that the reason
for this was because the failures only happened when running the
testsuite without FORCE_PARALLEL (i.e., on serial mode; maybe it would
be worth having a builder testing things on serial...). Then, he
decided to start bisecting the changes to see which one introduced the
failure (it was not trivial to know this only by looking at gdb.log).
After a lot of time, he found that Pedro's commit
e1316e60d4 was the culprit. There was
nothing wrong in the code, but the new gdb.base/checkpoint-ns.exp
testcase did something that left the GDBFLAGS variable in an
inconsistent state. This test works by modifying this variable to set
non-stop on, sourcing gdb.base/checkpoint.exp (which does the hard
work), and then restoring the old value on GDBFLAGS. However, this was
not working because gdb.base/checkpoint.exp bails out if it is being
tested on gdbserver, and when it calls "continue" the control goes back
to the function calling the tests, and not to
gdb.base/checkpoint-ns.exp.
The fix is simple: just wrap the "source" call, and make
gdb.base/checkpoint-ns.exp aware of the "continue"/"return" calls made
by gdb.base/checkpoint.exp.
gdb/testsuite/ChangeLog:
2015-08-12 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
Keith Seitz <keiths@redhat.com>
* gdb.base/checkpoint-ns.exp: Use save_vars to save and restore
GDBFLAGS.
gdb/testsuite/ChangeLog:
* gdb.base/gdbhistsize-history.exp
(test_histsize_history_setting): Use save_vars.
* gdb.base/gdbinit-history.exp (test_gdbinit_history_setting):
Use save_vars.
(test_no_truncation_of_unlimited_history_file): Use save_vars.
* gdb.base/readline.exp: Use save_vars.
This patch adds documentation for explicit locations to both the
User Manual and gdb's online help system.
gdb/ChangeLog:
* NEWS: Mention explicit locations.
* breakpoint.c [LOCATION_HELP_STRING]: New macro.
[BREAK_ARGS_HELP]: Use LOCATION_HELP_STRING.
(_initialize_breakpoint): Update documentation for
"clear", "break", "trace", "strace", "ftrace", and "dprintf".
gdb/doc/ChangeLog:
* gdb.texinfo (Thread-Specific Breakpoints, Printing Source Lines):
Use "location(s)"instead of "linespec(s)".
(Specifying a Location): Rewrite.
Add subsections describing linespec, address, and explicit locations.
Add node/menu for each subsection.
(Source and Machine Code, C Preprocessor Macros)
(Create and Delete Trace points)
(Extensions for Ada Tasks): Use "location(s)" instead of "linespec(s)".
(Continuing at a Different Address): Remove "linespec" examples.
Add reference to "Specify a Location"
(The -break-insert Command): Rewrite. Add anchor.
Add reference to appropriate manual section discussing locations.
(The -dprintf-insert Command): Refer to -break-insert for
specification of 'location'.
gdb/testsuite/ChangeLog:
* gdb.base/help.exp: Update help_breakpoint_text.
This patch adds support for explicit locations to MI's -break-insert
command. The new options, documented in the User Manual, are
--source, --line, --function, and --label.
gdb/ChangeLog:
* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Add support for
explicit locations, options "--source", "--function",
"--label", and "--line".
gdb/testsuite/ChangeLog:
* gdb.mi/mi-break.exp (test_explicit_breakpoints): New proc.
(at toplevel): Call test_explicit_breakpoints.
* gdb.mi/mi-dprintf.exp: Add tests for explicit dprintf
breakpoints.
* lib/mi-support.exp (mi_make_breakpoint): Add support for
breakpoint conditions, "-cond".
This patch exposes explicit locations to the CLI user. This enables
users to "explicitly" specify attributes of the breakpoint location
to avoid any ambiguity that might otherwise exist with linespecs.
The general syntax of explicit locations is:
-source SOURCE_FILENAME -line {+-}LINE -function FUNCTION_NAME
-label LABEL_NAME
Option names may be abbreviated, e.g., "-s SOURCE_FILENAME -li 3" and users
may use the completer with either options or values.
gdb/ChangeLog:
* completer.c: Include location.h.
(enum match_type): New enum.
(location_completer): Rename to ...
(linespec_completer): ... this.
(collect_explicit_location_matches, backup_text_ptr)
(explicit_location_completer): New functions.
(location_completer): "New" function; handle linespec
and explicit location completions.
(complete_line_internal): Remove all location completer-specific
handling.
* linespec.c (linespec_lexer_lex_keyword, is_ada_operator)
(find_toplevel_char): Export.
(linespec_parse_line_offset): Export.
Issue error if STRING is not numerical.
(gdb_get_linespec_parser_quote_characters): New function.
* linespec.h (linespec_parse_line_offset): Declare.
(get_gdb_linespec_parser_quote_characters): Declare.
(is_ada_operator): Declare.
(find_toplevel_char): Declare.
(linespec_lexer_lex_keyword): Declare.
* location.c (explicit_to_event_location): New function.
(explicit_location_lex_one): New function.
(string_to_explicit_location): New function.
(string_to_event_location): Handle explicit locations.
* location.h (explicit_to_event_location): Declare.
(string_to_explicit_location): Declare.
gdb/testsuite/ChangeLog:
* gdb.linespec/3explicit.c: New file.
* gdb.linespec/cpexplicit.cc: New file.
* gdb.linespec/cpexplicit.exp: New file.
* gdb.linespec/explicit.c: New file.
* gdb.linespec/explicit.exp: New file.
* gdb.linespec/explicit2.c: New file.
* gdb.linespec/ls-errs.exp: Add explicit location tests.
* lib/gdb.exp (capture_command_output): Regexp-escape `command'
before using in the matching pattern.
Clarify that `prefix' is a regular expression.
This patch converts the code base to use the new struct event_location
API being introduced. This patch preserves the current functionality and
adds no new features.
The "big picture" API usage introduced by this patch may be illustrated
with a simple exmaple. Where previously developers would write:
void
my_command (char *arg, int from_tty)
{
create_breakpoint (..., arg, ...);
...
}
one now uses:
void
my_command (char *arg, int from_tty)
{
struct event_locaiton *location;
struct cleanup *back_to;
location = string_to_event_locaiton (&arg, ...);
back_to = make_cleanup_delete_event_location (location);
create_breakpoint (..., location, ...);
do_cleanups (back_to);
}
Linespec-decoding functions (now called location-decoding) such as
decode_line_full no longer skip argument pointers over processed input.
That functionality has been moved into string_to_event_location as
demonstrated above.
gdb/ChangeLog
* ax-gdb.c: Include location.h.
(agent_command_1) Use linespec location instead of address
string.
* break-catch-throw.c: Include location.h.
(re_set_exception_catchpoint): Use linespec locations instead
of address strings.
* breakpoint.c: Include location.h.
(create_overlay_event_breakpoint, create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint, update_breakpoints_after_exec):
Use linespec location instead of address string.
(print_breakpoint_location): Use locations and
event_location_to_string.
Print extra_string for pending locations for non-MI streams.
(print_one_breakpoint_location): Use locations and
event_location_to_string.
(init_raw_breakpoint_without_location): Initialize b->location.
(create_thread_event_breakpoint): Use linespec location instead of
address string.
(init_breakpoint_sal): Likewise.
Only save extra_string if it is non-NULL and not the empty string.
Use event_location_to_string instead of `addr_string'.
Constify `p' and `endp'.
Use skip_spaces_const/skip_space_const instead of non-const versions.
Copy the location into the breakpoint.
If LOCATION is NULL, save the breakpoint address as a linespec location
instead of an address string.
(create_breakpoint_sal): Change `addr_string' parameter to a struct
event_location. All uses updated.
(create_breakpoints_sal): Likewise for local variable `addr_string'.
(parse_breakpoint_sals): Use locations instead of address strings.
Remove check for empty linespec with conditional.
Refactor.
(decode_static_tracepoint_spec): Make argument const and update
function.
(create_breakpoint): Change `arg' to a struct event_location and
rename.
Remove `copy_arg' and `addr_start'.
If EXTRA_STRING is empty, set it to NULL.
Don't populate `canonical' for pending breakpoints.
Pass `extra_string' to find_condition_and_thread.
Clear `extra_string' if `rest' was NULL.
Do not error with "garbage after location" if setting a dprintf
breakpoint.
Copy the location into the breakpoint instead of an address string.
(break_command_1): Use string_to_event_location and pass this to
create_breakpoint instead of an address string.
Check against `arg_cp' for a probe linespec.
(dprintf_command): Use string_to_event_location and pass this to
create_breakpoint instead of an address string.
Throw an exception if no format string was specified.
(print_recreate_ranged_breakpoint): Use event_location_to_string
instead of address strings.
(break_range_command, until_break_command)
(init_ada_exception_breakpoint): Use locations instead
of address strings.
(say_where): Print out extra_string for pending locations.
(base_breakpoint_dtor): Delete `location' and `location_range_end' of
the breakpoint.
(base_breakpoint_create_sals_from_location): Use struct event_location
instead of address string.
Remove `addr_start' and `copy_arg' parameters.
(base_breakpoint_decode_location): Use struct event_location instead of
address string.
(bkpt_re_set): Use locations instead of address strings.
Use event_location_empty_p to check for unset location.
(bkpt_print_recreate): Use event_location_to_string instead of
an address string.
Print out extra_string for pending locations.
(bkpt_create_sals_from_location, bkpt_decode_location)
(bkpt_probe_create_sals_from_location): Use struct event_location
instead of address string.
(bkpt_probe_decode_location): Use struct event_location instead of
address string.
(tracepoint_print_recreate): Use event_location_to_string to
recreate the tracepoint.
(tracepoint_create_sals_from_location, tracepoint_decode_location)
(tracepoint_probe_create_sals_from_location)
(tracepoint_probe_decode_location): Use struct event_location
instead of address string.
(dprintf_print_recreate): Use event_location_to_string to recreate
the dprintf.
(dprintf_re_set): Remove check for valid/missing format string.
(strace_marker_create_sals_from_location)
(strace_marker_create_breakpoints_sal, strace_marker_decode_location)
(update_static_tracepoint): Use struct event_location instead of
address string.
(location_to_sals): Likewise.
Pass `extra_string' to find_condition_and_thread.
For newly resolved pending breakpoint locations, clear the location's
string representation.
Assert that the breakpoint's condition string is NULL when
condition_not_parsed.
(breakpoint_re_set_default, create_sals_from_location_default)
(decode_location_default, trace_command, ftrace_command)
(strace_command, create_tracepoint_from_upload): Use locations
instead of address strings.
* breakpoint.h (struct breakpoint_ops) <create_sals_from_location>:
Use struct event_location instead of address string.
Update all uses.
<decode_location>: Likewise.
(struct breakpoint) <addr_string>: Change to struct event_location
and rename `location'.
<addr_string_range_end>: Change to struct event_location and rename
`location_range_end'.
(create_breakpoint): Use struct event_location instead of address
string.
* cli/cli-cmds.c: Include location.h.
(edit_command, list_command): Use locations instead of address strings.
* elfread.c: Include location.h.
(elf_gnu_ifunc_resolver_return_stop): Use event_location_to_string.
* guile/scm-breakpoint.c: Include location.h.
(bpscm_print_breakpoint_smob): Use event_location_to_string.
(gdbscm_register_breakpoint): Use locations instead of address
strings.
* linespec.c: Include location.h.
(struct ls_parser) <stream>: Change to const char *.
(PARSER_STREAM): Update.
(lionespec_lexer_lex_keyword): According to find_condition_and_thread,
keywords must be followed by whitespace.
(canonicalize_linespec): Save a linespec location into `canonical'.
Save a canonical linespec into `canonical'.
(parse_linespec): Change `argptr' to const char * and rename `arg'.
All uses updated.
Update function description.
(linespec_parser_new): Initialize `parser'.
Update initialization of parsing stream.
(event_location_to_sals): New function.
(decode_line_full): Change `argptr' to a struct event_location and
rename it `location'.
Use locations instead of address strings.
Call event_location_to_sals instead of parse_linespec.
(decode_line_1): Likewise.
(decode_line_with_current_source, decode_line_with_last_displayed)
Use locations instead of address strings.
(decode_objc): Likewise.
Change `argptr' to const char * and rename `arg'.
(destroy_linespec_result): Delete the linespec result's location
instead of freeing the address string.
* linespec.h (struct linespec_result) <addr_string>: Change to
struct event_location and rename to ...
<location>: ... this.
(decode_line_1, decode_line_full): Change `argptr' to struct
event_location. All callers updated.
* mi/mi-cmd-break.c: Include language.h, location.h, and linespec.h.
(mi_cmd_break_insert_1): Use locations instead of address strings.
Throw an error if there was "garbage" at the end of the specified
linespec.
* probe.c: Include location.h.
(parse_probes): Change `argptr' to struct event_location.
Use event locations instead of address strings.
* probe.h (parse_probes): Change `argptr' to struct event_location.
* python/py-breakpoint.c: Include location.h.
(bppy_get_location): Constify local variable `str'.
Use event_location_to_string.
(bppy_init): Use locations instead of address strings.
* python/py-finishbreakpoint.c: Include location.h.
(bpfinishpy_init): Remove local variable `addr_str'.
Use locations instead of address strings.
* python/python.c: Include location.h.
(gdbpy_decode_line): Use locations instead of address strings.
* remote.c: Include location.h.
(remote_download_tracepoint): Use locations instead of address
strings.
* spu-tdep.c: Include location.h.
(spu_catch_start): Remove local variable `buf'.
Use locations instead of address strings.
* tracepoint.c: Include location.h.
(scope_info): Use locations instead of address strings.
(encode_source_string): Constify parameter `src'.
* tracepoint.h (encode_source_string): Likewise.
gdb/testsuite/ChangeLog
* gdb.base/dprintf-pending.exp: Update dprintf "without format"
test.
Add tests for missing ",FMT" and ",".
gdb/ChangeLog:
* symtab.c (make_file_symbol_completion_list_1): Renamed from
make_file_symbol_completion_list and made static.
(make_file_symbol_completion_list): New function.
gdb/testsuite/ChangeLog:
* gdb.base/completion.exp: Add location completer tests.
The ppc64 displaced step code can't handle atomic sequences. Fallback
to stepping over the breakpoint in-line if we detect one.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* infrun.c (displaced_step_prepare_throw): Return -1 if
gdbarch_displaced_step_copy_insn returns NULL. Update intro
comment.
* rs6000-tdep.c (LWARX_MASK, LWARX_INSTRUCTION, LDARX_INSTRUCTION)
(STWCX_MASK, STWCX_INSTRUCTION, STDCX_INSTRUCTION): Move higher up
in file.
(ppc_displaced_step_copy_insn): New function.
(ppc_displaced_step_fixup): Update comment.
(rs6000_gdbarch_init): Install ppc_displaced_step_copy_insn as
gdbarch_displaced_step_copy_insn hook.
* gdbarch.sh (displaced_step_copy_insn): Document what happens on
NULL return.
* gdbarch.h: Regenerate.
gdb/testsuite/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.arch/ppc64-atomic-inst.exp (do_test): New procedure, move
tests here.
(top level): Run do_test with and without displaced stepping.
Running the testsuite with "maint set target-non-stop on" shows:
(gdb) PASS: gdb.base/valgrind-infcall.exp: continue #98 (false warning)
continue
Continuing.
dl_main (phdr=<optimized out>..., auxv=<optimized out>) at rtld.c:2302
2302 LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
Cannot access memory at address 0x400532
(gdb) PASS: gdb.base/valgrind-infcall.exp: continue #99 (false warning)
p gdb_test_infcall ()
$1 = 1
(gdb) FAIL: gdb.base/valgrind-infcall.exp: p gdb_test_infcall ()
Even though that was a native GNU/Linux test run, this test spawns
Valgrind and connects to it with "target remote". The error above is
actually orthogonal to target-non-stop. The real issue is that that
enables displaced stepping, and displaced stepping doesn't work with
Valgrind, because we can't write to the inferior memory (thus can't
copy the instruction to the scratch pad area).
I'm sure there will be other targets with the same issue, so trying to
identify Valgrind wouldn't be sufficient. The fix is to try setting
up the displaced step anyway. If we get a MEMORY_ERROR, we disable
displaced stepping for that inferior, and fall back to doing an
in-line step-over. If "set displaced-stepping" is "on" (as opposed to
"auto), GDB warns displaced stepping failed ("on" is mainly useful for
the testsuite, not for users).
Tested on x86_64 Fedora 20.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* inferior.h (struct inferior) <displaced_stepping_failed>: New
field.
* infrun.c (use_displaced_stepping_now_p): New parameter 'inf'.
Return false if dispaced stepping failed before.
(resume): Pass the current inferior to
use_displaced_stepping_now_p. Wrap displaced_step_prepare in
TRY/CATCH. If we get a MEMORY_ERROR, set the inferior's
displaced_stepping_failed flag, and fall back to an in-line
step-over.
gdb/testsuite/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.base/valgrind-disp-step.c: New file.
* gdb.base/valgrind-disp-step.exp: New file.
On a target that is both always in non-stop mode and can do displaced
stepping (such as native x86_64 GNU/Linux, with "maint set
target-non-stop on"), the step-over-trips-on-watchpoint.exp test
sometimes fails like this:
(gdb) PASS: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: thread 1
set scheduler-locking off
(gdb) PASS: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: set scheduler-locking off
step
-[Switching to Thread 0x7ffff7fc0700 (LWP 11782)]
-Hardware watchpoint 4: watch_me
-
-Old value = 0
-New value = 1
-child_function (arg=0x0) at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c:39
-39 other = 1; /* set thread-specific breakpoint here */
-(gdb) PASS: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: step
+wait_threads () at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c:49
+49 return 1; /* in wait_threads */
+(gdb) FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: step
Note "scheduler-locking" was set off. The problem is that on such
targets, the step-over of thread 2 and the "step" of thread 1 can be
set to run simultaneously (since with displaced stepping the
breakpoint isn't ever removed from the target), and sometimes, the
"step" of thread 1 finishes first, so it'd take another resume to see
the watchpoint trigger. Fix this by replacing the wait_threads
function with a one-line infinite loop that doesn't call any function,
so that the "step" of thread 1 never finishes.
gdb/testsuite/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.threads/step-over-lands-on-breakpoint.c (wait_threads):
Delete function.
(main): Add alarm. Run an infinite loop instead of calling
wait_threads.
* gdb.threads/step-over-lands-on-breakpoint.exp (do_test): Change
comment.
* gdb.threads/step-over-trips-on-watchpoint.c (wait_threads):
Delete function.
(main): Add alarm. Run an infinite loop instead of calling
wait_threads.
* gdb.threads/step-over-trips-on-watchpoint.exp (do_test): Change
comment.
With "maint set target-non-stop on" we get:
-PASS: gdb.threads/signal-while-stepping-over-bp-other-thread.exp: step
+FAIL: gdb.threads/signal-while-stepping-over-bp-other-thread.exp: step
The issue is simply that switch_back_to_stepped_thread is not used in
non-stop mode, thus infrun doesn't output the expected "switching back
to stepped thread" log.
gdb/testsuite/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* signal-while-stepping-over-bp-other-thread.exp: Expect "restart
threads" as alternative to "switching back to stepped thread".
Letting a "checkpoint" run to exit with "set non-stop on" behaves
differently compared to the default all-stop mode ("set non-stop
off").
Currently, in non-stop mode:
(gdb) start
Temporary breakpoint 1 at 0x40086b: file src/gdb/testsuite/gdb.base/checkpoint.c, line 28.
Starting program: build/gdb/testsuite/gdb.base/checkpoint
Temporary breakpoint 1, main () at src/gdb/testsuite/gdb.base/checkpoint.c:28
28 char *tmp = &linebuf[0];
(gdb) checkpoint
checkpoint 1: fork returned pid 24948.
(gdb) c
Continuing.
Copy complete.
Deleting copy.
[Inferior 1 (process 24944) exited normally]
[Switching to process 24948]
(gdb) info threads
Id Target Id Frame
1 process 24948 "checkpoint" (running)
No selected thread. See `help thread'.
(gdb) c
The program is not being run.
(gdb)
Two issues above:
1. Thread 1 got stuck in "(running)" state (it isn't really running)
2. While checkpoints try to preserve the illusion that the thread is
still the same when the process exits, GDB switched to "No thread
selected." instead of staying with thread 1 selected.
Problem #1 is caused by handle_inferior_event and normal_stop not
considering that when a
TARGET_WAITKIND_SIGNALLED/TARGET_WAITKIND_EXITED event is reported,
and the inferior is mourned, the target may still have execution.
Problem #2 is caused by the make_cleanup_restore_current_thread
cleanup installed by fetch_inferior_event not being able to find the
original thread 1's ptid in the thread list, thus not being able to
restore thread 1 as selected thread. The fix is to make the cleanup
installed by make_cleanup_restore_current_thread aware of thread ptid
changes, by installing a thread_ptid_changed observer that adjusts the
cleanup's data.
After the patch, we get the same in all-stop and non-stop modes:
(gdb) c
Continuing.
Copy complete.
Deleting copy.
[Inferior 1 (process 25109) exited normally]
[Switching to process 25113]
(gdb) info threads
Id Target Id Frame
* 1 process 25113 "checkpoint" main () at src/gdb/testsuite/gdb.base/checkpoint.c:28
(gdb)
Turns out the whole checkpoints.exp file can run in non-stop mode
unmodified. I thought of moving most of the test file's contents to a
procedure that can be called twice, once in non-stop mode and another
in all-stop mode. But then, the test already takes close to 30
seconds to run on my machine, so I thought it'd be nicer to run
all-stop and non-stop mode in parallel. Thus I added a new
checkpoint-ns.exp file that just appends "set non-stop on" to GDBFLAGS
and sources checkpoint.exp.
gdb/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* infrun.c (handle_inferior_event): If we get
TARGET_WAITKIND_SIGNALLED or TARGET_WAITKIND_EXITED in non-stop
mode, mark all threads of the exiting process as not-executing.
(normal_stop): If we get TARGET_WAITKIND_SIGNALLED or
TARGET_WAITKIND_EXITED in non-stop mode, finish all threads of the
exiting process, if inferior_ptid still points at a process.
* thread.c (struct current_thread_cleanup) <next>: New field.
(current_thread_cleanup_chain): New global.
(restore_current_thread_ptid_changed): New function.
(restore_current_thread_cleanup_dtor): Remove the cleanup from the
current_thread_cleanup_chain list.
(make_cleanup_restore_current_thread): Add the cleanup data to the
current_thread_cleanup_chain list.
(_initialize_thread): Install restore_current_thread_ptid_changed
as thread_ptid_changed observer.
gdb/testsuite/ChangeLog:
2015-08-07 Pedro Alves <palves@redhat.com>
* gdb.base/checkpoint-ns.exp: New file.
* gdb.base/checkpoint.exp: Pass explicit "checkpoint.c" to
standard_testfile.
Indicate speculatively executed instructions with a leading '?'. We use the
space that is normally used for the PC prefix. In the case where the
instruction at the current PC had been executed speculatively before, the PC
prefix will be partially overwritten resulting in "?> ".
As a side-effect, the /p modifier to omit the PC prefix in the "record
instruction-history" command now uses a 3-space PC prefix " " in order to
have enough space for the speculative execution indication.
gdb/
* btrace.c (btrace_compute_ftrace_bts): Clear insn flags.
(pt_btrace_insn_flags): New.
(ftrace_add_pt): Call pt_btrace_insn_flags.
* btrace.h (btrace_insn_flag): New.
(btrace_insn) <flags>: New.
* record-btrace.c (btrace_insn_history): Print insn prefix.
* NEWS: Announce it.
doc/
* gdb.texinfo (Process Record and Replay): Document prefixing of
speculatively executed instructions in the "record instruction-history"
command.
testsuite/
* gdb.btrace/instruction_history.exp: Update.
* gdb.btrace/tsx.exp: New.
* gdb.btrace/tsx.c: New.
* lib/gdb.exp (skip_tsx_tests, skip_btrace_pt_tests): New.
The buildbot shows that PPC64 and x86_64 builders, both native and
extended-remote gdbserver frequently timeout these tests.
until-precsave.exp times out on my x86_64 occasionally as well.
Inspecting the logs, we see that if we waited some more, the tests
would pass.
Simply bump until-precsave.exp timeouts further, and apply the same
treatment to step-precsave.exp.
gdb/testsuite/ChangeLog:
2015-08-06 Pedro Alves <palves@redhat.com>
* gdb.reverse/step-precsave.exp: Use with_timeout_factor to
increase timeout.
* gdb.reverse/until-precsave.exp: Bump timeouts.
This test fails with --target_board=native-extended-gdbserver because
it misses the usual "disconnect":
(gdb) target remote | /usr/lib64/valgrind/../../bin/vgdb --pid=30454
Already connected to a remote target. Disconnect? (y or n) n
Still connected.
(gdb) FAIL: gdb.base/valgrind-infcall.exp: target remote for vgdb (got interactive prompt)
gdb/testsuite/ChangeLog:
2015-08-06 Pedro Alves <palves@redhat.com>
* gdb.base/valgrind-infcall.exp: Issue a "disconnect".
This adds a kfailed test that has the whole process exit just while
several threads continuously step over a breakpoint. Usually, the
process exits just while GDB or GDBserver is handling the breakpoint
hit. In other words, the process disappears while the event thread is
(ptrace-) stopped. This exposes several issues in GDB and GDBserver.
Errors, crashes, etc.
I fixed some of these issues recently, but there's a lot more to do.
It's a bit like playing whack-a-mole at the moment. You fix an issue,
which then exposes several others.
E.g., with the native target, you get (among other errors):
(...)
[New Thread 0x7ffff47b9700 (LWP 18077)]
[New Thread 0x7ffff3fb8700 (LWP 18078)]
[New Thread 0x7ffff37b7700 (LWP 18079)]
Cannot find user-level thread for LWP 18076: generic error
(gdb) KFAIL: gdb.threads/process-dies-while-handling-bp.exp: non_stop=on: cond_bp_target=1: inferior 1 exited (prompt) (PRMS: gdb/18749)
gdb/testsuite/ChangeLog:
2015-08-06 Pedro Alves <palves@redhat.com>
PR gdb/18749
* gdb.threads/process-dies-while-handling-bp.c: New file.
* gdb.threads/process-dies-while-handling-bp.exp: New file.
Ref: https://sourceware.org/ml/gdb-patches/2015-07/msg00868.html
This adds a test that has a multithreaded program have several threads
continuously fork, while another thread continuously steps over a
breakpoint.
This exposes several intertwined issues, which this patch addresses:
- When we're stopping and suspending threads, some thread may fork,
and we missed setting its suspend count to 1, like we do when a new
clone/thread is detected. When we next unsuspend threads, the fork
child's suspend count goes below 0, which is bogus and fails an
assertion.
- If a step-over is cancelled because a signal arrives, but then gdb
is not interested in the signal, we pass the signal straight back
to the inferior. However, we miss that we need to re-increment the
suspend counts of all other threads that had been paused for the
step-over. As a result, other threads indefinitely end up stuck
stopped.
- If a detach request comes in just while gdbserver is handling a
step-over (in the test at hand, this is GDB detaching the fork
child), gdbserver internal errors in stabilize_thread's helpers,
which assert that all thread's suspend counts are 0 (otherwise we
wouldn't be able to move threads out of the jump pads). The
suspend counts aren't 0 while a step-over is in progress, because
all threads but the one stepping past the breakpoint must remain
paused until the step-over finishes and the breakpoint can be
reinserted.
- Occasionally, we see "BAD - reinserting but not stepping." being
output (from within linux_resume_one_lwp_throw). That was because
GDB pokes memory while gdbserver is busy with a step-over, and that
suspends threads, and then re-resumes them with proceed_one_lwp,
which missed another reason to tell linux_resume_one_lwp that the
thread should be set back to stepping.
- In a couple places, we were resuming threads that are meant to be
suspended. E.g., when a vCont;c/s request for thread B comes in
just while gdbserver is stepping thread A past a breakpoint. The
resume for thread B must be deferred until the step-over finishes.
- The test runs with both "set detach-on-fork" on and off. When off,
it exercises the case of GDB detaching the fork child explicitly.
When on, it exercises the case of gdb resuming the child
explicitly. In the "off" case, gdb seems to exponentially become
slower as new inferiors are created. This is _very_ noticeable as
with only 100 inferiors gdb is crawling already, which makes the
test take quite a bit to run. For that reason, I've disabled the
"off" variant for now.
gdb/ChangeLog:
2015-08-06 Pedro Alves <palves@redhat.com>
* target/waitstatus.h (enum target_stop_reason)
<TARGET_STOPPED_BY_SINGLE_STEP>: New value.
gdb/gdbserver/ChangeLog:
2015-08-06 Pedro Alves <palves@redhat.com>
* linux-low.c (handle_extended_wait): Set the fork child's suspend
count if stopping and suspending threads.
(check_stopped_by_breakpoint): If stopped by trace, set the LWP's
stop reason to TARGET_STOPPED_BY_SINGLE_STEP.
(linux_detach): Complete an ongoing step-over.
(lwp_suspended_inc, lwp_suspended_decr): New functions. Use
throughout.
(resume_stopped_resumed_lwps): Don't resume a suspended thread.
(linux_wait_1): If passing a signal to the inferior after
finishing a step-over, unsuspend and re-resume all lwps. If we
see a single-step event but the thread should be continuing, don't
pass the trap to gdb.
(stuck_in_jump_pad_callback, move_out_of_jump_pad_callback): Use
internal_error instead of gdb_assert.
(enqueue_pending_signal): New function.
(check_ptrace_stopped_lwp_gone): Add debug output.
(start_step_over): Use internal_error instead of gdb_assert.
(complete_ongoing_step_over): New function.
(linux_resume_one_thread): Don't resume a suspended thread.
(proceed_one_lwp): If the LWP is stepping over a breakpoint, reset
it stepping.
gdb/testsuite/ChangeLog:
2015-08-06 Pedro Alves <palves@redhat.com>
* gdb.threads/forking-threads-plus-breakpoint.exp: New file.
* gdb.threads/forking-threads-plus-breakpoint.c: New file.
At https://sourceware.org/ml/gdb-patches/2015-08/msg00097.html, Joel
observed that trying to next/step a program on GNU/Linux sometimes
results in the following failed assertion:
% gdb -q .obj/gprof/main
(gdb) start
(gdb) n
(gdb) step
[...]/infrun.c:2391: internal-error:
resume: Assertion `sig != GDB_SIGNAL_0' failed.
What happened is that, during the "next" operation, GDB hit a
longjmp/exception/step-resume breakpoint but failed to see that this
breakpoint was set for a different thread than the one being stepped.
Joel's detailed analysis follows:
More precisely, at the end of the "start" command, we are stopped at
the start of function Main in main.adb; there are 4 threads in total,
and we are in the main thread (which is thread 1):
(gdb) info thread
Id Target Id Frame
4 Thread 0xb7a56ba0 (LWP 28379) 0xffffe410 in __kernel_vsyscall ()
3 Thread 0xb7c5aba0 (LWP 28378) 0xffffe410 in __kernel_vsyscall ()
2 Thread 0xb7e5eba0 (LWP 28377) 0xffffe410 in __kernel_vsyscall ()
* 1 Thread 0xb7ea18c0 (LWP 28370) main () at /[...]/main.adb:57
All the logs below reference Thread ID/LWP, but it'll be easier to
talk about the threads by GDB thread number. For instance, thread 1
is LWP 28370 while thread 3 is LWP 28378. So, the explanations below
translate the LWPs into thread numbers.
Back to what happens while we are trying to "next' our program:
(gdb) n
infrun: clear_proceed_status_thread (Thread 0xb7a56ba0 (LWP 28379))
infrun: clear_proceed_status_thread (Thread 0xb7c5aba0 (LWP 28378))
infrun: clear_proceed_status_thread (Thread 0xb7e5eba0 (LWP 28377))
infrun: clear_proceed_status_thread (Thread 0xb7ea18c0 (LWP 28370))
infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0xb7ea18c0 (LWP 28370)] at 0x805451e
infrun: target_wait (-1.0.0, status) =
infrun: 28370.28370.0 [Thread 0xb7ea18c0 (LWP 28370)],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x8054523
We've resumed thread 1 (LWP 28370), and received in return a signal
that the same thread stopped slightly further. It's still in the
range of instructions for the line of source we started the "next"
from, as evidenced by the following trace...
infrun: stepping inside range [0x805451e-0x8054531]
... and thus, we decide to continue stepping the same thread:
infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0xb7ea18c0 (LWP 28370)] at 0x8054523
infrun: prepare_to_wait
That's when we get an event from a different thread (thread 3)...
infrun: target_wait (-1.0.0, status) =
infrun: 28370.28378.0 [Thread 0xb7c5aba0 (LWP 28378)],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x80782d0
infrun: context switch
infrun: Switching context from Thread 0xb7ea18c0 (LWP 28370) to Thread 0xb7c5aba0 (LWP 28378)
... which we find to be at the address where we set a breakpoint on
"the unwinder debug hook" (namely "_Unwind_DebugHook"). But GDB fails
to notice that the breakpoint was inserted for thread 1 only, and so
decides to handle it as...
infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME
... and inserts a breakpoint at the corresponding resume address, as
evidenced by this the next log:
infrun: exception resume at 80542a2
That breakpoint seems innocent right now, but will play a role fairly
quickly. But for now, GDB has inserted the exception-resume
breakpoint, and needs to single-step thread 3 past the breakpoint it
just hit. Thus, it temporarily disables the exception breakpoint, and
requests a step of that thread:
infrun: skipping breakpoint: stepping past insn at: 0x80782d0
infrun: skipping breakpoint: stepping past insn at: 0x80782d0
infrun: skipping breakpoint: stepping past insn at: 0x80782d0
infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=1, current thread [Thread 0xb7c5aba0 (LWP 28378)] at 0x80782d0
infrun: prepare_to_wait
We then get a notification, still from thread 3, that it's now past
that breakpoint...
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 28370.28378.0 [Thread 0xb7c5aba0 (LWP 28378)],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x8078424
... so we can resume what we were doing before, which is single-stepping
thread 1 until we get to a new line of code:
infrun: switching back to stepped thread
infrun: Switching context from Thread 0xb7c5aba0 (LWP 28378) to Thread 0xb7ea18c0 (LWP 28370)
infrun: expected thread still hasn't advanced
infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [Thread 0xb7ea18c0 (LWP 28370)] at 0x8054523
The "resume" log above shows that we're resuming thread 1 from where
we left off (0x8054523). We get one more stop at 0x8054529, which is
still inside our stepping range so we go again. That's when we get
the following event, from thread 3:
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun: 28370.28378.0 [Thread 0xb7c5aba0 (LWP 28378)],
infrun: status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: TARGET_WAITKIND_STOPPED
infrun: stop_pc = 0x80542a2
Now the stop_pc address is interesting, because it's the address of
"exception resume" breakpoint...
infrun: context switch
infrun: Switching context from Thread 0xb7ea18c0 (LWP 28370) to Thread 0xb7c5aba0 (LWP 28378)
infrun: BPSTAT_WHAT_CLEAR_LONGJMP_RESUME
... and since that location is at a different line of code, this is
where it decides the "next" operation should stop:
infrun: stop_waiting
[Switching to Thread 0xb7c5aba0 (LWP 28378)]
0x080542a2 in inte_tache_rt.ttache_rt (
<_task>=0x80968ec <inte_tache_rt_inst.tache2>)
at /[...]/inte_tache_rt.adb:54
54 end loop;
However, what GDB should have noticed earlier that the exception
breakpoint we hit was for a different thread, thus should have
single-stepped that thread out of the breakpoint _without_ inserting
the exception-return breakpoint, and then resumed the single-stepping
of the initial thread (thread 1) until that thread stepped out of its
stepping range.
This is what this patch does, and after applying it, GDB now correctly
stops on the next line of code.
The patch adds a C++ test that exercises this, both for setjmp/longjmp
and exception breakpoints. With an unpatched GDB it shows:
(gdb) next
[Switching to Thread 22445.22455]
thread_try_catch (arg=0x0) at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/next-other-thr-longjmp.c:59
59 catch (...)
(gdb) FAIL: gdb.threads/next-other-thr-longjmp.exp: next to line 1
next
/home/pedro/gdb/mygit/build/../src/gdb/infrun.c:4865: internal-error: process_event_stop_test: Assertion `ecs->event_thread->control.exception_resume_breakpoint != NULL' fa
iled.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.threads/next-other-thr-longjmp.exp: next to line 2 (GDB internal error)
Resyncing due to internal error.
n
Tested on x86_64-linux, no regressions.
gdb/ChangeLog:
2015-08-05 Pedro Alves <palves@redhat.com>
Joel Brobecker <brobecker@adacore.com>
* breakpoint.c (bpstat_what) <bp_longjmp, bp_longjmp_call_dummy>
<bp_exception, bp_longjmp_resume, bp_exception_resume>: Handle the
case where BS->STOP is not set.
gdb/testsuite/ChangeLog:
2015-08-05 Pedro Alves <palves@redhat.com>
* gdb.threads/next-while-other-thread-longjmps.c: New file.
* gdb.threads/next-while-other-thread-longjmps.exp: New file.
2015-08-03 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.base/bp-permanent.exp: Report test as unsupported if
the target cannot stop at the permanent breakpoint.
These testcases are mocks of real programs.
GDB doesn't care what the programs do, they just have to look
and/or behave like the real program.
These testcases exercise gdb when debugging really large programs.
E.g., gmonster-1 has 10,000 CUs, and gmonster-2 has 1000 shared libs
(which is actually a little small, 5000 would be more accurate).
gdb/testsuite/ChangeLog:
* gdb.perf/lib/perftest/utils.py: New file.
* gdb.perf/gm-hello.cc: New file.
* gdb.perf/gm-pervasive-typedef.cc: New file.
* gdb.perf/gm-pervasive-typedef.h: New file.
* gdb.perf/gm-std.cc: New file.
* gdb.perf/gm-std.h: New file.
* gdb.perf/gm-use-cerr.cc: New file.
* gdb.perf/gm-utils.h: New file.
* gdb.perf/gmonster-null-lookup.py: New file.
* gdb.perf/gmonster-pervasive-typedef.py: New file.
* gdb.perf/gmonster-print-cerr.py: New file.
* gdb.perf/gmonster-ptype-string.py: New file.
* gdb.perf/gmonster-runto-main.py: New file.
* gdb.perf/gmonster-select-file.py: New file.
* gdb.perf/gmonster1-null-lookup.exp: New file.
* gdb.perf/gmonster1-pervasive-typedef.exp: New file.
* gdb.perf/gmonster1-print-cerr.exp: New file.
* gdb.perf/gmonster1-ptype-string.exp: New file.
* gdb.perf/gmonster1-runto-main.exp: New file.
* gdb.perf/gmonster1-select-file.exp: New file.
* gdb.perf/gmonster1.cc: New file.
* gdb.perf/gmonster1.exp: New file.
* gdb.perf/gmonster2-null-lookup.exp: New file.
* gdb.perf/gmonster2-pervasive-typedef.exp: New file.
* gdb.perf/gmonster2-print-cerr.exp: New file.
* gdb.perf/gmonster2-ptype-string.exp: New file.
* gdb.perf/gmonster2-runto-main.exp: New file.
* gdb.perf/gmonster2-select-file.exp: New file.
* gdb.perf/gmonster2.cc: New file.
* gdb.perf/gmonster2.exp: New file.
single-step.exp takes a while to run, and while that's not necessarily
bad, here it's because the default value of SINGLE_STEP_COUNT is 10,000.
We're not going to gain any more insight into perf issues
single-stepping (stepi) 10,000 times over 1,000 times,
so this patch changes the default to 1,000.
gdb/testsuite/ChangeLog:
* gdb.perf/single-step.exp (SINGLE_STEP_COUNT): Change to 1000 from
10000.
gdb/testsuite/ChangeLog:
* Makefile.in (workers/%.worker, build-perf): New rule.
(GDB_PERFTEST_MODE): New variable.
(check-perf): Use it.
(clean): Clean up gdb.perf parallel build subdirs.
* lib/build-piece.exp: New file.
* lib/gdb.exp (make_gdb_parallel_path): New function
(standard_output_file, standard_temp_file): Call it.
(GDB_PARALLEL handling): Make outputs,temp,cache directories as subdirs
of $GDB_PARALLEL.
* lib/cache.exp (gdb_do_cache): Call make_gdb_parallel_path.
This patch does two things.
1) Add support for multiple data points.
2) Move the "report" output from perftest.log to perftest.sum.
I want to record the raw data somewhere, and a bit of statistical analysis
(standard deviation left for another day), but I also don't want
it to clutter up the basic report.
This patch takes a cue from gdb.{sum,log} and does the same thing
with perftest.{sum,log}.
Ultimately, we'll probably want to emit raw data to csv files or some
such and then do post-processing passes on that.
gdb/testsuite/ChangeLog:
* lib/perftest/reporter.py (SUM_FILE_NAME): New global.
(LOG_FILE_NAME): New global.
(TextReporter.__init__): Initialize self.txt_sum.
(TextReporter.report): Add support for multiple data-points.
Move report to perftest.sum, put raw data in perftest.log.
(TextReporter.start): Open sum and log files.
(TextReporter.end): Close sum and log files.
* lib/perftest/testresult.py (SingleStatisticTestResult.record): Handle
multiple data-points.
The buildbots show that attach-many-short-lived-thread.exp is racy.
But after staring at debug logs and playing with SystemTap scripts for
a (long) while, I figured out that neither GDB, nor the kernel nor the
test's program itself are at fault.
The problem is simply that the testsuite machinery is currently
subject to PID-reuse races. The attach-many-short-lived-threads.c
test program just happens to be much more susceptible to trigger this
race because threads and processes share the same number space on
Linux, and the test spawns many many short lived threads in
succession, thus enlarging the race window a lot.
Part of the problem is that several tests spawn processes with "exec&"
(in order to test the "attach" command) , and then at the end of the
test, to make sure things are cleaned up, issue a 'remote_spawn "kill
-p $testpid"'. Since with tcl's "exec&", tcl itself is responsible
for reaping the process's exit status, when we go kill the process,
testpid may have already exited _and_ its status may have (and often
has) been reaped already. Thus it can happen that another process
meanwhile reuses $testpid, and that "kill" command kills the wrong
process... Frequently, that happens to be
attach-many-short-lived-thread, but this explains other test's races
as well.
In the attach-many-short-lived-threads test, it sometimes manifests
like this:
(gdb) file /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads
Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads...done.
(gdb) Loaded /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads into /home/pedro/gdb/mygit/build/gdb/testsuite/../../gdb/gdb
attach 5940
Attaching to program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/attach-many-short-lived-threads, process 5940
warning: process 5940 is a zombie - the process has already terminated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ptrace: Operation not permitted.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: attach
info threads
No threads.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: no new threads
set breakpoint always-inserted on
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 1: set breakpoint always-inserted on
Other times the process dies while the test is ongoing (the process is
ptrace-stopped):
(gdb) print again = 1
Cannot access memory at address 0x6020cc
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: reset timer in the inferior
(Recall that on Linux, SIGKILL is not interceptable)
And other times it dies just while we're detaching:
$4 = 319
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 2: print seconds_left
detach
Can't detach Thread 0x7fb13b7de700 (LWP 1842): No such process
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 2: detach
GDB mishandles the latter (it should ignore ESRCH while detaching just
like when continuing), but that's another story.
The fix here is to change spawn_wait_for_attach to use Expect's
'spawn' command instead of Tcl's 'exec&' to spawn programs, because
with spawn we control when to wait for/reap the process. That allows
killing the process by PID without being subject to pid-reuse races,
because even if the process is already dead, the kernel won't reuse
the process's PID until the zombie is reaped.
The other part of the problem lies in DejaGnu itself, unfortunately.
I have occasionally seen tests (attach-many-short-lived-threads
included, but not only that one) die with a random inexplicable
SIGTERM too, and that too is caused by the same reason, except that in
that case, the rogue SIGTERM is sent from this bit in DejaGnu's remote.exp:
exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &"
...
catch "wait -i $shell_id"
Even if the program exits promptly, that whole cascade of kills
carries on in the background, thus potentially killing the poor
process that manages to reuse $pid...
I sent a fix for that to the DejaGnu list:
http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00000.html
With both patches in place, I haven't seen
attach-many-short-lived-threads.exp fail again.
Tested on x86_64 Fedora 20, native, gdbserver and extended-gdbserver.
gdb/testsuite/ChangeLog:
2015-07-31 Pedro Alves <palves@redhat.com>
* gdb.base/attach-pie-misread.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* gdb.base/attach-pie-noexec.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/attach-twice.exp: Likewise.
* gdb.base/attach.exp: Likewise.
(do_command_attach_tests): Use gdb_spawn_with_cmdline_opts and
gdb_test_multiple.
* gdb.base/solib-overlap.exp: Adjust to spawn_wait_for_attach
returning a spawn id instead of a pid. Use spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/valgrind-infcall.exp: Likewise.
* gdb.multi/multi-attach.exp: Likewise.
* gdb.python/py-prompt.exp: Likewise.
* gdb.python/py-sync-interp.exp: Likewise.
* gdb.server/ext-attach.exp: Likewise.
* gdb.threads/attach-into-signal.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.threads/attach-many-short-lived-threads.exp: Adjust to
spawn_wait_for_attach returning a spawn id instead of a pid. Use
spawn_id_get_pid and kill_wait_spawned_process.
* gdb.threads/attach-stopped.exp (corefunc): Use
spawn_wait_for_attach, spawn_id_get_pid and
kill_wait_spawned_process.
* gdb.base/break-interp.exp: Rename $res to $test_spawn_id.
Use spawn_id_get_pid. Wait for spawn id after eof. Use
kill_wait_spawned_process instead of explicit "kill -9".
* lib/gdb.exp (can_spawn_for_attach): Adjust comment.
(kill_wait_spawned_process, spawn_id_get_pid): New procedures.
(spawn_wait_for_attach): Use spawn instead of exec to spawn
processes. Don't map cygwin/windows pids here. Now returns a
spawn id list.
Running gdb.threads/fork-plus-threads.exp against gdbserver in
extended-remote mode, even though the test passes, we still see broken
behavior:
(gdb) PASS: gdb.threads/fork-plus-threads.exp: set detach-on-fork off
continue &
Continuing.
(gdb) PASS: gdb.threads/fork-plus-threads.exp: continue &
[New Thread 28092.28092]
[Thread 28092.28092] #2 stopped.
[New Thread 28094.28094]
[Inferior 2 (process 28092) exited normally]
[New Thread 28094.28105]
[New Thread 28094.28109]
...
[Thread 28174.28174] #18 stopped.
[New Thread 28185.28185]
[Inferior 10 (process 28174) exited normally]
[New Thread 28185.28196]
[Thread 28185.28185] #20 stopped.
Cannot remove breakpoints because program is no longer writable.
Further execution is probably impossible.
[Inferior 11 (process 28185) exited normally]
[Inferior 1 (process 28091) exited normally]
PASS: gdb.threads/fork-plus-threads.exp: reached breakpoint
info threads
No threads.
(gdb) PASS: gdb.threads/fork-plus-threads.exp: no threads left
info inferiors
Num Description Executable
* 1 <null> /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.threads/fork-plus-threads
(gdb) PASS: gdb.threads/fork-plus-threads.exp: only inferior 1 left
All the "[Thread FOO] #NN stopped." above are bogus, as well as the
"Cannot remove breakpoints because program is no longer writable.",
which is a consequence.
The problem is that when we intercept a fork event, we should report
the event for the parent, only, and leave the child stopped, but not
report its stop event. GDB later decides whether to follow the parent
or the child. But because handle_extended_wait does not set the
child's last_status.kind to TARGET_WAITKIND_STOPPED, a
stop_all_threads/unstop_all_lwps sequence (e.g., from trying to access
memory) by mistake ends up queueing a SIGSTOP on the child, resuming
it, and then when that SIGSTOP is intercepted, because the LWP has
last_resume_kind set to resume_stop, gdbserver reports the stop to
GDB, as GDB_SIGNAL_0:
...
>>>> entering unstop_all_lwps
unstopping all lwps
proceed_one_lwp: lwp 1600
client wants LWP to remain 1600 stopped
proceed_one_lwp: lwp 1828
Client wants LWP 1828 to stop. Making sure it has a SIGSTOP pending
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sending sigstop to lwp 1828
pc is 0x3615ebc7cc
Resuming lwp 1828 (continue, signal 0, stop expected)
continue from pc 0x3615ebc7cc
unstop_all_lwps done
sigchld_handler
<<<< exiting unstop_all_lwps
handling possible target event
>>>> entering linux_wait_1
linux_wait_1: [<all threads>]
my_waitpid (-1, 0x40000001)
my_waitpid (-1, 0x1): status(137f), 1828
LWFE: waitpid(-1, ...) returned 1828, ERRNO-OK
LLW: waitpid 1828 received Stopped (signal) (stopped)
pc is 0x3615ebc7cc
Expected stop.
LLW: resume_stop SIGSTOP caught for LWP 1828.1828.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
linux_wait_1 ret = LWP 1828.1828, 1, 0
<<<< exiting linux_wait_1
Writing resume reply for LWP 1828.1828:1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Tested on x86_64 Fedora 20, extended-remote.
gdb/gdbserver/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
* linux-low.c (handle_extended_wait): Set the child's last
reported status to TARGET_WAITKIND_STOPPED.
The new gdb.threads/fork-plus-threads.exp test exposes one more
problem. When one types "info inferiors" after running the program,
one see's a couple inferior left still, while there should only be
inferior #1 left. E.g.:
(gdb) info inferiors
Num Description Executable
4 process 8393 /home/pedro/bugs/src/test
2 process 8388 /home/pedro/bugs/src/test
* 1 <null> /home/pedro/bugs/src/test
(gdb) info threads
Calling prune_inferiors() manually at this point (from a top gdb) does
not remove them, because they still have inf->pid != 0 (while they
shouldn't). This suggests that we never mourned those inferiors.
Enabling logs (master + previous patch) we see:
...
WL: waitpid Thread 0x7ffff7fc2740 (LWP 9513) received Trace/breakpoint trap (stopped)
WL: Handling extended status 0x03057f
LHEW: Got clone event from LWP 9513, new child is LWP 9579
[New Thread 0x7ffff37b8700 (LWP 9579)]
WL: waitpid Thread 0x7ffff7fc2740 (LWP 9508) received 0 (exited)
WL: Thread 0x7ffff7fc2740 (LWP 9508) exited.
^^^^^^^^
[Thread 0x7ffff7fc2740 (LWP 9508) exited]
WL: waitpid Thread 0x7ffff7fc2740 (LWP 9499) received 0 (exited)
WL: Thread 0x7ffff7fc2740 (LWP 9499) exited.
[Thread 0x7ffff7fc2740 (LWP 9499) exited]
RSRL: resuming stopped-resumed LWP Thread 0x7ffff37b8700 (LWP 9579) at 0x3615ef4ce1: step=0
...
(gdb) info inferiors
Num Description Executable
5 process 9508 /home/pedro/bugs/src/test
^^^^
4 process 9503 /home/pedro/bugs/src/test
3 process 9500 /home/pedro/bugs/src/test
2 process 9499 /home/pedro/bugs/src/test
* 1 <null> /home/pedro/bugs/src/test
(gdb)
...
Note the "Thread 0x7ffff7fc2740 (LWP 9508) exited." line.
That's this in wait_lwp:
/* Check if the thread has exited. */
if (WIFEXITED (status) || WIFSIGNALED (status))
{
thread_dead = 1;
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog, "WL: %s exited.\n",
target_pid_to_str (lp->ptid));
}
}
That was the leader thread reporting an exit, meaning the whole
process is gone. So the problem is that this code doesn't understand
that an WIFEXITED status of the leader LWP should be reported to
infrun as process exit.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
PR threads/18600
* linux-nat.c (wait_lwp): Report to the core when thread group
leader exits.
gdb/testsuite/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.exp: Test that "info inferiors"
only shows inferior 1.
When a program forks and another process start threads while gdb is
handling the fork event, newly created threads are left stuck stopped
by gdb, even though gdb presents them as "running", to the user.
This can be seen with the test added by this patch. The test has the
inferior fork a certain number of times and waits for all children to
exit. Each fork child spawns a number of threads that do nothing and
joins them immediately. Normally, the program should run unimpeded
(from the point of view of the user) and exit very quickly. Without
this fix, it doesn't because of some threads left stopped by gdb, so
inferior 1 never exits.
The program triggers when a new clone thread is found while inside the
linux_stop_and_wait_all_lwps call in linux-thread-db.c:
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
thread_from_lwp (lp->ptid);
linux_unstop_all_lwps ();
Within linux_stop_and_wait_all_lwps, we reach
linux_handle_extended_wait with the "stopping" parameter set to 1, and
because of that we don't mark the new lwp as resumed. As consequence,
the subsequent resume_stopped_resumed_lwps, called from
linux_unstop_all_lwps, never resumes the new LWP.
There's lots of cruft in linux_handle_extended_wait that no longer
makes sense. On systems with CLONE events support, we don't rely on
libthread_db for thread listing anymore, so the code that preserves
stop_requested and the handling of last_resume_kind is all dead.
So the fix is to remove all that, and simply always mark the new LWP
as resumed, so that resume_stopped_resumed_lwps re-resumes it.
gdb/ChangeLog:
2015-07-30 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
PR threads/18600
* linux-nat.c (linux_handle_extended_wait): On CLONE event, always
mark the new thread as resumed. Remove STOPPING parameter.
(wait_lwp): Adjust call to linux_handle_extended_wait.
(linux_nat_filter_event): Adjust call to
linux_handle_extended_wait.
(resume_stopped_resumed_lwps): Add debug output.
gdb/testsuite/ChangeLog:
2015-07-30 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>
PR threads/18600
* gdb.threads/fork-plus-threads.c: New file.
* gdb.threads/fork-plus-threads.exp: New file.
Just a slight cleanup. Committed as obvious.
gdb/testsuite/ChangeLog:
* gdb.base/batch-preserve-term-settings.exp
(test_terminal_settings_preserved_after_cli_exit): Use
send_quit_command.
Tested on x86_64 Debian Stretch, native, gdbserver and
extended-gdbserver. Also tested that the various error paths, like if
$PPID is empty or if SIGTERM did not not kill GDB, function correctly.
gdb/testsuite/ChangeLog:
* gdb.base/batch-preserve-term-settings.exp (send_quit_command):
New proc.
(test_terminal_settings_preserved_after_sigterm): New test.
Now that we can expect inferior output with the gdbserver boards, this
is all it takes to have the test pass against extended-remote
gdbserver.
Don Breazeal originally wrong something like this:
https://sourceware.org/ml/gdb-patches/2015-03/msg00506.html
which was what originally inspired the introduction of
$inferior_spawn_id.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
Don Breazeal <donb@codesourcery.com>
* gdb.base/multi-forks.exp (continue_to_exit_bp_loc): Expect
output from both inferior_spawn_id and gdb_spawn_id.
Hi,
While examining BuildBot's logs, I noticed:
<https://sourceware.org/ml/gdb-testers/2015-q3/msg03767.html>
gdb.threads/attach-into-signal.exp has two nested loops and don't use
unique messages. This commit fixes that. Pushed under the obvious
rule.
gdb/testsuite/ChangeLog:
2015-07-29 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.threads/attach-into-signal.exp (corefunc): Use
with_test_prefix on nested loops, uniquefying the test messages.
My last commit d60a92216e introduced a
regression caused by a typo. This fixes it. Checked in as obvious.
Thanks to Pedro for reporting.
gdb/testsuite/ChangeLog:
2015-07-29 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.python/py-objfile.exp: Fix typo that snuck in from my last
commit.
When exiting GDB -- whether it's via the "quit" command, via a SIGTERM,
or otherwise -- we should leave the terminal in the state we acquired
it. To that end, we have to undo any modifications that may have been
made by the TUI (ncurses) or by the CLI (readline).
Tested on x86_64 Debian Stretch.
gdb/ChangeLog:
* top.c: Include "tui/tui.h".
(undo_terminal_modifications_before_exit): New static function.
(quit_force): Use it.
gdb/testsuite/ChangeLog:
* gdb.base/batch-preserve-term-settings.exp
(test_terminal_settings_preserved_after_cli_exit): New test.
See ChangeLog for details. No functional change intended.
Tested on x86_64 Debian Stretch by verifying that the gdb.log output
remains unchanged for native, gdbserver and extended-gdbserver.
gdb/testsuite/ChangeLog:
* gdb.base/batch-preserve-term-settings.exp: Remove top-level
manipulation of saved_gdbflags.
(test_terminal_settings_preserved): Remove global declaration of
the unused variable pagination_prompt. Remove manipulation of
saved_gdbflags. Use a local variable EXTRA_GDBFLAGS instead of
GDBFLAGS.
As all tests that check gdb,noinferiorio have been adjusted to expect
inferior output with "-i $inferior_spawn_id", we can remove this now,
and thus enable those tests against gdbserver.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* boards/gdbserver-base.exp: Don't set gdb,noinferiorio.
The following patch will remove the gdb,noinferiorio setting from the
gdbserver boards, so this bit can be reverted.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/interrupt.exp: Revert back to checking gdb,noinferiorio
at the top.
This forces all tests that rely on stdio to be unbuffered, like
interrupt.exp was adjusted in 6f98576f.
To recap, in some scenarios, GDB or GDBserver can be spawned with
input _not_ connected to a tty, and then tests that rely on stdio fail
with timeouts, because the inferior's stdout and stderr streams end up
fully buffered. Calling gdb_unbuffer_output forces output to be
unbuffered.
See https://sourceware.org/ml/gdb-patches/2015-02/msg00809.html and
https://sourceware.org/ml/gdb-patches/2015-02/msg00819.html.
Tested on x86_64 Fedora 20, native, and against a remote gdbserver
board file that connects to the target with ssh, with and without -t
(create pty).
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/call-ar-st.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/call-rt-st.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/call-strs.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/call-strs.exp: Adjust to step over the
gdb_unbuffer_output call.
* gdb.base/catch-gdb-caused-signals.c: Include
"../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/dprintf.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/ending-run.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/run.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/shlib-call.exp: Adjust to step over the
gdb_unbuffer_output call.
* gdb.base/shmain.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/sizeof.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
* gdb.base/varargs.c: Include "../lib/unbuffer_output.c".
(main): Rename to ...
(test): ... this.
(main): Reimplement.
* gdb.base/varargs.exp: Run to test instead of to main.
* gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-dprintf.exp (mi_expect_dprintf): New procedure,
factore out from mi_continue_dprintf. For call-style dprintfs,
expect dprintf output out of $inferior_spawn_id.
(mi_continue_dprintf): Use mi_expect_dprintf.
* gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c".
(main): Call gdb_unbuffer_output.
Rather than trying to determine where (which spawn id) the inferior
output comes out from, which depends on e.g., remote that supports
file i/o remote protocol extension, vs remote that sends inferior
output through a separate $inferior_spawn_id, vs native debugging,
which sends output through $gdb_spawn_id, vs native debugging with a
test that uses "separate-inferior-tty" (like mi-console.exp does),
always expect inferior output from both $inferior_spawn_id and
$gdb_spawn_id.
mi-console.exp itself already copes with different possible outputs in
a similar way:
# Combine both outputs in a single pattern.
set output "($semihosted_output|$native_output)"
Fixes:
FAIL: gdb.mi/mi-console.exp: Testing console output inferior output (timeout)
when testing against local gdbserver with gdb,noinferiorio removed
from the board file.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* lib/mi-support.exp (mi_inferior_spawn_id): Delete.
(default_mi_gdb_start): Set inferior_spawn_id instead of
mi_inferior_spawn_id. If $inferior_spawn_id is not set, set it to
gdb_spawn_id.
(mi_gdb_test): Always expect inferior output from both
$inferior_spawn_id and $gdb_spawn_id.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.gdb/selftest.exp (test_with_self): Update comment. Use
send_inferior and $inferior_spawn_id.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/call-rt-st.exp (print_struct_call): Split "result"
parameter into two new parameters, "inf_result" and "gdb_result".
Expect inferior output and gdb output from $inferior_spawn_id and
$gdb_spawn_id, respectively. Adjust all callers.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/call-ar-st.exp: Use gdb_test_stdio+multi_line instead
of gdb_test_sequence.
This one is a little more complicated than the other patches in this
series, because of the exit status wrapper handling, requiring a
little state machine.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/a2-run.exp (saw_usage, saw_exit_wrapper)
(saw_spurious_output): Expect inferior output from
$inferior_spawn_id. Use gdb_test_stdio.
This one needed a larger revamp. The issue is that the "info
breakpoints" test at the bottom of the file is broken on targets that
can do both server-side dprintf, and inferior I/O, because then
neither the breakpoint numbers match nor the "already hit N times"
output.
Address that by making the test restart gdb from scratch when
switching between dprintf styles. Test groups are factored into
procedures, and we now use with_test_prefix. While we're changing
test messages, lowercase a few test messages, and then while at it,
modernize a couple things here and there.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/dprintf.exp: Use standard_testfile. Change
prepare_for_testing call.
(srcfile): Don't set.
(restart): New procedure.
(test_dprintf): New procecure, use to continue over dprintfs.
(test_call, test_agent): New procedures, tests moved here.
Restart gdb and recreate dprintfs. Adjust expected output.
This adds a new helper procedure to be used by tests that rely on
stdio.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_test_stdio): New procedure.
There seems to be no point in relying on stdio here. Simply use
gdb_continue_to_end instead.
(not removing the printf calls, as the .c file is half generated.)
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/restore.exp (restore_tests): Use gdb_continue_to_end.
These tests rely on inferior I/O, but that seems pointless and
unrelated here. Simply remove the printf calls, and don't expect
them.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/call-signal-resume.exp: Remove check for
gdb,noinferiorio. Don't expect "no signal". Use gdb_test.
* gdb.base/unwindonsignal.exp: Likewise.
* gdb.base/call-signals.c (gen_signal): Remove printf call.
* gdb.base/unwindonsignal.c (gen_signal): Likewise.
No point in relying on stdio in this test. Simply run to a breakpoint
instead.
gdb/testsuite/ChangeLog:
2015-07-29 Pedro Alves <palves@redhat.com>
* gdb.base/siginfo-addr.c (pass): New function.
(handler): Call it iff si_addr is correct.
* gdb.base/siginfo-addr.exp: Remove gdb_skip_stdio_test check.
Set a breakpoint at "pass" and continue to it.
While running some regression tests, I noticed that the two Python
tests mentioned in the $SUBJECT contain non-unique names. This is a
violation of our guidelines:
<https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Make_sure_test_messages_are_unique>
And also makes things harder for BuildBot. So I hacked both testcases
and made every test name unique. I guess this could be considered an
obvious patch, but I decided to post it before pushing because others
may have different opinions about the names.
OK to apply?
gdb/testsuite/ChangeLog:
2015-07-28 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.python/py-objfile.exp: Make some tests have unique names.
* gdb.python/py-pp-registration.exp: Likewise.
This test fails with --target_board=native-extended-gdbserver because
it misses the usual "disconnect":
(gdb) spawn ../gdbserver/gdbserver --once :2347 /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.server/server-exec-info
Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.server/server-exec-info created; pid = 4736
Listening on port 2347
target extended-remote localhost:2347
Already connected to a remote target. Disconnect? (y or n) ^CsQuit
(gdb) et sysroot remote:
Undefined command: "et". Try "help".
(gdb) n
The program is not being run.
(gdb) FAIL: gdb.server/server-exec-info.exp: set sysroot remote: (got interactive prompt)
info files
(gdb) FAIL: gdb.server/server-exec-info.exp: info files
gdb/testsuite/ChangeLog:
2015-07-28 Pedro Alves <palves@redhat.com>
* gdb.server/server-exec-info.exp: Issue a "disconnect".
Using gcc 5.2 (maybe other versions as well), building mi-pending.c gives
these warnings:
./gdb.mi/mi-pending.c: In function ‘thread_func’:
./gdb.mi/mi-pending.c:34:5: warning: ‘return’ with no value, in function returning non-void
return;
^
./gdb.mi/mi-pending.c:38:5: warning: ‘return’ with no value, in function returning non-void
return;
^
gdb_compile_pthreads assumes that the build was successful only if there
is no output. These warnings therefore make gdb_compile_pthreads think
that the build failed, and the test doesn't run.
The easy fix is to replace the "return" with "return NULL". I am
pushing this as obvious.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-pending.c (thread_func): Replace return with return
NULL.
I noticed there was an unexpected pass in mi-watch.exp when running on
x86_64. Doing a bit of archeology shows that the xfail was added by
4a543da. This particular test failed on the MIPS architecture, which
the original contributor was working with. Here is the thread:
https://www.sourceware.org/ml/gdb-patches/2007-09/msg00151.html
Looking at the latest buildbot results for MIPS, it seems that it's also
an unexpected pass on that architecture. Therefore, I see no reason to
leave the xfail in place.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-watch.exp (test_watchpoint_triggering): Remove xfail.
GDB currently does not promptly quit after receiving a SIGTERM while no
proper target is active. This is because in handle_sigterm we currently
look at target_can_async_p to determine whether to asynchronously quit
GDB using an async signal handler or to asynchronously quit using the
quit flag. However, target_can_async_p is always false under the dummy
target, so under this target we always use the quit flag and not the
async signal handler to signal that GDB should quit. So GDB won't quit
until a code path that checks the quit flag is executed.
To fix this issue, this patch makes the SIGTERM handler no longer
inspect target_can_async_p, and instead makes the handler
unconditionally set the quit flag _and_ mark the corresponding async
signal handler, so that if the target is async (or if it's the dummy
target) then we will likely quit through the async signal handler, and
if it's not async then we will likely quit through the quit flag. This
redundant approach is similar to how we handle SIGINT.
gdb/ChangeLog:
* event-top.c (handle_sigterm): Don't inspect
target_can_async_p. Always set the quit flag and always mark
the async signal handler.
gdb/testsuite/ChangeLog:
* gdb.base/gdb-sigterm-2.exp: New test.
I happen to see REMOTE_EXAMPLES isn't used anywhere, so this patch
removes it.
REMOTE_EXAMPLES was added in the following commit in 1991,
commit 86bbb439c8
Author: John Gilmore <gnu@cygnus>
Date: Fri May 3 19:57:13 1991 +0000
There should be a Makefile in the cvs main directory, configured
for "./config.gdb none", so that things like "make tags" and "make tar"
will work.
and it was used like:
TARFILES = ${TAGFILES_MAINDIR} ${OTHERS} ${REMOTE_EXAMPLES}
However TARFILES was removed by the change latter in 1994,
Tue Aug 16 15:24:03 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
* symtab.c (decode_line_1): If funfirstline and we get a
non-LOC_BLOCK symbol (e.g. variable or type), then error().
* Makefile.in (TARFILES, NONSRC, SFILES_STAND, SFILES_KGDB):
Remove; unused.
Since then, REMOTE_EXAMPLES is not used any more.
gdb:
2015-07-27 Yao Qi <yao.qi@linaro.org>
* Makefile.in (REMOTE_EXAMPLES): Remove it.
This reverts commit b558ff043d.
This reverts commit 4a11f20659.
The initial import commit failed to retain local changes made to
readline's configure.in (and the commit message erroneously stated that
there were no local changes that needed to be reapplied). Also the
import caused a couple of build errors and a scattering of testsuite
regressions throughout many arches. It's probably better to start over
with this import, hopefully more carefully next time.
Regressions, e.g.,
http://gdb-build.sergiodj.net/builders/Fedora-x86_64-m32/builds/1501
gdb/testsuite/ChangeLog:
Revert:
* Makefile.in (check/%.exp): Pass directory for GDB_PARALLEL.
(workers/%.worker, build-perf): New rule.
(GDB_PERFTEST_MODE): New variable.
(check-perf): Use it.
(clean): Clean up gdb.perf parallel build subdirs.
* lib/build-piece.exp: New file.
* lib/cache.exp (gdb_do_cache): Include $GDB_PARALLEL in path name.
* lib/gdb.exp (standard_output_file): Include $GDB_PARALLEL in path
name.
(standard_temp_file): Ditto.
(GDB_PARALLEL handling): Make outputs,temp,cache directories as subdirs
of $GDB_PARALLEL.
This patch syncs our upstream copy of readline from version 6.2 to the
latest version, 7.0 alpha (released July 10 2015).
I essentially copied what was done the last time readline was synced,
when Jan updated to readline 6.2 in 2011:
http://sourceware.org/ml/gdb-patches/2011-05/msg00003.html
Procedure:
1. I extracted the readline-7.0-alpha tarball on top of readline/.
2. I deleted all the new files under doc/ that were deliberately omitted
before.
3. I regenerated readline/configure and readline/examples/rlfe/configure
using autoconf 2.64. No other configure files need regenerating.
4. I updated the function gdb_printable_part in completer.c with a
trivial change made to the readline function it is based off of,
printable_part in readline/complete.c. There is more work to be done in
completer.c to sync it with readline/complete.c, but it is non-trivial
and should probably be done separately anyway.
Local patches that had to be reapplied:
None. readline 7.0 alpha contains all of our local readline
patches.
New files in readline/:
colors.{c,h}
examples/{hist_erasedups,hist_purgecmd,rl-callbacktest,rlbasic}.c
parse-colors.{c,h}
readline.pc.in
configure.ac
Deleted files in readline/:
configure.in
Regressions:
After the sync there is one testsuite regression, the test
"signal SIGINT" in gdb.gdb/selftest.exp which now FAILs. Previously,
the readline 6.2 SIGINT handler would temporarily reinstall the
underlying application's SIGINT handler and immediately re-raise SIGINT
so that the orginal handler gets invoked. But now (since readline 6.3)
its SIGINT handler does not re-raise SIGINT or directly invoke the
original handler; it now sets a flag marking that SIGINT was raised, and
waits until readline explicitly has control to call the application's
SIGINT handler. Anyway, because SIGINT is no longer re-raised from
within readline's SIGINT handler, doing "signal SIGINT" with a stopped
inferior gdb process will no longer resume and then immediately stop the
process (since there is no 2nd SIGINT to immediately catch). Instead,
the inferior gdb process will now just print "Quit" and continue to run.
So with this commit, this particular test case is adjusted to reflect
this change in behavior (we now have to send a 2nd SIGINT manually to
stop it).
Aside from this one testsuite regression, I personally noticed no
regression in user-visible behavior. Though I only tested on x86_64
and on i686 Debian Stretch.
Getting this kind of change in at the start of the GDB 7.11 development
cycle will allow us to get a lot of passive testing from developers and
from bleeding-edge users.
readline/ChangeLog.gdb:
Import readline 7.0 alpha
* configure: Regenerate.
* examples/rlfe/configure: Regenerate.
gdb/ChangeLog:
* completer.c (gdb_printable_part): Sync with readline function
it is based off of.
gdb/testsuite/ChangeLog:
* gdb.gdb/selftest.exp (test_with_self): Update test to now
expect the GDB inferior to no longer immediately stop after
being resumed with "signal SIGINT".
I think I lost a patch along the way, because I remember needing
something like this, but the reverted patch isn't the right way to
do this. Removing ...
gdb/testsuite/ChangeLog:
* gdb.perf/lib/perftest/measure.py (MeasurementCpuTime::stop): Print
result.
(MeasurementWallTime::stop): Ditto.
(MeasurementVmSizeTime::stop): Ditto.
These testcases are mocks of real programs.
GDB doesn't care what the programs do, they just have to look
and/or behave like the real program.
These testcases exercise gdb when debugging really large programs.
E.g., gmonster-1 has 10,000 CUs, and gmonster-2 has 1000 shared libs
(which is actually a little small, 5000 would be more accurate).
gdb/testsuite/ChangeLog:
* gdb.perf/lib/perftest/utils.py: New file.
* gdb.perf/gm-hello.cc: New file.
* gdb.perf/gm-pervasive-typedef.cc: New file.
* gdb.perf/gm-pervasive-typedef.h: New file.
* gdb.perf/gm-std.cc: New file.
* gdb.perf/gm-std.h: New file.
* gdb.perf/gm-use-cerr.cc: New file.
* gdb.perf/gm-utils.h: New file.
* gdb.perf/gmonster-null-lookup.py: New file.
* gdb.perf/gmonster-pervasive-typedef.py: New file.
* gdb.perf/gmonster-print-cerr.py: New file.
* gdb.perf/gmonster-ptype-string.py: New file.
* gdb.perf/gmonster-runto-main.py: New file.
* gdb.perf/gmonster-select-file.py: New file.
* gdb.perf/gmonster1-null-lookup.exp: New file.
* gdb.perf/gmonster1-pervasive-typedef.exp: New file.
* gdb.perf/gmonster1-print-cerr.exp: New file.
* gdb.perf/gmonster1-ptype-string.exp: New file.
* gdb.perf/gmonster1-runto-main.exp: New file.
* gdb.perf/gmonster1-select-file.exp: New file.
* gdb.perf/gmonster1.cc: New file.
* gdb.perf/gmonster1.exp: New file.
* gdb.perf/gmonster2-null-lookup.exp: New file.
* gdb.perf/gmonster2-pervasive-typedef.exp: New file.
* gdb.perf/gmonster2-print-cerr.exp: New file.
* gdb.perf/gmonster2-ptype-string.exp: New file.
* gdb.perf/gmonster2-runto-main.exp: New file.
* gdb.perf/gmonster2-select-file.exp: New file.
* gdb.perf/gmonster2.cc: New file.
* gdb.perf/gmonster2.exp: New file.
gdb/testsuite/ChangeLog:
* gdb.perf/README: New file.
* lib/perftest.exp (tcl_string_list_to_python_list): New function.
* lib/gen-perf-test.exp: New file.
gdb/testsuite/ChangeLog:
* gdb.base/watchpoint.exp (test_complex_watchpoint): Remove
compiler_info references.
* gdb.cp/temargs.exp: Ditto.
* lib/gdb.exp: Unset compiler_info instead of setting to "unknown".
(get_compiler_info): Early exit if already computed. Set compiler_info
to "unknown" if there was a problem.
(test_compiler_info): Add function comment. Call get_compiler_info.
gdb/testsuite/ChangeLog:
* Makefile.in (check/%.exp): Pass directory for GDB_PARALLEL.
(workers/%.worker, build-perf): New rule.
(GDB_PERFTEST_MODE): New variable.
(check-perf): Use it.
(clean): Clean up gdb.perf parallel build subdirs.
* lib/build-piece.exp: New file.
* lib/cache.exp (gdb_do_cache): Include $GDB_PARALLEL in path name.
* lib/gdb.exp (standard_output_file): Include $GDB_PARALLEL in path
name.
(standard_temp_file): Ditto.
(GDB_PARALLEL handling): Make outputs,temp,cache directories as subdirs
of $GDB_PARALLEL.
The gdb_skip_xml_test procedure explicitly says that it cannot be
invoked when GDB is running. However, the testcase for "catch
syscall" is wrongly doing that, which is causing a failure on
native-extended-gdbserver tests:
new FAIL: gdb.base/catch-syscall.exp: set tdesc filename /home/gdb-buildbot/fedora-x86-64-3/fedora-x86-64-native-extended-gdbserver-m32/build/gdb/testsuite/outputs/gdb.base/catch-syscall/trivial.xml (got interactive prompt)
This obvious commit fixes this, by calling gdb_exit before gdb_skip_xml_test.
Checked in as obvious.
gdb/testsuite/ChangeLog
2015-07-24 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/catch-syscall.exp: Call gdb_exit before
gdb_skip_xml_test.
I have patches that:
1 - make the CLI print stop info from a normal_stop observer, like MI
does.
2 - happen to change the order in which the Python and CLI/TUI
normal_stop observers are installed.
With those in place, py-events.exp regresses like shown below [1],
because the Python stop events are output before CLI prints stop info,
instead of after, and the test doesn't expect that.
With the same Python hooks, the order in which MI and Python events is
emited today is already undefined, because MI also uses the
normal_stop observer for output. I see no reason that we should in
general define the order observers, interpreters and scripting
languages get their turn at being notified of these events. So this
patch makes the test cope with Python->CLI output order too.
Tested on x86_64 Fedora 20.
gdb/testsuite/
2015-07-24 Pedro Alves <palves@redhat.com>
* gdb.python/py-events.exp: Accept output between the stop event
and the prompt.
* gdb.python/py-evsignal.exp: Likewise.
* gdb.python/py-evthreads.exp: Likewise.
[1] - The regressions in question look like:
Before said patches:
(gdb) continue
Continuing.
event type: continue
Breakpoint 2, first () at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.python/py-events.c:30
30 for (i = 0; i < 2; i++)
event type: stop
event type: stop
stop reason: breakpoint
first breakpoint number: 2
breakpoint number: 2
breakpoint number: 3
all threads stopped
(gdb) PASS: gdb.python/py-events.exp: continue
After said patches:
(gdb) continue
Continuing.
event type: continue
event type: stop
event type: stop
stop reason: breakpoint
first breakpoint number: 2
breakpoint number: 2
breakpoint number: 3
all threads stopped
Breakpoint 2, first () at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.python/py-events.c:30
30 for (i = 0; i < 2; i++)
(gdb) FAIL: gdb.python/py-events.exp: continue
If a non-leader thread exits the process while all other threads are
ptrace-stopped, native gdb fails an assertion. The test added by this
commit catches it:
/home/pedro/gdb/mygit/build/../src/gdb/linux-nat.c:3198: internal-error: linux_nat_filter_event: Assertion `lp->resumed' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
FAIL: gdb.threads/non-leader-exit-process.exp: program exits normally (GDB internal error)
The fix is just to remove the assertion.
With that out of the way, neither GDB not GDBserver handle this
perfectly though, so I'm adding a KFAIL:
(gdb) continue
Continuing.
[Thread 0x7ffff7fc0700 (LWP 15350) exited]
No unwaited-for children left.
Couldn't get registers: No such process.
(gdb) KFAIL: gdb.threads/non-ldr-exit.exp: program exits normally (PRMS: gdb/18717)
gdb/ChangeLog:
2015-07-24 Pedro Alves <palves@redhat.com>
PR gdb/18717
* linux-nat.c (linux_nat_filter_event): Don't assert that the lwp
is resumed, and extend the debug log.
gdb/testsuite/ChangeLog:
2015-07-24 Pedro Alves <palves@redhat.com>
PR gdb/18717
* gdb.threads/non-ldr-exit.c: New file.
* gdb.threads/non-ldr-exit.exp: New file.
My patch series will affect the code starting inferior in GDBserver
(callees of start_inferior), so we need tests to cover how
start_inferior is used in different cases.
In server.c:process_serial_event, start_inferior is used when
GBDserver receives 'R' packet, and this patch is to add a test
for this path, and see how --wrapper option works when the process
is restarted.
gdb/testsuite:
2015-07-24 Yao Qi <yao.qi@linaro.org>
* gdb.server/ext-wrapper.exp: Test --wrapper option when
restarting process.
When I run gdb.server/ext-restart.exp, I get the following GDB internal
error,
run^M
The program being debugged has been started already.^M
Start it from the beginning? (y or n) y^M
Sending packet: $vKill;53c5#3d...Packet received: OK^M
Packet vKill (kill) is supported^M
Sending packet: $vFile:close:6#b6...Packet received: F0^M
Sending packet: $vFile:close:3#b3...Packet received: F0^M
Starting program: /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.server/ext-restart ^M
Sending packet: $QDisableRandomization:1#cf...Packet received: OK^M
Sending packet: $R0#82...Sending packet: $qC#b4...Packet received: QCp53c5.53c5^M <-- [1]
Sending packet: $qAttached:53c5#c9...Packet received: E01^M
warning: Remote failure reply: E01^M
....
0x00002aaaaaaac2d0 in ?? () from target:/lib64/ld-linux-x86-64.so.2^M
/home/yao/SourceCode/gnu/gdb/git/gdb/thread.c:88: internal-error: inferior_thread: Assertion `tp' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.^M
Quit this debugging session? (y or n) FAIL: gdb.server/ext-restart.exp: run to main (GDB internal error)
Resyncing due to internal error.
the test is to restart the program, to make sure GDBserver handles
packet 'R' correctly. From the GDBserver output, we can see,
Remote debugging from host 127.0.0.1^M
Process /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.server/ext-restart created; pid = 21445^M
GDBserver restarting^M
Process /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.server/ext-restart created; pid = 21446^M
Killing process(es): 21446
we first start process 21445(0x53c5), kill it and restart a new process
21446. However, in the gdb output above [1], we can see that the reply
of qC is still the old process id rather than the new one. Looks
general_thread isn't up to date after GDBserver receives R packet.
This patch is to update general_thread after call start_inferior.
gdb/gdbserver:
2015-07-24 Yao Qi <yao.qi@linaro.org>
* server.c (process_serial_event): Set general_thread.
gdb/testsuite:
2015-07-24 Yao Qi <yao.qi@linaro.org>
* gdb.server/ext-restart.exp: New file.
We didn't test --wrapper option in extended-remote before, this patch
is to add a test case for it. In order to pass option --wrapper to
gdbserver in extended-remote, I add arg in gdbserver_start_extended,
and its default value is "", so that other places use
gdbserver_start_extended don't have to be updated.
gdb/testsuite:
2015-07-24 Yao Qi <yao.qi@linaro.org>
* lib/gdbserver-support.exp (gdbserver_start_extended): Add
argument options.
* gdb.server/ext-wrapper.exp: New file.
Dummy CUs are used by the incremental linker to pre-allocate space
in the output file. They have a DWARF header but no contents.
gdb/ChangeLog:
* dwarf2read.c (dwarf2_per_cu_data): Add comment.
(load_cu): Handle dummy CUs.
(dw2_do_instantiate_symtab, process_queuef): Ditto.
(dwarf2_fetch_die_loc_sect_off, dwarf2_fetch_constant_bytes): Ditto.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-dummy-cu.S: New file.
* gdb.dwarf2/dw2-dummy-cu.exp: New file.
When a dynamic array type contains a typedef-wrapped array, an assertion
failure occurs during type resolution. This is what happens in the
following Ada case:
type Rec_Type is record
I : Integer;
B : Boolean;
end record;
type Vec_Type is array (1 .. 4) of Rec_Type;
type Array_Type is array (Positive range <>) of Vec_Type;
If users try to print or even pass to an inferior call a variable A of
type Array_Type, GDB will raise an error:
(gdb) print a
../../src/gdb/gdbtypes.c:1807: internal-error:
resolve_dynamic_array: Assertion `TYPE_CODE (type) ==
TYPE_CODE_ARRAY' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
What happens is that during dynamic array type resolution, we first peel
TYPE_CODE_TYPEDEF layers wrapping the array element type and check if
its type is itself TYPE_CODE_ARRAY. If it is, we pass the
typedef-wrapped type to a recursive call to resolve_dynamic_array
whereas this function expects only TYPE_CODE_ARRAY types.
This patch makes it pass the peeled type to the recursive call so that
type resolution can continue smoothly.
gdb/ChangeLog:
* gdbtypes.c (resolve_dynamic_array): Pass the peeled element
type to the recursive call instead of the original (maybe
TYPE_CODE_TYPEDEF) type.
gdb/testsuite/ChangeLog:
* gdb.ada/var_arr_typedef.exp: New testcase.
* gdb.ada/var_arr_typedef/pack.adb: New file.
* gdb.ada/var_arr_typedef/pack.ads: New file.
* gdb.ada/var_arr_typedef/var_arr_typedef.adb: New file.
Since multi_line was moved to gdb.exp in a slightly stricter form,
The gdb.ada/info_exc.exp:info exceptions test has been failing.
This is because it now expects a new-line sequence at the end of
each argument given to multi_line, including ".*". But the intent
when writing the test was to signify "could-be-nothing-at-all".
As a result, the test fails on x86_64-linux with a runtime built as
recommended, because of that
extra new-line sequence.
gdb/testsuite/ChangeLog:
* gdb.ada/info_exc.exp: Adjust "info exceptions" expected output.
This new test fails on i686 buildbot slaves,
(gdb) core-file /home/gdb-buildbot-2/fedora-x86-64-2/fedora-i686/build/gdb/testsuite/gdb.arch/i386-biarch-core.core
"/home/gdb-buildbot-2/fedora-x86-64-2/fedora-i686/build/gdb/testsuite/gdb.arch/i386-biarch-core.core"
is not a core dump: File format not recognized
(gdb) FAIL: gdb.arch/i386-biarch-core.exp: core-file
There are two problems:
(1) The testcase did not really test if elf64-i386 is supported by GDB (BFD).
That was OK for a Fedora testcase but I forgot about it when submitting it
upstream.
I haven't really verified if the GNU target is elf64-little but it seems so,
no other one seems suitable from:
elf32-x86-64
elf64-big
elf64-k1om
elf64-l1om
elf64-little
elf64-x86-64
pei-x86-64
(2) The output of the "core-file" command itself can be arbitrary as the
elf64-i386 file with x86_64 registers is really broken; but that does not
matter much, important is the following test whether core file memory is
readable.
./configure --enable-64-bit-bfd
(gdb) core-file /home/jkratoch/redhat/gdb-test-build32-plus64/gdb/testsuite/gdb.arch/i386-biarch-core.core^M
warning: Couldn't find general-purpose registers in core file.^M
Failed to read a valid object file image from memory.^M
warning: Couldn't find general-purpose registers in core file.^M
#0 <unavailable> in ?? ()^M
(gdb) FAIL: gdb.arch/i386-biarch-core.exp: core-file
x/i 0x400078^M
0x400078: hlt ^M
(gdb) PASS: gdb.arch/i386-biarch-core.exp: .text is readable
I do not know much dejagnu but I expect 'istarget' tests against the site.exp
'target_triplet' content which is set to the primary GDB target
(--target=...).
GDB is normally never configured for primary target elf64-i386, I think BFD
does not know such explicit target, it gets recognized as elf64-little.
In fact many testfiles of the GDB testsuite are wrong as they require
'istarget' (therefore primary GDB target) even for just loading arch specific
files which would be sufficient with secondary target (--enable-targets=...)
support.
This my new patch removes this 'istarget' check as it is IMO unrelated to what
we need to test. Although you are right we do 'x/i' and test for 'hlt' so
I think we should test also for available 'set architecture i386'.
We could also test by 'x/bx' instead of 'x/i' to avoid such additional
test/requirement.
This testcase comes from a different bug from 2009:
https://bugzilla.redhat.com/show_bug.cgi?id=457187http://pkgs.fedoraproject.org/cgit/gdb.git/commit/?id=94cd124608bf0dd359cb48a710800d72c21b30c3
That bug has been fixed in the meantime but the same testcase was reproducing
this new different bug - internal error regression - so I submitted it.
We can remove the "x/bx $address" test but it was useful for the previous bug
from 2009 as that time the internal error regression did not happen, just the
core file was not recognized (which would not be detected by the proposed
ignoring of the "core-file" command output) and so the core file was not
available. That can be tested by the "x/bx $address" test.
gdb/testsuite/ChangeLog
2015-07-16 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.arch/i386-biarch-core.exp: Replace istarget
by "complete set gnutarget". Remove expectation for the "core-file"
command.
New testcase.
gdb/testsuite/ChangeLog
2015-07-15 Aleksandar Ristovski <aristovski@qnx.com
Tests for validate symbol file using build-id.
* gdb.base/solib-mismatch-lib.c: New file.
* gdb.base/solib-mismatch-libmod.c: New file.
* gdb.base/solib-mismatch.c: New file.
* gdb.base/solib-mismatch.exp: New file.
Tracepoints and range stepping are independent features. This patch
skips the gdb.trace/range-stepping.exp test case if the target does not
support range stepping.
gdb/testsuite/ChangeLog:
* gdb.base/range-stepping.exp (gdb_range_stepping_enabled):
Move it to ...
* lib/range-stepping-support.exp (gdb_range_stepping_enabled):
... here.
* gdb.trace/range-stepping.exp: Check that the target supports
range stepping.
This exercises the case of the inferior disappearing while GDB is
debugging it, such as something doing "kill -9 PID" while the program
is stopped under GDB or GDBserver. This triggered a set of internal
errors, fixed by previous patches.
gdb/testsuite/ChangeLog:
2015-07-14 Pedro Alves <palves@redhat.com>
* gdb.base/killed-outside.exp: New file.
* gdb.base/killed-outside.c: New file.
I have somehow missed gdb.asm/asm-source.exp PASS->FAIL even on x86_64.
It has no longer valid assumption that "break" breaks after the prologue even
in assembler. So I have changed this assumption of the testfile.
gdb/testsuite/ChangeLog
2015-07-10 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.asm/asm-source.exp (f at main): Stop at gdbasm_enter.
(n at main): New.
* gdb.asm/asmsrc1.s: Add comment "mark: main enter".
Since the new KFAILs/KPASSs for the infcall tests on x86 and x86_64
targets generated unnecessary noise, this change skips them with
UNSUPPORTED instead.
gdb/testsuite/ChangeLog:
* gdb.base/gnu_vector.exp: On x86 and x86_64 targets, skip the
infcall tests instead of setting up for KFAIL.
When navigating in the recorded execution trace via "record goto", we do not
set stop_pc. This may trigger an internal error in infrun.c when stepping
from that location. Set it.
(gdb) rec full
(gdb) c
Continuing.
Breakpoint 1, foo (void) at foo.c:42
42 x = y
(gdb) rn
foo (void)
at foo.c:41
41 y = x
(gdb) rec go end
Go forward to insn number 98724
at foo.c:42
42 x = y
(gdb) n
infrun.c:2382: internal-error: resume: Assertion `sig != GDB_SIGNAL_0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
This happens because there's a breakpoint at PC when the "next"
is issued, so that breapoint should be immediately stepped over.
That should have been detected/done by proceed, here:
if (addr == (CORE_ADDR) -1)
{
if (pc == stop_pc
&& breakpoint_here_p (aspace, pc) == ordinary_breakpoint_here
&& execution_direction != EXEC_REVERSE)
/* There is a breakpoint at the address we will resume at,
step one instruction before inserting breakpoints so that
we do not stop right away (and report a second hit at this
breakpoint).
Note, we don't do this in reverse, because we won't
actually be executing the breakpoint insn anyway.
We'll be (un-)executing the previous instruction. */
tp->stepping_over_breakpoint = 1;
But since stop_pc was stale, the pc == stop_pc check failed, and left the
breakpont at PC inserted.
gdb/
* record-btrace.c (record_btrace_goto_begin, record_btrace_goto_end)
record_btrace_goto): Move call to print_stack_frame ...
(record_btrace_set_replay): ... here. Set stop_pc.
* record-full.c (record_full_goto_entry): Set stop_pc.
testsuite/
* gdb.btrace/record_goto-step.exp: New.
This patch adds support for AArch64 to the gdb.trace testsuite.
Note that it does not add support for testing fast tracepoint as it
isn't supported. Therefore the test cases with inline assembly are not
ported in this patch, as we do not know what the conditions for
inserting a fast tracepoint on AArch64 would be.
gdb/testsuite/ChangeLog:
* gdb.trace/backtrace.exp: Set registers for aarch64 target.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/mi-trace-frame-collected.exp: Likewise.
* gdb.trace/mi-trace-unavailable.exp: Likewise.
* gdb.trace/report.exp: Likewise.
* gdb.trace/trace-break.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
GDB could:
compile code struct_object.selffield = &struct_object
./compile/compile-c-types.c:83: internal-error: insert_type: Assertion `add == NULL || add->gcc_type == gcc_type' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.compile/compile.exp: compile code struct_object.selffield = &struct_object (GDB internal
error)
The bug was not in GDB but in the GCC part interfacing with GDB.
Alexandre Oliva has fixed it the right way:
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=commitdiff;h=072dfdba0ea62abb65514cb3a90cdf3868efe286
git://gcc.gnu.org/git/gcc.git
aoliva/libcp1
Attaching this GDB testsuite update + info to user s/he should upgrade GCC.
After Alex upstreams the fix I can update the message to contain the specific
GCC release.
gdb/ChangeLog
2015-07-08 Jan Kratochvil <jan.kratochvil@redhat.com>
PR compile/18484
* compile/compile-c-types.c (insert_type): Change gdb_assert to error.
gdb/testsuite/ChangeLog
2015-07-08 Jan Kratochvil <jan.kratochvil@redhat.com>
PR compile/18484
* gdb.compile/compile.c (struct struct_type): Add volatile to
selffield's type.
* gdb.compile/compile.exp
(compile code struct_object.selffield = &struct_object): Skip further
struct_object tests if this one xfails.
The existing code preserves 'from' bits, which is incorrect. E.g.
(gdb) maint agent-eval (char)255L
Scope: 0x4008d6
Reg mask: 00
0 const16 255
3 ext 64
5 end
'ext 64' should be 'ext 8'; this bytecode evaluates to 255 instead of
the correct result of -1. The fix is simple. I ran the entire test
suite on x86-64 and there were no new test failures.
gdb/ChangeLog:
2015-07-08 Robert O'Callahan <robert@ocallahan.org>
PR exp/18617
* ax-gdb.c (gen_conversion): Extend to 'to' bits, not 'from'.
gdb/testsuite/ChangeLog:
2015-07-08 Robert O'Callahan <robert@ocallahan.org>
PR exp/18617
* gdb.trace/ax.exp: Add test.
Some tests expect the the target is aarch64, but checking target
triplet is not accurate, because target triplet can be aarch64 but
the program is in arm (or aarch32) state.
This patch addes a new proc is_aarch64_target which returns true
if the target is on aarch64 state.
gdb/testsuite:
2015-07-07 Yao Qi <yao.qi@linaro.org>
* gdb.arch/aarch64-atomic-inst.exp: Check is_aarch64_target
instead of istarget "aarch64*-*-*".
* gdb.arch/aarch64-fp.exp: Likewise.
* gdb.base/float.exp: Likewise.
* gdb.reverse/aarch64.exp: Likewise.
* lib/gdb.exp (is_aarch64_target): New proc.
GDB tests running on arm target should be also run on aarch32
(32-bit mode on aarch64). There should be no difference. It is not
precise to check target triplet to decide which tests should be run,
because if I compiler all the test binary in 32-bit (arm program),
but target triplet is still aarch64, so that these arm specific tests
are skipped.
This patch is to add a new proc is_aarch32_target which return true
if target triplet is arm or the test binary is compiled for arm.
gdb/testsuite:
2015-07-07 Yao Qi <yao.qi@linaro.org>
* lib/gdb.exp (is_aarch32_target): New proc.
* gdb.arch/arm-bl-branch-dest.exp: Check is_aarch32_target
instead of "istarget "arm*-*-*"".
* gdb.arch/arm-disp-step.exp: Likewise.
* gdb.arch/thumb-bx-pc.exp: Likewise.
* gdb.arch/thumb-prologue.exp: Likewise.
* gdb.arch/thumb-singlestep.exp: Likewise.
* gdb.base/disp-step-syscall.exp: Likewise.
* gdb.base/float.exp: Likewise.
This patch is to enable test_catch_syscall_multi_arch on aarch64.
gdb/testsuite:
2015-07-07 Yao Qi <yao.qi@linaro.org>
* gdb.base/catch-syscall.exp (test_catch_syscall_multi_arch):
Set arch1, arch2, syscall1_name, syscall2_name and syscall_number.
Multi-arch related tests under gdb.multi are to compile programs with
the same compiler but different compiler options (-m64 vs -m32). However,
different compilers are needed to compile both aarch64 program and
arm (aarch32) program. This patch is to adjust these test cases to
compile programs in different modes with different compiler.
When we use gcc for arm-linux target, its file name can be different,
arm-linux-gnueabihf-gcc, arm-linux-gnueabi-gcc, or arm-none-linux-gnueabi-gcc,
so I add a variable ARM_CC_FOR_TARGET, so that user can set the name
of gcc for arm-linux target on aarch64, like:
$ make check RUNTESTFLAGS='ARM_CC_FOR_TARGET=arm-linux-gnueabihf-gcc multi-arch.exp'
gdb/testsuite:
2015-07-07 Yao Qi <yao.qi@linaro.org>
* gdb.multi/multi-arch-exec.exp: Set march1 and march2 to "" if target
is aarch64. If target is aarch64, set compiler=${ARM_CC_FOR_TARGET}
if it exists.
* gdb.multi/multi-arch.exp: Likewise.
Patch "Do not skip prologue for asm (.S) files" [1] changes GDB's
behaviour on which test gdb.arch/thumb-singlestep.exp depends, so
it causes the fail below:
(gdb) si^M
37 blx foo^M
(gdb) FAIL: gdb.arch/thumb-singlestep.exp: step into foo
the test assumes the program will stop at the instruction after "push"
but it doesn't. The fix to this fail is to do one more single step.
[1] https://sourceware.org/ml/gdb-patches/2015-06/msg00561.html
gdb/testsuite:
2015-07-07 Yao Qi <yao.qi@linaro.org>
* gdb.arch/thumb-singlestep.exp: Do one more single step.
As these characters don't need to be escaped for strings
wrapped inside {} braces, we can remove the unneeded backslashes.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (test_class_help): Remove the unneeded escaping of
'[' and ']' characters.
Refs:
https://sourceware.org/ml/gdb/2015-03/msg00024.htmlhttps://sourceware.org/ml/gdb/2015-06/msg00005.html
On GNU/Linux, if an infcall spawns a thread, that thread ends up with
stuck running state. This happens because:
- when linux-nat.c detects a new thread, it marks them as running,
and does not report anything to the core.
- we skip finish_thread_state when the thread that is running the
infcall stops.
As result, that new thread ends up with stuck "running" state, even
though it really is stopped.
On Windows, _all_ threads end up stuck in running state, not just the
one that was spawned. That happens because when a new thread is
detected, unlike linux-nat.c, windows-nat.c reports
TARGET_WAITKIND_SPURIOUS to infrun. It's the fact that that event
does not cause a user-visible stop that triggers the problem. When
the target is re-resumed, we call set_running with a wildcard ptid,
which marks all thread as running. That set_running is not suppressed
because the (leader) thread being resumed does not have in_infcall
set. Later, when the infcall finally finishes successfully, nothing
marks all threads back to stopped.
We can trigger the same problem on all targets by having a thread
other than the one that is running the infcall report a breakpoint hit
to infrun, and then have that breakpoint not cause a stop. That's
what the included test does.
The fix is to stop GDB from suppressing the set_running calls while
doing an infcall, and then set the threads back to stopped when the
call finishes, iff they were originally stopped before the infcall
started. (Note the MI *running/*stopped event suppression isn't
affected.)
Tested on x86_64 GNU/Linux.
gdb/ChangeLog:
2015-06-29 Pedro Alves <palves@redhat.com>
PR threads/18127
* infcall.c (run_inferior_call): On infcall success, if the thread
was marked stopped before, reset it back to stopped.
* infrun.c (resume): Don't suppress the set_running calls when
doing an infcall.
(normal_stop): Only discard the finish_thread_state cleanup if the
infcall succeeded.
gdb/testsuite/ChangeLog:
2015-06-29 Pedro Alves <palves@redhat.com>
PR threads/18127
* gdb.threads/hand-call-new-thread.c: New file.
* gdb.threads/hand-call-new-thread.c: New file.