summaryrefslogtreecommitdiffstats
path: root/src/Backtrace/main.c
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-11-30 15:10:42 +0100
committerKarel Klic <kklic@redhat.com>2009-11-30 15:10:42 +0100
commit3b97c373a8d6bce4fa8b8ae5f014f83dab39d09a (patch)
treecd20a309e35ae77cabf4bf45d90724ecc5d3830a /src/Backtrace/main.c
parent0bde5aff06915f888b1a6c6a1309b7ee56058c8a (diff)
downloadabrt-3b97c373a8d6bce4fa8b8ae5f014f83dab39d09a.tar.gz
abrt-3b97c373a8d6bce4fa8b8ae5f014f83dab39d09a.tar.xz
abrt-3b97c373a8d6bce4fa8b8ae5f014f83dab39d09a.zip
abrt-backtrace handle more corner cases, silently exit on python backtraces
Diffstat (limited to 'src/Backtrace/main.c')
-rw-r--r--src/Backtrace/main.c71
1 files changed, 65 insertions, 6 deletions
diff --git a/src/Backtrace/main.c b/src/Backtrace/main.c
index 315b6ef..0761d31 100644
--- a/src/Backtrace/main.c
+++ b/src/Backtrace/main.c
@@ -114,6 +114,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
/* Our argp parser. */
static struct argp argp = { options, parse_opt, args_doc, doc };
+#define PYTHON_BACKTRACE_ID1 "\n\nTraceback (most recent call last):\n"
+#define PYTHON_BACKTRACE_ID2 "\n\nLocal variables in innermost frame:\n"
int main(int argc, char **argv)
{
@@ -161,6 +163,15 @@ int main(int argc, char **argv)
bttext[size] = '\0';
fclose(fp);
+ /* Detect Python backtraces. If it is a Python backtrace,
+ * silently exit for now.
+ */
+ if (strstr(bttext, PYTHON_BACKTRACE_ID1) != NULL
+ && strstr(bttext, PYTHON_BACKTRACE_ID2) != NULL)
+ {
+ exit(0);
+ }
+
/* Print independent backtrace and exit. */
if (arguments.independent)
{
@@ -173,17 +184,65 @@ int main(int argc, char **argv)
/* Skip the backtrace header information. */
char *btnoheader_a = strstr(bttext, "\nThread ");
- char *btnoheader_b = strstr(bttext, "#");
+ char *btnoheader_b = strstr(bttext, "\n#");
char *btnoheader = bttext;
- if (btnoheader < btnoheader_a)
- btnoheader = btnoheader_a + 1;
- if (btnoheader < btnoheader_b)
- btnoheader = btnoheader_b;
+ if (btnoheader_a)
+ {
+ if (btnoheader_b && btnoheader_b < btnoheader_a)
+ btnoheader = btnoheader_b + 1;
+ else
+ btnoheader = btnoheader_a + 1;
+ }
+ else if (btnoheader_b)
+ btnoheader = btnoheader_b + 1;
+
+ /* Bug fixing hack for broken backtraces.
+ * Sometimes the empty line is missing before new Thread section.
+ * This is against rules, but a bug (now fixed) in Linux kernel caused
+ * this.
+ */
+ char *thread_fixer = btnoheader + 1;
+ while ((thread_fixer = strstr(thread_fixer, "\nThread")) != NULL)
+ {
+ if (thread_fixer[-1] != '\n')
+ thread_fixer[-1] = '\n';
+
+ ++thread_fixer;
+ }
+
+ /* Bug fixing hack for GDB.
+ * Sometimes there is a newline in the local variable section.
+ * This is caused by some GDB hooks.
+ * Example: rhbz#538440
+ * #1 0x0000000000420939 in sync_deletions (mse=0x0, mfld=0x1b85020)
+ * at mail-stub-exchange.c:1119
+ * status = <value optimized out>
+ * iter = 0x1af38d0
+ * known_messages = 0x1b5c460Traceback (most recent call last):
+ * File "/usr/share/glib-2.0/gdb/glib.py", line 98, in next
+ * if long (node["key_hash"]) >= 2:
+ * RuntimeError: Cannot access memory at address 0x11
+ *
+ * __PRETTY_FUNCTION__ = "sync_deletions"
+ * #2 0x0000000000423e6b in refresh_folder (stub=0x1b77f10 [MailStubExchange],
+ * ...
+ */
+ char *empty_line = btnoheader;
+ while ((empty_line = strstr(empty_line, "\n\n")) != NULL)
+ {
+ if (0 != strncmp(empty_line, "\n\nThread", strlen("\n\nThread")))
+ {
+ /* Remove the empty line by converting the first newline to char. */
+ empty_line[0] = 'X';
+ }
+ ++empty_line;
+ }
/* Cut the backtrace footer.
* Footer: lines not starting with # or "Thread", and separated from
* the backtrace body by a newline.
*/
+ /* It is not necessary for now, because of the bug fixing hack for GDB.
int i;
for (i = size - 1; i > 0; --i)
{
@@ -198,7 +257,7 @@ int main(int argc, char **argv)
bttext[i] = '\0';
break;
}
- }
+ }*/
/* Try to parse the backtrace. */
struct backtrace *backtrace;