diff options
author | Yao Qi <yao.qi@linaro.org> | 2017-12-07 17:07:01 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2017-12-07 17:07:01 +0000 |
commit | a8806230241d201f808d856eaae4d44088117b0c (patch) | |
tree | c4d6debfb37b349dd078c9d6016da154465a1d6c /gdb/testsuite/gdb.trace | |
parent | 30970df7d56bd65657c97296f31fe9862bf27e1d (diff) | |
download | fsf-binutils-gdb-a8806230241d201f808d856eaae4d44088117b0c.zip fsf-binutils-gdb-a8806230241d201f808d856eaae4d44088117b0c.tar.gz fsf-binutils-gdb-a8806230241d201f808d856eaae4d44088117b0c.tar.bz2 |
Initialize target description early in IPA
Target descriptions are allocated lazily, that is fine in GDBserver,
but it is not safe to call malloc in gdb_collect in IPA, because we
can set a fast tracepoint in malloc, and when the tracepoint is hit,
gdb_collect/malloc is called, deadlock or memory corruption may be
triggered.
#0 0xf7cfc200 in malloc ()
#1 0xf7efdc07 in operator new(unsigned int) ()
#2 0xf7ef7636 in allocate_target_description() ()
#3 0xf7efcbe1 in i386_create_target_description(unsigned long long, bool) ()
#4 0xf7efb474 in i386_linux_read_description(unsigned long long) ()
#5 0xf7efb190 in get_ipa_tdesc(int) ()
#6 0xf7ef9baa in gdb_collect ()
The fix is to initialize all target descriptions earlier, when the
IPA is loaded. In order to guarantee malloc is not called in IPA
in gdb_collect, I change the test to set a breakpoint on malloc, if
IPA gdb_collect calls malloc, program will hit the breakpoint, and
test fail.
continue
Continuing.
Thread 1 "" hit Breakpoint 5, 0xf7cfc200 in malloc ()
(gdb) FAIL: gdb.trace/ftrace.exp: advance through tracing
gdb/gdbserver:
2017-12-07 Yao Qi <yao.qi@linaro.org>
* linux-aarch64-ipa.c (initialize_low_tracepoint): Call
aarch64_linux_read_description.
* linux-amd64-ipa.c (idx2mask): New array.
(get_ipa_tdesc): Move idx2mask out.
(initialize_low_tracepoint): Initialize target descriptions.
* linux-i386-ipa.c (idx2mask): New array.
(get_ipa_tdesc): Move idx2mask out.
(initialize_low_tracepoint): Initialize target descriptions.
gdb/testsuite:
2017-12-07 Yao Qi <yao.qi@linaro.org>
* gdb.trace/ftrace.exp (run_trace_experiment): Set breakpoint on
malloc and catch syscall.
Diffstat (limited to 'gdb/testsuite/gdb.trace')
-rw-r--r-- | gdb/testsuite/gdb.trace/ftrace.exp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.trace/ftrace.exp b/gdb/testsuite/gdb.trace/ftrace.exp index b862680..3aa8883 100644 --- a/gdb/testsuite/gdb.trace/ftrace.exp +++ b/gdb/testsuite/gdb.trace/ftrace.exp @@ -63,9 +63,36 @@ proc run_trace_experiment {} { gdb_test_no_output "tstart" "start trace experiment" - gdb_test "continue" \ - ".*Breakpoint \[0-9\]+, end .*" \ - "advance through tracing" + # Fast tracepoint can be set in signal handler, so gdb_collect in + # IPA shouldn't call any non-async-signal-safe functions. It is + # impractical to list all non-async-signal-safe functions, and set + # breakpoints on them, so choose malloc only in this test. + gdb_test "b -q malloc" + + # Performance-wise, gdb_collect in IPA shouldn't call any syscall + # in order to keep fast tracepoint fast enough. + global gdb_prompt + set test "catch syscall" + gdb_test_multiple $test $test { + -re "The feature \'catch syscall\' is not supported.*\r\n$gdb_prompt $" { + } + -re ".*$gdb_prompt $" { + pass $test + } + } + + global decimal + set test "advance through tracing" + gdb_test_multiple "continue" $test { + -re "Thread 2 .* hit Catchpoint $decimal \\(call to syscall .*\\).*\r\n$gdb_prompt $" { + # IPA starts a helper thread, which calls accept. Ignore it. + send_gdb "continue\n" + exp_continue + } + -re "Breakpoint $decimal, end .*$gdb_prompt $" { + pass $test + } + } gdb_test "tstatus" ".*Trace .*" "check on trace status" |