Copy address of regions related to C# DLL files. 45/226545/9
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 3 Mar 2020 12:43:08 +0000 (13:43 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 12 Mar 2020 11:20:46 +0000 (12:20 +0100)
Change-Id: Ic2e7e4b78d0ba85efcb6c3735152c5a5bffb395e

src/crash-stack/crash-stack.c
src/shared/util.c
src/shared/util.h

index 0445d9c..cd9138b 100644 (file)
@@ -377,9 +377,11 @@ static struct addr_node *get_addr_list_from_maps(int fd)
                if (result < 0)
                        continue;
                perm[PERM_LEN] = 0;
+
                /* rwxp */
                if ((perm[2] == 'x' && path[0] == '/') ||
-                   (perm[1] == 'w' && path[0] != '/')) {
+                   (perm[1] == 'w' && path[0] != '/') ||
+                   is_dotnet_file(path)) {
                        char* addr2 = strchr(addr, '-');
                        if (addr2 == NULL) {
                                _E("Not found '-' in addr: %s", addr);
index 239ebee..9e90b64 100644 (file)
@@ -637,6 +637,27 @@ exit:
        return result;
 }
 
+bool is_dotnet_file(const char *path)
+{
+       static const char *DOTNET_EXTS[] = { ".dll", ".exe", NULL };
+
+       bool result = false;
+       size_t p_len = strlen(path);
+       while (p_len > 0 && path[p_len-1] == '\n')
+               p_len--;
+
+       for (const char **ext = DOTNET_EXTS; *ext != NULL; ext++) {
+               size_t d_len = strlen(*ext);
+
+               if ((p_len >= d_len) &&
+                   (strncasecmp(&path[p_len - d_len], *ext, d_len) == 0)) {
+                       result = true;
+                       break;
+               }
+       }
+       return result;
+}
+
 /**
  * @}
  */
index 882ce5e..a4325ba 100644 (file)
@@ -76,6 +76,7 @@ bool file_exists_in_dir(const char *dir_path, const char *file_name);
 
 bool write_to_file(const char *content, const char *base_dir, const char *file_name);
 
+bool is_dotnet_file(const char *path);
 #ifdef __cplusplus
 }
 #endif