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

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