+++ /dev/null
-# "on_off foo" wil turn into "ON" or "OFF"
-%define on_off() %{expand:%%{?with_%{1}:ON}%%{!?with_%{1}:OFF}}
-
-Name: libbugreport
-Summary: libbugreport provides API to communicate with bugreport-service
-Version: 1.0.1
-Release: 1
-Provides: libcrash-service = %{version}-%{release}
-Group: Framework/system
-License: Apache-2.0
-Source0: %{name}-%{version}.tar.gz
-Source1001: crash-worker.manifest
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: cmake
-
-%description
-
-%package -n libbugreport-devel
-Summary: package provides headers needed to develop programs using bugreport-service
-%description -n libbugreport-devel
-%description -n libbugreport-devel
-
-%prep
-%setup -q
-
-%build
-cp %{SOURCE1001} .
-
-export CFLAGS+=" -Werror"
-
-%cmake src/bugreport/ \
- -DCMAKE_INSTALL_PREFIX=%{_prefix} \
- -DLOGGER=dlog \
- -DDLOG_LOG_LEVEL=DLOG_INFO \
- -DVERSION=%{version}
-
-make %{?jobs:-j%jobs}
-
-%install
-rm -rf %{buildroot}
-%make_install
-
-%files
-%license LICENSE
-%manifest crash-worker.manifest
-%{_libdir}/libbugreport.so.*
-
-%files -n libbugreport-devel
-%license LICENSE
-%manifest crash-worker.manifest
-%{_includedir}/libbugreport.h
-%{_libdir}/libbugreport.so
-%{_libdir}/pkgconfig/bugreport.pc
#include <diagnostics.h>
#include <unistd.h>
#include <signal.h>
+#include <libbugreport.h>
#include "bugreport-service.h"
#include "crash-manager/crash-manager.h"
-#include "libbugreport.h"
#include "shared/log.h"
#include "shared/util.h"
#include "diagnostics/diagnostics.h"
#include <time.h>
#include <stdio.h>
#include <string.h>
+#include <libbugreport.h>
-#include "libbugreport.h"
#include "bugreport-service.h"
#include "systemdump.h"
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(bugreport C)
-
-ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/../../include include/)
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../../src/ ${CMAKE_SOURCE_DIR}/../../include)
-
-INCLUDE(GNUInstallDirs)
-
-INCLUDE(FindPkgConfig)
-
-pkg_check_modules(bugreport_pkgs REQUIRED
- dlog
- gio-2.0
- gio-unix-2.0
- )
-
-FOREACH(flag ${bugreport_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wno-unused-function -Wno-unused-const-variable")
-
-INCLUDE(${CMAKE_SOURCE_DIR}/../../cmake/ProcessM4.cmake)
-
-LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/crash-manager)
-
-ADD_LIBRARY(libbugreport SHARED libbugreport-service.c)
-SET_TARGET_PROPERTIES(libbugreport PROPERTIES
- SOVERSION 1
- PUBLIC_HEADER libbugreport.h
- OUTPUT_NAME bugreport)
-
-CONFIGURE_FILE(bugreport.pc.in ${CMAKE_SOURCE_DIR}/bugreport.pc @ONLY)
-
-INSTALL(TARGETS libbugreport LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bugreport.pc
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
-
+++ /dev/null
-prefix=/usr
-exec_prefix=${prefix}
-includedir=${prefix}/include
-libdir=${exec_prefix}/lib
-
-Name: bugreport
-Description: The bugreport library
-Version: @VERSION@
-Cflags: -I${includedir}
-Libs: -L${libdir} -lbugreport
+++ /dev/null
-/*
- * Copyright (c) 2016-2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gio/gio.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define LOG_TAG "LIBBUGREPORT"
-
-#include "libbugreport.h"
-#include "shared/log.h"
-
-#define BUS_NAME "org.tizen.system.crash.livedump"
-#define OBJECT_PATH "/Org/Tizen/System/Crash/Livedump"
-#define INTERFACE_NAME "org.tizen.system.crash.livedump"
-#define METHOD_NAME "livedump_pid"
-
-static GDBusConnection* dbus_init(void)
-{
- GError *error = NULL;
- GDBusConnection *conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-
- if (!conn || error) {
- _E("Failed to get dbus: %s", error ? error->message : "");
- if (error)
- g_error_free(error);
- return NULL;
- }
-
- return conn;
-}
-
-int livedump_pid(pid_t pid, const char *dump_reason, char *report_path, size_t report_path_len)
-{
- int res = TIZEN_ERROR_NONE;
- GDBusConnection *conn = dbus_init();
-
- if (!conn)
- return TIZEN_ERROR_IO_ERROR;
-
- GVariant *parameters = g_variant_new("(is)", pid, dump_reason);
-
- GError *error = NULL;
- GVariant *reply = g_dbus_connection_call_sync(conn,
- BUS_NAME,
- OBJECT_PATH,
- INTERFACE_NAME,
- METHOD_NAME,
- parameters,
- G_VARIANT_TYPE("(s)"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
- if (!reply || error) {
- _E("Error while calling livedump_pid via dbus (pid=%d, reason=%s): %s", pid, dump_reason, error ? error->message : "");
- res = TIZEN_ERROR_IO_ERROR;
-
- if (error) {
- if (error->code == G_DBUS_ERROR_ACCESS_DENIED)
- res = TIZEN_ERROR_PERMISSION_DENIED;
- if (error->code == CS_ERR_NO_PROC)
- res = TIZEN_ERROR_NO_SUCH_PROCESS;
- g_error_free(error);
- }
- goto exit;
- }
-
- if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(s)"))) {
- _E("reply is not of the correct type (s)");
- res = TIZEN_ERROR_IO_ERROR;
- goto exit;
- }
-
- gchar *reply_str;
- g_variant_get(reply, "(&s)", &reply_str);
- if (strlen(reply_str) <= (report_path_len + 1)) {
- strncpy(report_path, reply_str, report_path_len);
- } else {
- _E("Report path (%s) is longer than report_path_len", reply_str);
- res = TIZEN_ERROR_IO_ERROR;
- }
-exit:
- g_object_unref(conn);
- return res;
-}
+++ /dev/null
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <stdbool.h>
-#include <sys/types.h>
-
-#define CS_ERROR 1
-#define CS_ERR_NO_ERROR 0
-#define CS_ERR_PARAM 1
-#define CS_ERR_TIMEOUT 2
-#define CS_ERR_READ 3
-#define CS_ERR_INTERNAL 4
-#define CS_ERR_UNSUPPORTED 5
-#define CS_ERR_NO_PROC 6
-
-/**
- * @brief Sends a request to the bugreport-service to create livedump report of specific process.
- * @param pid PID of process for which the report should be created.
- * @param dump_reason the reason that should be included in the raport.
- * @param report_path pointer to the buffer in which will be saved the report path.
- * @param report_path_len lenght of buffer for the report path.
- * @return 0 on success, otherwise a negative error value
- * @retval #TIZEN_ERROR_NONE Success
- * @retval #TIZEN_ERROR_PERMISSION_DENIED Permission denied
- * @retval #TIZEN_ERROR_NO_SUCH_PROCESS No such process
- * @retval #TIZEN_ERROR_IO_ERROR Internal error occurred
- */
-extern int livedump_pid(pid_t pid, const char *dump_reason, char *report_path, size_t report_path_len);