This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/2] GDB test suite: Get core files on targets with systemd-coredump
- From: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 18 Sep 2017 20:41:52 +0200
- Subject: [PATCH 2/2] GDB test suite: Get core files on targets with systemd-coredump
- Authentication-results: sourceware.org; auth=none
- References: <1505760152-28775-1-git-send-email-arnez@linux.vnet.ibm.com>
So far the test suite skips tests if they need system-generated core files
and the core files can not be found. In particular this is usually the
case on systems with an active systemd-coredump service. On such systems,
core files are not written into the local directory, but made accessible
via a command-line utitily "coredumpctl" instead.
This patch enables processing core files on such systems as well. Note
that there are a few quirks:
* In my tests, after invoking a command that dumps core, it could happen
that "coredumpctl" did not find the dump immediately afterwards. After
waiting a bit, the dump was found and could be accessed. Thus the patch
performs a single wait-and-retry in case of failure.
* There does not seem to be a way for a user to remove specific core dumps
from the journal. Thus it can happen that "coredumpctl" returns an old
dump, and the test case continues with that instead of the new one. It
might be possible to improve the logic here, by considering the time
stamps as well. I leave that for a future patch.
* On the system I've tested it on, the bigcore.exp test case still failed
because coredumpctl truncated the core file after 4G for some reason.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (find_core): Add handling for targets with
systemd-coredump, using the coredumpctl command.
---
gdb/testsuite/lib/gdb.exp | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 1fd0009..7f80e12 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5877,6 +5877,19 @@ proc find_core {binfile coredir {destcore ""}} {
}
}
+ # We may be running on a system with the systemd-coredump service in
+ # effect; try the coredumpctl command. But due to asynchronous
+ # processing the core dump may not have been processed yet. Thus wait
+ # a bit and retry after failure.
+ foreach delay {0 1} {
+ sleep $delay
+ if {![catch {exec -ignorestderr coredumpctl -o $destcore dump $binfile}]} {
+ if [file exists $destcore] {
+ return $destcore
+ }
+ }
+ }
+
warning "Can not locate core dump generated by \"[file tail $binfile]\"."
return ""
}
--
2.9.4