|
From: Matthias S. <zz...@ge...> - 2015-08-12 19:15:00
|
Add test that calls abort with xml output.
It solved bug 191069
---
coregrind/m_signals.c | 53 +++++++++++++++++++--------
docs/internals/xml-output-protocol4.txt | 47 ++++++++++++++++++++++++
memcheck/tests/Makefile.am | 3 +-
memcheck/tests/gone_abrt_xml.stderr.exp | 63 +++++++++++++++++++++++++++++++++
memcheck/tests/gone_abrt_xml.vgtest | 5 +++
5 files changed, 155 insertions(+), 16 deletions(-)
create mode 100644 memcheck/tests/gone_abrt_xml.stderr.exp
create mode 100644 memcheck/tests/gone_abrt_xml.vgtest
diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c
index f59bff7..b166845 100644
--- a/coregrind/m_signals.c
+++ b/coregrind/m_signals.c
@@ -1740,14 +1740,25 @@ static void default_action(const vki_siginfo_t *info, ThreadId tid)
core = False;
}
- if ( (VG_(clo_verbosity) >= 1 ||
- (could_core && is_signal_from_kernel(tid, sigNo, info->si_code))
- ) &&
- !VG_(clo_xml) ) {
- VG_(umsg)(
- "\n"
- "Process terminating with default action of signal %d (%s)%s\n",
- sigNo, VG_(signame)(sigNo), core ? ": dumping core" : "");
+ if ( VG_(clo_verbosity) >= 1 ||
+ (could_core && is_signal_from_kernel(tid, sigNo, info->si_code)) ||
+ VG_(clo_xml) ) {
+ if (VG_(clo_xml)) {
+ VG_(printf_xml)("<fatal_signal>\n");
+ VG_(printf_xml)(" <tid>%d</tid>\n", tid);
+ ThreadState* tst = VG_(get_ThreadState)(tid);
+ if (tst->thread_name) {
+ VG_(printf_xml)(" <threadname>%s</threadname>\n", tst->thread_name);
+ }
+ VG_(printf_xml)(" <signo>%d</signo>\n", sigNo);
+ VG_(printf_xml)(" <signame>%s</signame>\n", VG_(signame)(sigNo));
+ VG_(printf_xml)(" <sicode>%d</sicode>\n", info->si_code);
+ } else {
+ VG_(umsg)(
+ "\n"
+ "Process terminating with default action of signal %d (%s)%s\n",
+ sigNo, VG_(signame)(sigNo), core ? ": dumping core" : "");
+ }
/* Be helpful - decode some more details about this fault */
if (is_signal_from_kernel(tid, sigNo, info->si_code)) {
@@ -1820,13 +1831,20 @@ static void default_action(const vki_siginfo_t *info, ThreadId tid)
break;
} /* switch (sigNo) */
- if (event != NULL) {
- if (haveaddr)
- VG_(umsg)(" %s at address %p\n",
- event, info->VKI_SIGINFO_si_addr);
- else
- VG_(umsg)(" %s\n", event);
- }
+ if (VG_(clo_xml)) {
+ if (event != NULL)
+ VG_(printf_xml)(" <event>%s</event>\n", event);
+ if (haveaddr)
+ VG_(printf_xml)(" <siaddr>%p</siaddr>\n", info->VKI_SIGINFO_si_addr);
+ } else {
+ if (event != NULL) {
+ if (haveaddr)
+ VG_(umsg)(" %s at address %p\n",
+ event, info->VKI_SIGINFO_si_addr);
+ else
+ VG_(umsg)(" %s\n", event);
+ }
+ }
}
/* Print a stack trace. Be cautious if the thread's SP is in an
obviously stupid place (not mapped readable) that would
@@ -1889,6 +1907,11 @@ static void default_action(const vki_siginfo_t *info, ThreadId tid)
VG_(threads)[1].client_stack_szB);
}
}
+ if (VG_(clo_xml)) {
+ /* postamble */
+ VG_(printf_xml)("</fatal_signal>\n");
+ VG_(printf_xml)("\n");
+ }
}
if (VG_(clo_vgdb) != Vg_VgdbNo
diff --git a/docs/internals/xml-output-protocol4.txt b/docs/internals/xml-output-protocol4.txt
index ccb22b4..e20b9dd 100644
--- a/docs/internals/xml-output-protocol4.txt
+++ b/docs/internals/xml-output-protocol4.txt
@@ -743,3 +743,50 @@ OR
* STACK is only present in case of VALGRIND_PRINTF_BACKTRACE. See above
for a definition of STACK.
+
+====================================================================
+
+FATAL_SIGNAL
+
+FATAL_SIGNAL defines a message that was caused by a signal that killed them
+process.
+
+Definition:
+
+ <fatal_signal>
+ <tid>INT</tid>
+ <threadname>NAME</threadname> if set
+
+ <signo>INT</signo>
+ <signame>NAME</signame>
+
+ <sicode>0</sicode>
+ <event>NAME</event>
+ <siaddr>ADDR</siaddr>
+
+ STACK
+
+ </fatal_signal>
+
+* The <tid> tag indicates the Valgrind thread number. This value
+ is arbitrary but may be used to determine which threads produced
+ which errors (at least, the first instance of each error).
+
+* The <threadname> tag identifies the name of the thread if it was
+ set by the client application. If no name was set, the tag is
+ omitted.
+
+* The <signo> tag indicates signo value from struct siginfo.
+
+* In <signame> tag there is the decoded name of signo.
+
+* The <sicode> tag contains the sicode from struct siginfo.
+
+* The <event> tag indicates the decoded name of the sicode.
+
+* The <siaddr> tag indicates the address that is the reason
+ why the signal was triggered. This can be an unaligned pointer value or
+ just the address of not mapped memory that is accessed Nevertheless.
+
+* STACK is defined above and shows where the thread was when it catched the signal.
+ When sending the signal to itself using raise, then raise is visible in this stack.
diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am
index 0a850a2..f084198 100644
--- a/memcheck/tests/Makefile.am
+++ b/memcheck/tests/Makefile.am
@@ -293,7 +293,8 @@ EXTRA_DIST = \
writev1.stderr.exp writev1.stderr.exp-solaris writev1.vgtest \
xml1.stderr.exp xml1.stdout.exp xml1.vgtest xml1.stderr.exp-s390x-mvc \
threadname.vgtest threadname.stderr.exp \
- threadname_xml.vgtest threadname_xml.stderr.exp
+ threadname_xml.vgtest threadname_xml.stderr.exp \
+ gone_abrt_xml.vgtest gone_abrt_xml.stderr.exp
check_PROGRAMS = \
accounting \
diff --git a/memcheck/tests/gone_abrt_xml.stderr.exp b/memcheck/tests/gone_abrt_xml.stderr.exp
new file mode 100644
index 0000000..b0faf73
--- /dev/null
+++ b/memcheck/tests/gone_abrt_xml.stderr.exp
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+
+<valgrindoutput>
+
+<protocolversion>4</protocolversion>
+<protocoltool>memcheck</protocoltool>
+
+<preamble>
+ <line>...</line>
+ <line>...</line>
+ <line>...</line>
+ <line>...</line>
+</preamble>
+
+<pid>...</pid>
+<ppid>...</ppid>
+<tool>memcheck</tool>
+
+<args>
+ <vargv>...</vargv>
+ <argv>
+ <exe>./../../gdbserver_tests/gone</exe>
+ <arg>abort</arg>
+ </argv>
+</args>
+
+<status>
+ <state>RUNNING</state>
+ <time>...</time>
+</status>
+
+starting ...
+aborting ...
+<fatal_signal>
+ <tid>...</tid>
+ <signo>6</signo>
+ <signame>SIGABRT</signame>
+ <sicode>0</sicode>
+ <stack>
+ <frame>
+ <ip>0x........</ip>
+ <obj>...</obj>
+ <fn>main</fn>
+ <dir>...</dir>
+ <file>gone.c</file>
+ <line>...</line>
+ </frame>
+ </stack>
+</fatal_signal>
+
+
+<status>
+ <state>FINISHED</state>
+ <time>...</time>
+</status>
+
+<errorcounts>
+</errorcounts>
+
+<suppcounts>...</suppcounts>
+
+</valgrindoutput>
+
diff --git a/memcheck/tests/gone_abrt_xml.vgtest b/memcheck/tests/gone_abrt_xml.vgtest
new file mode 100644
index 0000000..dc18192
--- /dev/null
+++ b/memcheck/tests/gone_abrt_xml.vgtest
@@ -0,0 +1,5 @@
+prog: ../../gdbserver_tests/gone
+args: abort
+vgopts: --xml=yes --xml-fd=2 --log-file=/dev/null
+stderr_filter: filter_xml
+cleanup: rm -f vgcore.*
--
2.5.0
|
|
From: Matthias S. <zz...@ge...> - 2015-08-24 19:39:45
|
Hi! Will this patch or at least this idea be considered for commiting? This makes diagnosis of valgrind/client app abnormal exits a lot simpler. Especially in automated valgrind execution. Regards Matthias |
|
From: Matthias S. <zz...@ge...> - 2015-09-07 17:57:45
|
Am 24.08.2015 um 21:39 schrieb Matthias Schwarzott: > Hi! > I added this latest patch also to this bug: https://bugs.kde.org/show_bug.cgi?id=191069 > Will this patch or at least this idea be considered for commiting? > Is there a chance to get this into version 3.11? Regards Matthias |
|
From: Matthias S. <zz...@ge...> - 2015-11-24 19:04:11
|
Am 07.09.2015 um 19:57 schrieb Matthias Schwarzott: > Am 24.08.2015 um 21:39 schrieb Matthias Schwarzott: >> Hi! >> Hi! > I added this latest patch also to this bug: > https://bugs.kde.org/show_bug.cgi?id=191069 > >> Will this patch or at least this idea be considered for commiting? >> Can this patch be considered for applying? It just tries to make the xml output of memcheck be more like the text output. Regards Matthias |