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