Add AUL api to send backtrace print request 08/323908/3
authorJihoi Kim <jihoi.kim@samsung.com>
Fri, 25 Apr 2025 07:04:42 +0000 (16:04 +0900)
committerJihoi Kim <jihoi.kim@samsung.com>
Mon, 12 May 2025 08:42:58 +0000 (17:42 +0900)
- Implement aul_send_backtrace_request
- Define WATCHDOG_PRINT_BT command
- Add Debug log in ptrace for bactrace

Change-Id: Iba23650253fd0ba706b6bb63c906b69a9b248029
Signed-off-by: Jihoi Kim <jihoi.kim@samsung.com>
src/aul/aul_backtrace.cc
src/aul/include/aul_backtrace.h
src/aul/include/aul_cmd.h

index 583a21f5853d0942e8639be6dc8af0a014d7f2ef..92b33c8c146c1d1e5380510450e3b83ce11a5290 100644 (file)
@@ -33,6 +33,7 @@
 #include "aul/aul_api.h"
 #include "aul/common/log_private.hh"
 #include "aul/include/aul.h"
+#include "aul/app_request.h"
 
 namespace {
 
@@ -144,6 +145,7 @@ class Ptrace {
       return -1;
     }
 
+    _D("Ptrace attach success. pid=%d, SIGCHLD raised.", pid_);
     attached_ = true;
     return 0;
   }
@@ -190,3 +192,20 @@ extern "C" API int aul_backtrace_print(pid_t pid) {
   trace.PrintBacktrace();
   return AUL_R_OK;
 }
+
+extern "C" API int aul_send_backtrace_request(pid_t pid) {
+  if (pid < 1) {
+    _E("Invalid parameter");
+    return AUL_R_EINVAL;
+  }
+
+  int ret = aul::internal::AppRequest(WATCHDOG_PRINT_BT, getuid())
+      .With({{AUL_K_TARGET_PID, std::to_string(pid)}})
+      .SendSimply();
+  if (ret < 0) {
+    _E("Failed to send request. error(%d)", ret);
+    return ret;
+  }
+
+  return AUL_R_OK;
+}
index 839f1389671a7f726f6567cd45d89facea628438..1d75030498996d3e1dd08e1b4d458694147bb3c2 100644 (file)
@@ -35,6 +35,17 @@ extern "C" {
  */
 int aul_backtrace_print(pid_t pid);
 
+/**
+ * @brief Requests amd to print backtrace information of the specified process.
+ * @param[in] pid The process ID.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #AUL_R_OK Successful
+ * @retval #AUL_R_EINVAL Invalid parameter
+ * @retval #AUL_R_EILLACC Permission denied
+ * @retval #AUL_R_ERROR General error
+ */
+int aul_send_backtrace_request(pid_t pid);
+
 #ifdef __cplusplus
 }
 #endif
index 36fe2f1c9dd4ee75a387bfe19ed839363e7b129a..13f7a4748a4e69ccc86e4265c358b9eed2c6225c 100644 (file)
@@ -225,6 +225,8 @@ enum app_cmd {
        APP_THAW = 179,
        APP_TERM_BY_PID_FOR_OOM = 180,
 
+       WATCHDOG_PRINT_BT = 181,
+
        APP_CMD_MAX
 };