Blame SOURCES/0020-Use-the-main-class-URL-for-executable.patch

78a2f7
From 292f1775606874562026b5e27c3a192694553979 Mon Sep 17 00:00:00 2001
78a2f7
From: Jakub Filak <jfilak@redhat.com>
78a2f7
Date: Sat, 11 Jan 2014 00:34:15 +0100
78a2f7
Subject: [PATCH 20/39] Use the main class URL for 'executable'
78a2f7
78a2f7
Closes #28
78a2f7
Related to rhbz#1054737
78a2f7
---
78a2f7
 src/abrt-checker.c  | 31 +++++++++++++++++++++++++++++--
78a2f7
 test/CMakeLists.txt |  6 ++++--
78a2f7
 2 files changed, 33 insertions(+), 4 deletions(-)
78a2f7
78a2f7
diff --git a/src/abrt-checker.c b/src/abrt-checker.c
78a2f7
index c62d1ef..613a0ec 100644
78a2f7
--- a/src/abrt-checker.c
78a2f7
+++ b/src/abrt-checker.c
78a2f7
@@ -203,6 +203,14 @@ char *outputFileName = DISABLED_LOG_OUTPUT;
78a2f7
 /* Path (not necessary absolute) to output file */
78a2f7
 char **reportedCaughExceptionTypes;
78a2f7
 
78a2f7
+/* Determines which resource is used as executable */
78a2f7
+enum {
78a2f7
+    ABRT_EXECUTABLE_MAIN = 0,
78a2f7
+    ABRT_EXECUTABLE_THREAD = 1,
78a2f7
+};
78a2f7
+int executableFlags = 0;
78a2f7
+
78a2f7
+
78a2f7
 /* Map of buffer for already reported exceptions to prevent re-reporting */
78a2f7
 T_jthreadMap *threadMap;
78a2f7
 
78a2f7
@@ -2121,7 +2129,8 @@ static void JNICALL callback_on_exception(
78a2f7
                     updated_exception_name_ptr, class_name_ptr, method_name_ptr);
78a2f7
 
78a2f7
             char *executable = NULL;
78a2f7
-            char *stack_trace_str = generate_thread_stack_trace(jvmti_env, jni_env, tname, exception_object, &executable);
78a2f7
+            char *stack_trace_str = generate_thread_stack_trace(jvmti_env, jni_env, tname, exception_object,
78a2f7
+                    (executableFlags & ABRT_EXECUTABLE_THREAD) ? &executable : NULL);
78a2f7
 
78a2f7
             const char *report_message = message;
78a2f7
             if (NULL == report_message)
78a2f7
@@ -2757,9 +2766,27 @@ void parse_commandline_options(char *options)
78a2f7
         {
78a2f7
             reportedCaughExceptionTypes = build_string_vector(value, ':');
78a2f7
         }
78a2f7
+        else if (strcmp("executable", key) == 0)
78a2f7
+        {
78a2f7
+            if (strcmp("threadclass", value) == 0)
78a2f7
+            {
78a2f7
+                VERBOSE_PRINT("Use a thread class for 'executable'\n");
78a2f7
+                executableFlags |= ABRT_EXECUTABLE_THREAD;
78a2f7
+            }
78a2f7
+            else if (strcmp("mainclass", value) == 0)
78a2f7
+            {
78a2f7
+                /* Unset ABRT_EXECUTABLE_THREAD bit */
78a2f7
+                VERBOSE_PRINT("Use the main class for 'executable'\n");
78a2f7
+                executableFlags &= ~ABRT_EXECUTABLE_THREAD;
78a2f7
+            }
78a2f7
+            else
78a2f7
+            {
78a2f7
+                fprintf(stderr, "Unknown 'executable' option's value '%s'\n", key);
78a2f7
+            }
78a2f7
+        }
78a2f7
         else
78a2f7
         {
78a2f7
-            fprintf(stderr, "Unknow option '%s'\n", key);
78a2f7
+            fprintf(stderr, "Unknown option '%s'\n", key);
78a2f7
         }
78a2f7
     }
78a2f7
 }
78a2f7
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
78a2f7
index 0a73e2b..5267e7b 100644
78a2f7
--- a/test/CMakeLists.txt
78a2f7
+++ b/test/CMakeLists.txt
78a2f7
@@ -150,7 +150,7 @@ _add_test_target(
78a2f7
     run_threads
78a2f7
     MultiThreadTest
78a2f7
     DEPENDS ${TEST_JAVA_TARGETS}
78a2f7
-    AGENT_OPTIONS caught=java.lang.ArrayIndexOutOfBoundsException:java.lang.NullPointerException
78a2f7
+    AGENT_OPTIONS caught=java.lang.ArrayIndexOutOfBoundsException:java.lang.NullPointerException,executable=threadclass
78a2f7
 )
78a2f7
 _add_test(run_threads 0)
78a2f7
 
78a2f7
@@ -167,6 +167,7 @@ _add_test_target(
78a2f7
     run_bad_class
78a2f7
     BadClassTest
78a2f7
     DEPENDS ${TEST_JAVA_TARGETS} ${JAR_TEST_PATH}
78a2f7
+    AGENT_OPTIONS executable=threadclass
78a2f7
 )
78a2f7
 _add_test(run_bad_class 2)
78a2f7
 
78a2f7
@@ -175,6 +176,7 @@ _add_test_target(
78a2f7
     MissingClassTest
78a2f7
     PRE rm -f MissingClassTest.class
78a2f7
     DEPENDS ${TEST_JAVA_TARGETS} ${JAR_TEST_PATH}
78a2f7
+    AGENT_OPTIONS executable=threadclass
78a2f7
 )
78a2f7
 _add_test(run_missing_class_test 2)
78a2f7
 
78a2f7
@@ -294,7 +296,7 @@ _add_test_target(
78a2f7
     RemoteTest ${JAR_TEST_PATH} MultiThreadTest
78a2f7
     PRE rm -f SimpleTest.class ThreadCaughtException.class ThreadUncaughtException.class MultiThreadTest.class
78a2f7
     DEPENDS ${TEST_JAVA_TARGETS} ${JAR_TEST_PATH}
78a2f7
-    AGENT_OPTIONS caught=java.lang.ArrayIndexOutOfBoundsException:java.lang.NullPointerException
78a2f7
+    AGENT_OPTIONS caught=java.lang.ArrayIndexOutOfBoundsException:java.lang.NullPointerException,executable=threadclass
78a2f7
 )
78a2f7
 _add_test(run_remote_thread 0)
78a2f7
 
78a2f7
-- 
78a2f7
1.8.3.1
78a2f7