crash-manager: dbus: Add /proc/tid/comm info to signal 90/210490/3
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 19 Jul 2019 13:23:42 +0000 (15:23 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 24 Jul 2019 09:43:12 +0000 (11:43 +0200)
Change-Id: Ibfbc159204b54a9c4a2eaacc491c56a950e246b5

src/crash-manager/crash-manager.c
src/crash-manager/dbus_notify.c
tests/system/dbus_notify/dbus_notify.sh.template

index 3cbc777..b275dbd 100644 (file)
@@ -694,6 +694,9 @@ static void launch_dbus_notify(struct crash_info *cinfo)
 
        char pid_str[11], tid_str[11], sig_str[11];
        char *prstatus_fd_str = NULL;
+       char tid_comm_str[KERNEL_DEFINED_TASK_COMM_LEN + 1] = { 0, };
+
+       (void)read_proc_file(cinfo->tid_info, "comm", tid_comm_str, sizeof(tid_comm_str), filter_drop_trailing_whitespace);
 
        if (asprintf(&prstatus_fd_str, "%d", cinfo->prstatus_fd) == -1) {
                _E("Unable to allocate memory: %m");
@@ -714,6 +717,7 @@ static void launch_dbus_notify(struct crash_info *cinfo)
                        "--reportpath", cinfo->result_path,
                        "--prstatus_fd", prstatus_fd_str,
                        "--signal", sig_str,
+                       "--tid-comm", tid_comm_str,
                        NULL };
 
        spawn(av, NULL, NULL, NULL, NULL);
index 9c42dec..0254092 100644 (file)
@@ -60,6 +60,7 @@ struct NotifyParams {
        char *report_path;
        char *appid;
        char *pkgid;
+       char *tid_comm;
 };
 
 static int _get_important_registers(int fd, struct RegInfo **reg_info)
@@ -172,6 +173,13 @@ static GVariant* build_message_data(const struct NotifyParams *notify_params)
                g_variant_builder_close(&md_builder);
        }
 
+       if (notify_params->tid_comm) {
+               g_variant_builder_open(&md_builder, G_VARIANT_TYPE("{sv}"));
+               g_variant_builder_add(&md_builder, "s", "sys.tid.comm");
+               g_variant_builder_add(&md_builder, "v", g_variant_new_string(notify_params->tid_comm));
+               g_variant_builder_close(&md_builder);
+       }
+
        struct RegInfo *reg_info;
        int regs_count = _get_important_registers(notify_params->prstatus_fd, &reg_info);
 
@@ -247,6 +255,7 @@ static bool parse_cmdline(int ac, char *av[], struct NotifyParams *params)
                FLAG_REPORTPATH,
                FLAG_PRSTATUS_FD,
                FLAG_SIGNAL,
+               FLAG_TID_COMM,
        };
        static const struct option options[] = {
                { .name = "cmdline",     .has_arg = required_argument, .flag = NULL, .val = FLAG_CMDLINE },
@@ -258,6 +267,7 @@ static bool parse_cmdline(int ac, char *av[], struct NotifyParams *params)
                { .name = "reportpath",  .has_arg = required_argument, .flag = NULL, .val = FLAG_REPORTPATH },
                { .name = "prstatus_fd", .has_arg = required_argument, .flag = NULL, .val = FLAG_PRSTATUS_FD },
                { .name = "signal",      .has_arg = required_argument, .flag = NULL, .val = FLAG_SIGNAL },
+               { .name = "tid-comm",    .has_arg = required_argument, .flag = NULL, .val = FLAG_TID_COMM },
                { NULL },
        };
 
@@ -283,6 +293,8 @@ static bool parse_cmdline(int ac, char *av[], struct NotifyParams *params)
                        params->prstatus_fd = atoi(optarg);
                else if (FLAG_SIGNAL == val)
                        params->signal = atoi(optarg);
+               else if (FLAG_TID_COMM == val)
+                       params->tid_comm = optarg;
        } while (val != -1);
 
        return params->cmd_name && params->cmd_path && params->appid && params->pkgid && params->prstatus_fd > 0;
index 89972cc..9e51679 100644 (file)
@@ -31,6 +31,10 @@ fi
 #         string "sys.signal"
 #         variant             int32 6
 #      )
+#      dict entry(
+#         string "sys.tid.comm"
+#         variant             string "sleep"
+#      )
 #   ]
 
 ( ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
@@ -72,7 +76,11 @@ for i in $(seq 1 10); do
                        score=$(($score + 1))
                fi
 
-               if [ $score -eq 4 ]; then
+               if egrep -A1 "string \"sys.tid.comm" $TMPFILE | egrep 'variant.*string \"kenny\"'; then
+                       score=$(($score + 1))
+               fi
+
+               if [ $score -eq 5 ]; then
                        exit_with_code "SUCCESS" ${SUCCESS_CODE}
                fi
        fi