|
|
b35d98 |
From d2578295a953ced07371eedc885c032951b11297 Mon Sep 17 00:00:00 2001
|
|
|
b35d98 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
b35d98 |
Date: Mon, 13 Jan 2014 16:38:17 +0100
|
|
|
b35d98 |
Subject: [PATCH 30/39] Add an utility for stack trace analysis
|
|
|
b35d98 |
|
|
|
b35d98 |
The tool is supposed to find all remote class paths and create a file
|
|
|
b35d98 |
named "not-reportale" containing a short explanation why the examined
|
|
|
b35d98 |
stack trace is not reportable via ABRT.
|
|
|
b35d98 |
|
|
|
b35d98 |
The tool is designed for usage in post-create event.
|
|
|
b35d98 |
|
|
|
b35d98 |
Related to #29
|
|
|
b35d98 |
Related to rhbz#1054737
|
|
|
b35d98 |
---
|
|
|
b35d98 |
CMakeLists.txt | 19 ++-
|
|
|
b35d98 |
po/CMakeLists.txt | 64 ++++++++++
|
|
|
b35d98 |
po/LINGUAS | 0
|
|
|
b35d98 |
po/POTFILES.in | 1 +
|
|
|
b35d98 |
src/CMakeLists.txt | 7 +-
|
|
|
b35d98 |
utils/CMakeLists.txt | 34 ++++++
|
|
|
b35d98 |
utils/abrt-action-analyze-java.c | 258 +++++++++++++++++++++++++++++++++++++++
|
|
|
b35d98 |
utils/config.h.in | 2 +
|
|
|
b35d98 |
8 files changed, 379 insertions(+), 6 deletions(-)
|
|
|
b35d98 |
create mode 100644 po/CMakeLists.txt
|
|
|
b35d98 |
create mode 100644 po/LINGUAS
|
|
|
b35d98 |
create mode 100644 po/POTFILES.in
|
|
|
b35d98 |
create mode 100644 utils/CMakeLists.txt
|
|
|
b35d98 |
create mode 100644 utils/abrt-action-analyze-java.c
|
|
|
b35d98 |
create mode 100644 utils/config.h.in
|
|
|
b35d98 |
|
|
|
b35d98 |
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
|
b35d98 |
index 1504461..33a5e03 100644
|
|
|
b35d98 |
--- a/CMakeLists.txt
|
|
|
b35d98 |
+++ b/CMakeLists.txt
|
|
|
b35d98 |
@@ -39,6 +39,10 @@ endif()
|
|
|
b35d98 |
|
|
|
b35d98 |
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
|
|
|
b35d98 |
|
|
|
b35d98 |
+if(NOT BIN_INSTALL_DIR)
|
|
|
b35d98 |
+ set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
|
|
|
b35d98 |
+endif()
|
|
|
b35d98 |
+
|
|
|
b35d98 |
if(NOT LIB_INSTALL_DIR)
|
|
|
b35d98 |
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
|
|
|
b35d98 |
endif()
|
|
|
b35d98 |
@@ -55,10 +59,23 @@ if(NOT MAN_INSTALL_DIR)
|
|
|
b35d98 |
set(MAN_INSTALL_DIR ${SHARE_INSTALL_PREFIX}/man)
|
|
|
b35d98 |
endif()
|
|
|
b35d98 |
|
|
|
b35d98 |
+if(NOT LOCALE_INSTALL_DIR)
|
|
|
b35d98 |
+ set(LOCALE_INSTALL_DIR ${SHARE_INSTALL_PREFIX}/locale)
|
|
|
b35d98 |
+endif()
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+
|
|
|
b35d98 |
add_custom_target(
|
|
|
b35d98 |
dist
|
|
|
b35d98 |
COMMAND git archive --prefix=${CMAKE_PROJECT_NAME}-${git_commit}/ HEAD | gzip > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
|
|
|
b35d98 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
b35d98 |
)
|
|
|
b35d98 |
|
|
|
b35d98 |
-subdirs(src etc test)
|
|
|
b35d98 |
+include(FindPkgConfig)
|
|
|
b35d98 |
+pkg_check_modules(PC_SATYR REQUIRED satyr)
|
|
|
b35d98 |
+pkg_check_modules(PC_LIBREPORT REQUIRED libreport)
|
|
|
b35d98 |
+pkg_check_modules(PC_ABRT REQUIRED abrt)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+add_definitions(-D_GNU_SOURCE)
|
|
|
b35d98 |
+set(AJC_ENABLE_NLS true)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+subdirs(src etc test utils po)
|
|
|
b35d98 |
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
|
|
|
b35d98 |
new file mode 100644
|
|
|
b35d98 |
index 0000000..7c49772
|
|
|
b35d98 |
--- /dev/null
|
|
|
b35d98 |
+++ b/po/CMakeLists.txt
|
|
|
b35d98 |
@@ -0,0 +1,64 @@
|
|
|
b35d98 |
+project(po)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+if (AJC_ENABLE_NLS)
|
|
|
b35d98 |
+ find_program(INTLTOOL_UPDATE_CMD intltool-update)
|
|
|
b35d98 |
+ mark_as_advanced(INTLTOOL_UPDATE_CMD)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ find_program(XGETTEXT_CMD xgettext)
|
|
|
b35d98 |
+ mark_as_advanced(XGETTEXT_CMD)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ find_program(MSGMERGE_CMD msgmerge)
|
|
|
b35d98 |
+ mark_as_advanced(MSGMERGE_CMD)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ find_program(MSGFMT_CMD msgfmt)
|
|
|
b35d98 |
+ mark_as_advanced(MSGFMT_CMD)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ find_program(MSGFMT_CMD cat)
|
|
|
b35d98 |
+ mark_as_advanced(CAT_CMD)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ file(STRINGS ${po_SOURCE_DIR}/LINGUAS AJC_LINGUAS)
|
|
|
b35d98 |
+ set(AJC_LINGUAS_TARGETS)
|
|
|
b35d98 |
+ set(AJC_POTFILE ${CMAKE_PROJECT_NAME}.pot)
|
|
|
b35d98 |
+ set(AJC_POTFILE_OUTPUT ${po_BINARY_DIR}/${AJC_POTFILE})
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ add_custom_target(nls-update-sources
|
|
|
b35d98 |
+ ${INTLTOOL_UPDATE_CMD} -m
|
|
|
b35d98 |
+ WORKING_DIRECTORY ${po_SOURCE_DIR})
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ add_custom_command(OUTPUT ${AJC_POTFILE_OUTPUT}
|
|
|
b35d98 |
+ COMMAND ${XGETTEXT_CMD} --files-from ${po_SOURCE_DIR}/POTFILES.in --keyword=_ -o ${AJC_POTFILE_OUTPUT} --copyright-holder="ABRT Team" --msgid-bugs-address="crash-catcher at lists.fedorahosted.org" --no-wrap --no-location
|
|
|
b35d98 |
+ DEPENDS POTFILES.in
|
|
|
b35d98 |
+ WORKING_DIRECTORY ${abrt-java-connector_SOURCE_DIR}
|
|
|
b35d98 |
+ COMMENT "Extract translatable messages to ${AJC_POTFILE}"
|
|
|
b35d98 |
+ )
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ foreach(language ${AJC_LINGUAS})
|
|
|
b35d98 |
+ set(language_SOURCE ${po_SOURCE_DIR}/${language}.po)
|
|
|
b35d98 |
+ set(language_OUTPUT ${po_BINARY_DIR}/${language}/LC_MESSAGES/${CMAKE_PROJECT_NAME}.mo)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ add_custom_target(nls-update-${language}.po
|
|
|
b35d98 |
+ ${MSGMERGE_CMD} ${language} ${AJC_POTFILE_OUTPUT} -o ${language_SOURCE} --no-wrap
|
|
|
b35d98 |
+ DEPENDS ${language_SOURCE} ${AJC_POTFILE_OUTPUT}
|
|
|
b35d98 |
+ WORKING_DIRECTORY ${po_SOURCE_DIR}
|
|
|
b35d98 |
+ )
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ file(MAKE_DIRECTORY "${po_BINARY_DIR}/${language}/LC_MESSAGES")
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ add_custom_command(OUTPUT ${language_OUTPUT}
|
|
|
b35d98 |
+ COMMAND ${MSGFMT_CMD} -c -o ${language_OUTPUT} ${language_SOURCE}
|
|
|
b35d98 |
+ DEPENDS ${language_SOURCE}
|
|
|
b35d98 |
+ )
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ install(FILES ${language_OUTPUT}
|
|
|
b35d98 |
+ DESTINATION share/${CMAKE_PROJECT_NAME}/locale/${language}/LC_MESSAGES
|
|
|
b35d98 |
+ )
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ set(AJC_LINGUAS_TARGETS ${AJC_CATALOG_TARGETS} ${language_OUTPUT})
|
|
|
b35d98 |
+ endforeach(language)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ add_custom_target(nls ALL
|
|
|
b35d98 |
+ DEPENDS ${AJC_POTFILE_OUTPUT} ${AJC_LINGUAS_TARGETS}
|
|
|
b35d98 |
+ )
|
|
|
b35d98 |
+else(AJC_ENABLE_NLS)
|
|
|
b35d98 |
+ message("Native Language Support is disabled")
|
|
|
b35d98 |
+endif (AJC_ENABLE_NLS)
|
|
|
b35d98 |
diff --git a/po/LINGUAS b/po/LINGUAS
|
|
|
b35d98 |
new file mode 100644
|
|
|
b35d98 |
index 0000000..e69de29
|
|
|
b35d98 |
diff --git a/po/POTFILES.in b/po/POTFILES.in
|
|
|
b35d98 |
new file mode 100644
|
|
|
b35d98 |
index 0000000..21aec67
|
|
|
b35d98 |
--- /dev/null
|
|
|
b35d98 |
+++ b/po/POTFILES.in
|
|
|
b35d98 |
@@ -0,0 +1 @@
|
|
|
b35d98 |
+utils/abrt-action-analyze-java.c
|
|
|
b35d98 |
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
|
|
b35d98 |
index a00fe77..d084401 100644
|
|
|
b35d98 |
--- a/src/CMakeLists.txt
|
|
|
b35d98 |
+++ b/src/CMakeLists.txt
|
|
|
b35d98 |
@@ -1,13 +1,10 @@
|
|
|
b35d98 |
find_package(JNI REQUIRED)
|
|
|
b35d98 |
include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
|
|
|
b35d98 |
|
|
|
b35d98 |
-include(FindPkgConfig)
|
|
|
b35d98 |
-pkg_check_modules(PC_ABRT REQUIRED libreport)
|
|
|
b35d98 |
pkg_check_modules(PC_JOURNALD REQUIRED libsystemd-journal)
|
|
|
b35d98 |
-include_directories(${PC_ABRT_INCLUDE_DIRS})
|
|
|
b35d98 |
+include_directories(${PC_LIBREPORT_INCLUDE_DIRS})
|
|
|
b35d98 |
include_directories(${PC_JOURNALD_INCLUDE_DIRS})
|
|
|
b35d98 |
|
|
|
b35d98 |
-add_definitions(-D_GNU_SOURCE)
|
|
|
b35d98 |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99 -pedantic")
|
|
|
b35d98 |
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -DVERBOSE")
|
|
|
b35d98 |
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DSILENT")
|
|
|
b35d98 |
@@ -20,7 +17,7 @@ set_target_properties(
|
|
|
b35d98 |
PROPERTIES
|
|
|
b35d98 |
OUTPUT_NAME abrt-java-connector)
|
|
|
b35d98 |
|
|
|
b35d98 |
-target_link_libraries(AbrtChecker ${PC_ABRT_LIBRARIES})
|
|
|
b35d98 |
+target_link_libraries(AbrtChecker ${PC_LIBREPORT_LIBRARIES})
|
|
|
b35d98 |
target_link_libraries(AbrtChecker ${PC_JOURNALD_LIBRARIES})
|
|
|
b35d98 |
|
|
|
b35d98 |
install(TARGETS AbrtChecker DESTINATION ${LIB_INSTALL_DIR})
|
|
|
b35d98 |
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
|
|
|
b35d98 |
new file mode 100644
|
|
|
b35d98 |
index 0000000..c358968
|
|
|
b35d98 |
--- /dev/null
|
|
|
b35d98 |
+++ b/utils/CMakeLists.txt
|
|
|
b35d98 |
@@ -0,0 +1,34 @@
|
|
|
b35d98 |
+project(utils)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+set(AbrtActionAnalyzeJava_SRCS abrt-action-analyze-java.c)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+include(CheckIncludeFiles)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+if (AJC_ENABLE_NLS)
|
|
|
b35d98 |
+ check_include_files(locale.h HAVE_LOCALE_H)
|
|
|
b35d98 |
+ if (HAVE_LOCALE_H)
|
|
|
b35d98 |
+ set (ENABLE_NLS true)
|
|
|
b35d98 |
+ endif (HAVE_LOCALE_H)
|
|
|
b35d98 |
+endif (AJC_ENABLE_NLS)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+include_directories(${PC_SATYR_INCLUDE_DIRS})
|
|
|
b35d98 |
+include_directories(${PC_LIBREPORT_INCLUDE_DIRS})
|
|
|
b35d98 |
+include_directories(${PC_ABRT_INCLUDE_DIRS})
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+add_definitions(-DHAVE_CONFIG_H)
|
|
|
b35d98 |
+add_definitions(-DPACKAGE=\"${CMAKE_PROJECT_NAME}\")
|
|
|
b35d98 |
+add_definitions(-DLOCALEDIR=\"${LOCALE_INSTALL_DIR}\")
|
|
|
b35d98 |
+include_directories(${utils_BINARY_DIR})
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=gnu99 -pedantic")
|
|
|
b35d98 |
+set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -DVERBOSE")
|
|
|
b35d98 |
+set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DSILENT")
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+add_executable(abrt-action-analyze-java ${AbrtActionAnalyzeJava_SRCS})
|
|
|
b35d98 |
+target_link_libraries(abrt-action-analyze-java ${PC_SATYR_LIBRARIES})
|
|
|
b35d98 |
+target_link_libraries(abrt-action-analyze-java ${PC_LIBREPORT_LIBRARIES})
|
|
|
b35d98 |
+target_link_libraries(abrt-action-analyze-java ${PC_ABRT_LIBRARIES})
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+install(TARGETS abrt-action-analyze-java DESTINATION ${BIN_INSTALL_DIR})
|
|
|
b35d98 |
diff --git a/utils/abrt-action-analyze-java.c b/utils/abrt-action-analyze-java.c
|
|
|
b35d98 |
new file mode 100644
|
|
|
b35d98 |
index 0000000..a4728b6
|
|
|
b35d98 |
--- /dev/null
|
|
|
b35d98 |
+++ b/utils/abrt-action-analyze-java.c
|
|
|
b35d98 |
@@ -0,0 +1,258 @@
|
|
|
b35d98 |
+/*
|
|
|
b35d98 |
+ Copyright (C) 2014 Red Hat, Inc.
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
b35d98 |
+ it under the terms of the GNU General Public License as published by
|
|
|
b35d98 |
+ the Free Software Foundation; either version 2 of the License, or
|
|
|
b35d98 |
+ (at your option) any later version.
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ This program is distributed in the hope that it will be useful,
|
|
|
b35d98 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
b35d98 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
b35d98 |
+ GNU General Public License for more details.
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ You should have received a copy of the GNU General Public License along
|
|
|
b35d98 |
+ with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
b35d98 |
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
b35d98 |
+*/
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+#include <satyr/location.h>
|
|
|
b35d98 |
+#include <satyr/java/stacktrace.h>
|
|
|
b35d98 |
+#include <satyr/java/thread.h>
|
|
|
b35d98 |
+#include <satyr/java/frame.h>
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+#include <abrt/libabrt.h>
|
|
|
b35d98 |
+#include <stdlib.h>
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+static char *
|
|
|
b35d98 |
+backtrace_from_dump_dir(const char *dir_name)
|
|
|
b35d98 |
+{
|
|
|
b35d98 |
+ struct dump_dir *dd = dd_opendir(dir_name, DD_OPEN_READONLY);
|
|
|
b35d98 |
+ if (NULL == dd)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ return NULL;
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ /* Read backtrace */
|
|
|
b35d98 |
+ /* Prints an error message if the file cannot be loaded */
|
|
|
b35d98 |
+ char *backtrace_str = dd_load_text_ext(dd, FILENAME_BACKTRACE,
|
|
|
b35d98 |
+ DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ dd_close(dd);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ return backtrace_str;
|
|
|
b35d98 |
+}
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+static void
|
|
|
b35d98 |
+write_not_reportable_message_to_dump_dir(const char *dir_name, const char *message)
|
|
|
b35d98 |
+{
|
|
|
b35d98 |
+ struct dump_dir *dd = dd_opendir(dir_name, /*Open for writing*/0);
|
|
|
b35d98 |
+ if (NULL != dd)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ dd_save_text(dd, FILENAME_NOT_REPORTABLE, message);
|
|
|
b35d98 |
+ dd_close(dd);
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+}
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+static void
|
|
|
b35d98 |
+write_not_reportable_message_to_fd(int fdout, const char *message)
|
|
|
b35d98 |
+{
|
|
|
b35d98 |
+ full_write(fdout, message, strlen(message));
|
|
|
b35d98 |
+ full_write(fdout, "\n", 1);
|
|
|
b35d98 |
+}
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+static void
|
|
|
b35d98 |
+write_not_reportable_message_to_file(const char *file_name, const char *message)
|
|
|
b35d98 |
+{
|
|
|
b35d98 |
+ int fdout = open(file_name,
|
|
|
b35d98 |
+ O_WRONLY | O_TRUNC | O_CREAT | O_NOFOLLOW,
|
|
|
b35d98 |
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ if (0 > fdout)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ perror_msg("Can't open file '%s' for writing", file_name);
|
|
|
b35d98 |
+ return;
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+ write_not_reportable_message_to_fd(fdout, message);
|
|
|
b35d98 |
+ close(fdout);
|
|
|
b35d98 |
+}
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+static char *
|
|
|
b35d98 |
+backtrace_from_fd(int fdin)
|
|
|
b35d98 |
+{
|
|
|
b35d98 |
+ return xmalloc_read(fdin, /*no size limit*/NULL);
|
|
|
b35d98 |
+}
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+static char *
|
|
|
b35d98 |
+backtrace_from_file(const char *file_name)
|
|
|
b35d98 |
+{
|
|
|
b35d98 |
+ return xmalloc_xopen_read_close(file_name, /*no size limit*/NULL);
|
|
|
b35d98 |
+}
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+typedef void (*frame_cb)(struct sr_java_frame *frame, void *args);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+typedef struct {
|
|
|
b35d98 |
+ frame_cb callback;
|
|
|
b35d98 |
+ void *args;
|
|
|
b35d98 |
+} frame_proc_t;
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+static void
|
|
|
b35d98 |
+iterate_trough_stacktrace(struct sr_java_stacktrace *stacktrace, frame_proc_t **fproc)
|
|
|
b35d98 |
+{
|
|
|
b35d98 |
+ struct sr_java_thread *thread = stacktrace->threads;
|
|
|
b35d98 |
+ while (NULL != thread)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ struct sr_java_frame *frame = thread->frames;
|
|
|
b35d98 |
+ while (NULL != frame)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ frame_proc_t **it = fproc;
|
|
|
b35d98 |
+ while (NULL != *it)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ (*it)->callback(frame, (*it)->args);
|
|
|
b35d98 |
+ ++it;
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+ frame = frame->next;
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+ thread = thread->next;
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+}
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+static void
|
|
|
b35d98 |
+work_out_list_of_remote_urls(struct sr_java_frame *frame, struct strbuf *remote_files_csv)
|
|
|
b35d98 |
+{
|
|
|
b35d98 |
+ if (NULL != frame->class_path && prefixcmp(frame->class_path, "file://") != 0)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ struct stat buf;
|
|
|
b35d98 |
+ if (stat(frame->class_path, &buf) && errno == ENOENT)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ if (strstr(remote_files_csv->buf, frame->class_path) == NULL)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ strbuf_append_strf(remote_files_csv, "%s%s",
|
|
|
b35d98 |
+ remote_files_csv->buf[0] != '\0' ? ", " : "",
|
|
|
b35d98 |
+ frame->class_path);
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+}
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+int main(int argc, char *argv[])
|
|
|
b35d98 |
+{
|
|
|
b35d98 |
+#if ENABLE_NLS
|
|
|
b35d98 |
+ /* I18n */
|
|
|
b35d98 |
+ setlocale(LC_ALL, "");
|
|
|
b35d98 |
+ bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
b35d98 |
+ textdomain(PACKAGE);
|
|
|
b35d98 |
+#endif
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ abrt_init(argv);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ const char *dump_dir_name = NULL;
|
|
|
b35d98 |
+ const char *backtrace_file = NULL;
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ /* Can't keep these strings/structs static: _() doesn't support that */
|
|
|
b35d98 |
+ const char *program_usage_string = _(
|
|
|
b35d98 |
+ "& [[-d DIR] | [-f FILE]] [-o]\n"
|
|
|
b35d98 |
+ "\n"
|
|
|
b35d98 |
+ "Analyzes Java backtrace\n"
|
|
|
b35d98 |
+ );
|
|
|
b35d98 |
+ enum {
|
|
|
b35d98 |
+ OPT_v = 1 << 0,
|
|
|
b35d98 |
+ OPT_d = 1 << 1,
|
|
|
b35d98 |
+ OPT_f = 1 << 2,
|
|
|
b35d98 |
+ OPT_o = 1 << 3,
|
|
|
b35d98 |
+ };
|
|
|
b35d98 |
+ /* Keep enum above and order of options below in sync! */
|
|
|
b35d98 |
+ struct options program_options[] = {
|
|
|
b35d98 |
+ OPT__VERBOSE(&g_verbose),
|
|
|
b35d98 |
+ OPT_STRING('d', "dumpdir", &dump_dir_name, "DIR", _("Problem directory")),
|
|
|
b35d98 |
+ OPT_STRING('f', "backtrace", &backtrace_file, "FILE", _("Path to backtrace")),
|
|
|
b35d98 |
+ OPT_BOOL('o', "stdout", NULL, _("Print results on standard output")),
|
|
|
b35d98 |
+ { 0 }
|
|
|
b35d98 |
+ };
|
|
|
b35d98 |
+ program_options[ARRAY_SIZE(program_options) - 1].type = OPTION_END;
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ export_abrt_envvars(0);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ if (NULL != dump_dir_name && NULL != backtrace_file)
|
|
|
b35d98 |
+ error_msg_and_die("You need to pass either DIR or FILE");
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ int retval = 1;
|
|
|
b35d98 |
+ char *backtrace_str = NULL;
|
|
|
b35d98 |
+ if (NULL != dump_dir_name)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ backtrace_str = backtrace_from_dump_dir(dump_dir_name);
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+ else if (NULL != backtrace_file)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ backtrace_str = backtrace_from_file(backtrace_file);
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+ else
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ backtrace_str = backtrace_from_fd(STDIN_FILENO);
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ if (NULL == backtrace_str)
|
|
|
b35d98 |
+ goto finish;
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ struct sr_location location;
|
|
|
b35d98 |
+ sr_location_init(&location);
|
|
|
b35d98 |
+ const char *backtrace_str_ptr = backtrace_str;
|
|
|
b35d98 |
+ struct sr_java_stacktrace *stacktrace = sr_java_stacktrace_parse(&backtrace_str_ptr, &location);
|
|
|
b35d98 |
+ free(backtrace_str);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ if (NULL == stacktrace)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ error_msg("Could not parse the stack trace");
|
|
|
b35d98 |
+ goto finish;
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ struct strbuf *remote_files_csv = strbuf_new();
|
|
|
b35d98 |
+ frame_proc_t remote_files_proc = {
|
|
|
b35d98 |
+ .callback = (frame_cb)&work_out_list_of_remote_urls,
|
|
|
b35d98 |
+ .args = (void *)remote_files_csv
|
|
|
b35d98 |
+ };
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ frame_proc_t *fproc[] = {
|
|
|
b35d98 |
+ &remote_files_proc,
|
|
|
b35d98 |
+ //duphash_proc,
|
|
|
b35d98 |
+ //backtrace_usability,
|
|
|
b35d98 |
+ NULL,
|
|
|
b35d98 |
+ };
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ iterate_trough_stacktrace(stacktrace, fproc);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ sr_java_stacktrace_free(stacktrace);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ if ('\0' != remote_files_csv->buf[0])
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ char *not_reportable_message = xasprintf(
|
|
|
b35d98 |
+ _("This problem can be caused by a 3rd party code from the "\
|
|
|
b35d98 |
+ "jar/class at %s. In order to provide valuable problem " \
|
|
|
b35d98 |
+ "reports, ABRT will not allow you to submit this problem. If you " \
|
|
|
b35d98 |
+ "still want to participate in solving this problem, please contact " \
|
|
|
b35d98 |
+ "the developers directly."), remote_files_csv->buf);
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ if (opts & OPT_o)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ write_not_reportable_message_to_fd(STDOUT_FILENO, not_reportable_message);
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+ else if (NULL != dump_dir_name)
|
|
|
b35d98 |
+ {
|
|
|
b35d98 |
+ write_not_reportable_message_to_dump_dir(dump_dir_name, not_reportable_message);
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+ else
|
|
|
b35d98 |
+ { /* Just write it to the current working directory */
|
|
|
b35d98 |
+ write_not_reportable_message_to_file(FILENAME_NOT_REPORTABLE, not_reportable_message);
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ free(not_reportable_message);
|
|
|
b35d98 |
+ }
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ strbuf_free(remote_files_csv);
|
|
|
b35d98 |
+ retval = 0;
|
|
|
b35d98 |
+finish:
|
|
|
b35d98 |
+
|
|
|
b35d98 |
+ return retval;
|
|
|
b35d98 |
+}
|
|
|
b35d98 |
diff --git a/utils/config.h.in b/utils/config.h.in
|
|
|
b35d98 |
new file mode 100644
|
|
|
b35d98 |
index 0000000..6a26446
|
|
|
b35d98 |
--- /dev/null
|
|
|
b35d98 |
+++ b/utils/config.h.in
|
|
|
b35d98 |
@@ -0,0 +1,2 @@
|
|
|
b35d98 |
+#cmakedefine ENABLE_NLS 1
|
|
|
b35d98 |
+#cmakedefine HAVE_LOCALE_H 1
|
|
|
b35d98 |
--
|
|
|
b35d98 |
1.8.3.1
|
|
|
b35d98 |
|