2 * Copyright (c) 2016-2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #define LOG_TAG "LIBCRASH-SERVICE"
25 #include "shared/log.h"
27 #define BUS_NAME "org.tizen.system.crash.livedump"
28 #define OBJECT_PATH "/Org/Tizen/System/Crash/Livedump"
29 #define INTERFACE_NAME "org.tizen.system.crash.livedump"
30 #define METHOD_NAME "livedump_pid"
32 static GDBusConnection* dbus_init(void)
35 GDBusConnection *conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
38 _E("Failed to get dbus: %s", error ? error->message : "");
47 bool livedump_pid(pid_t pid, const char *dump_reason, char *report_path, size_t report_path_len)
50 GDBusConnection *conn = dbus_init();
55 GVariant *parameters = g_variant_new("(is)", pid, dump_reason);
58 GVariant *reply = g_dbus_connection_call_sync(conn,
64 G_VARIANT_TYPE("(s)"),
65 G_DBUS_CALL_FLAGS_NONE,
69 if (!reply || error) {
70 _E("Error while calling livedump_pid via dbus (pid=%d, reason=%s): %s", pid, dump_reason, error ? error->message : "");
77 if (!g_variant_is_of_type(reply, G_VARIANT_TYPE("(s)"))) {
78 _E("reply is not of the correct type (s)");
84 g_variant_get(reply, "(&s)", &reply_str);
85 if (strlen(reply_str) <= (report_path_len + 1)) {
86 strncpy(report_path, reply_str, report_path_len);
88 _E("Report path (%s) is longer than report_path_len", reply_str);