Blob Blame History Raw
From 292f1775606874562026b5e27c3a192694553979 Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Sat, 11 Jan 2014 00:34:15 +0100
Subject: [PATCH 20/39] Use the main class URL for 'executable'

Closes #28
Related to rhbz#1054737
---
 src/abrt-checker.c  | 31 +++++++++++++++++++++++++++++--
 test/CMakeLists.txt |  6 ++++--
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/src/abrt-checker.c b/src/abrt-checker.c
index c62d1ef..613a0ec 100644
--- a/src/abrt-checker.c
+++ b/src/abrt-checker.c
@@ -203,6 +203,14 @@ char *outputFileName = DISABLED_LOG_OUTPUT;
 /* Path (not necessary absolute) to output file */
 char **reportedCaughExceptionTypes;
 
+/* Determines which resource is used as executable */
+enum {
+    ABRT_EXECUTABLE_MAIN = 0,
+    ABRT_EXECUTABLE_THREAD = 1,
+};
+int executableFlags = 0;
+
+
 /* Map of buffer for already reported exceptions to prevent re-reporting */
 T_jthreadMap *threadMap;
 
@@ -2121,7 +2129,8 @@ static void JNICALL callback_on_exception(
                     updated_exception_name_ptr, class_name_ptr, method_name_ptr);
 
             char *executable = NULL;
-            char *stack_trace_str = generate_thread_stack_trace(jvmti_env, jni_env, tname, exception_object, &executable);
+            char *stack_trace_str = generate_thread_stack_trace(jvmti_env, jni_env, tname, exception_object,
+                    (executableFlags & ABRT_EXECUTABLE_THREAD) ? &executable : NULL);
 
             const char *report_message = message;
             if (NULL == report_message)
@@ -2757,9 +2766,27 @@ void parse_commandline_options(char *options)
         {
             reportedCaughExceptionTypes = build_string_vector(value, ':');
         }
+        else if (strcmp("executable", key) == 0)
+        {
+            if (strcmp("threadclass", value) == 0)
+            {
+                VERBOSE_PRINT("Use a thread class for 'executable'\n");
+                executableFlags |= ABRT_EXECUTABLE_THREAD;
+            }
+            else if (strcmp("mainclass", value) == 0)
+            {
+                /* Unset ABRT_EXECUTABLE_THREAD bit */
+                VERBOSE_PRINT("Use the main class for 'executable'\n");
+                executableFlags &= ~ABRT_EXECUTABLE_THREAD;
+            }
+            else
+            {
+                fprintf(stderr, "Unknown 'executable' option's value '%s'\n", key);
+            }
+        }
         else
         {
-            fprintf(stderr, "Unknow option '%s'\n", key);
+            fprintf(stderr, "Unknown option '%s'\n", key);
         }
     }
 }
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 0a73e2b..5267e7b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -150,7 +150,7 @@ _add_test_target(
     run_threads
     MultiThreadTest
     DEPENDS ${TEST_JAVA_TARGETS}
-    AGENT_OPTIONS caught=java.lang.ArrayIndexOutOfBoundsException:java.lang.NullPointerException
+    AGENT_OPTIONS caught=java.lang.ArrayIndexOutOfBoundsException:java.lang.NullPointerException,executable=threadclass
 )
 _add_test(run_threads 0)
 
@@ -167,6 +167,7 @@ _add_test_target(
     run_bad_class
     BadClassTest
     DEPENDS ${TEST_JAVA_TARGETS} ${JAR_TEST_PATH}
+    AGENT_OPTIONS executable=threadclass
 )
 _add_test(run_bad_class 2)
 
@@ -175,6 +176,7 @@ _add_test_target(
     MissingClassTest
     PRE rm -f MissingClassTest.class
     DEPENDS ${TEST_JAVA_TARGETS} ${JAR_TEST_PATH}
+    AGENT_OPTIONS executable=threadclass
 )
 _add_test(run_missing_class_test 2)
 
@@ -294,7 +296,7 @@ _add_test_target(
     RemoteTest ${JAR_TEST_PATH} MultiThreadTest
     PRE rm -f SimpleTest.class ThreadCaughtException.class ThreadUncaughtException.class MultiThreadTest.class
     DEPENDS ${TEST_JAVA_TARGETS} ${JAR_TEST_PATH}
-    AGENT_OPTIONS caught=java.lang.ArrayIndexOutOfBoundsException:java.lang.NullPointerException
+    AGENT_OPTIONS caught=java.lang.ArrayIndexOutOfBoundsException:java.lang.NullPointerException,executable=threadclass
 )
 _add_test(run_remote_thread 0)
 
-- 
1.8.3.1