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

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