summaryrefslogtreecommitdiff
path: root/src/bin/eina
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>2016-08-23 16:31:24 +0200
committerJean Guyomarc'h <jean.guyomarch@gmail.com>2016-08-23 21:15:24 +0200
commitb3c8470024ad11c83dba97955075464293afbff1 (patch)
tree31ee32568da25ba34c74e3ad6c1db398d5f05f49 /src/bin/eina
parent99d37838f32ef33b805bcefc7dc0320cfda05a0a (diff)
eina: fix eina_btlog for older osx versions
Older Mac OS X deprecated the default atos. This patch adds support for Mavericks (and maybe Yosemite as well).
Diffstat (limited to 'src/bin/eina')
-rw-r--r--src/bin/eina/eina_btlog.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/bin/eina/eina_btlog.c b/src/bin/eina/eina_btlog.c
index 2513d5c416..f251159b3c 100644
--- a/src/bin/eina/eina_btlog.c
+++ b/src/bin/eina/eina_btlog.c
@@ -51,7 +51,8 @@ struct _Bt
51 int line; 51 int line;
52}; 52};
53 53
54typedef Eina_Bool (*Translate_Func)(const char *bin_dir, 54typedef Eina_Bool (*Translate_Func)(const char *prog,
55 const char *bin_dir,
55 const char *bin_name, 56 const char *bin_name,
56 unsigned long long addr, 57 unsigned long long addr,
57 char **file_dir, 58 char **file_dir,
@@ -66,9 +67,11 @@ struct _Translation_Desc
66 const char *name; 67 const char *name;
67 const char *test; 68 const char *test;
68 Translate_Func func; 69 Translate_Func func;
70 const char *prog;
69}; 71};
70 72
71static Translate_Func _translate = NULL; 73static Translate_Func _translate = NULL;
74static const char *_prog = NULL;
72static Eina_Bool color = EINA_TRUE; 75static Eina_Bool color = EINA_TRUE;
73 76
74static void 77static void
@@ -102,7 +105,7 @@ path_split(const char *path, char **dir, char **file)
102} 105}
103 106
104static Eina_Bool 107static Eina_Bool
105_addr2line(const char *bin_dir, const char *bin_name, unsigned long long addr, 108_addr2line(const char *prog, const char *bin_dir, const char *bin_name, unsigned long long addr,
106 char **file_dir, char **file_name, char **func_name, int *file_line) 109 char **file_dir, char **file_name, char **func_name, int *file_line)
107{ 110{
108 char buf[4096], func[4096], *f1 = NULL, *f2 = NULL; 111 char buf[4096], func[4096], *f1 = NULL, *f2 = NULL;
@@ -110,8 +113,8 @@ _addr2line(const char *bin_dir, const char *bin_name, unsigned long long addr,
110 int line; 113 int line;
111 FILE *p; 114 FILE *p;
112 115
113 snprintf(buf, sizeof(buf), "addr2line -f -e %s/%s -C -a 0x%llx", 116 snprintf(buf, sizeof(buf), "%s -f -e %s/%s -C -a 0x%llx",
114 bin_dir, bin_name, addr); 117 prog, bin_dir, bin_name, addr);
115 p = popen(buf, "r"); 118 p = popen(buf, "r");
116 if (!p) return EINA_FALSE; 119 if (!p) return EINA_FALSE;
117 if ((fscanf(p, "%4095s\n", buf) == 1) && 120 if ((fscanf(p, "%4095s\n", buf) == 1) &&
@@ -145,7 +148,7 @@ _addr2line(const char *bin_dir, const char *bin_name, unsigned long long addr,
145 148
146#ifdef ATOS_COMPATIBLE 149#ifdef ATOS_COMPATIBLE
147static Eina_Bool 150static Eina_Bool
148_atos(const char *bin_dir, const char *bin_name, unsigned long long addr, 151_atos(const char *prog, const char *bin_dir, const char *bin_name, unsigned long long addr,
149 char **file_dir, char **file_name, char **func_name, int *file_line) 152 char **file_dir, char **file_name, char **func_name, int *file_line)
150{ 153{
151 char buf[4096]; 154 char buf[4096];
@@ -166,7 +169,7 @@ _atos(const char *bin_dir, const char *bin_name, unsigned long long addr,
166 // WARNING! Objective-C methods: 169 // WARNING! Objective-C methods:
167 // -[EcoreCocoaWindow windowDidResize:] (in libecore_cocoa.1.dylib) (ecore_cocoa_window.m:97) 170 // -[EcoreCocoaWindow windowDidResize:] (in libecore_cocoa.1.dylib) (ecore_cocoa_window.m:97)
168 171
169 snprintf(buf, sizeof(buf), "atos -o %s/%s 0x%llx", bin_dir, bin_name, addr); 172 snprintf(buf, sizeof(buf), "%s -o %s/%s 0x%llx", prog, bin_dir, bin_name, addr);
170 p = popen(buf, "r"); 173 p = popen(buf, "r");
171 if (!p) goto end; 174 if (!p) goto end;
172 175
@@ -245,11 +248,11 @@ bt_append(Eina_List *btl, const char *btline)
245 path_split(bin, &(bt->bin_dir), &(bt->bin_name)); 248 path_split(bin, &(bt->bin_dir), &(bt->bin_name));
246 if (!bt->bin_dir) bt->bin_dir = strdup(""); 249 if (!bt->bin_dir) bt->bin_dir = strdup("");
247 if (!bt->bin_name) bt->bin_name = strdup(""); 250 if (!bt->bin_name) bt->bin_name = strdup("");
248 if (!_translate(bt->bin_dir, bt->bin_name, offset - base, 251 if (!_translate(_prog, bt->bin_dir, bt->bin_name, offset - base,
249 &(bt->file_dir), &(bt->file_name), 252 &(bt->file_dir), &(bt->file_name),
250 &(bt->func_name), &(bt->line))) 253 &(bt->func_name), &(bt->line)))
251 { 254 {
252 if (!_translate(bt->bin_dir, bt->bin_name, offset, 255 if (!_translate(_prog, bt->bin_dir, bt->bin_name, offset,
253 &(bt->file_dir), &(bt->file_name), 256 &(bt->file_dir), &(bt->file_name),
254 &(bt->func_name), &(bt->line))) 257 &(bt->func_name), &(bt->line)))
255 { 258 {
@@ -281,6 +284,7 @@ _translation_function_detect(const Translation_Desc *desc)
281 if (ret == 0) 284 if (ret == 0)
282 { 285 {
283 _translate = d->func; 286 _translate = d->func;
287 _prog = d->prog;
284 break; 288 break;
285 } 289 }
286 } 290 }
@@ -302,18 +306,27 @@ main(int argc, char **argv)
302 { /* Mac OS X */ 306 { /* Mac OS X */
303 .name = "atos", 307 .name = "atos",
304 .test = "atos --help &> /dev/null", 308 .test = "atos --help &> /dev/null",
305 .func = _atos 309 .func = _atos,
310 .prog = "atos"
311 },
312 { /* Mac OS X */
313 .name = "atos (old)",
314 .test = "xcrun atos --help &> /dev/null",
315 .func = _atos,
316 .prog = "xcrun atos"
306 }, 317 },
307#endif 318#endif
308 { /* GNU binutils */ 319 { /* GNU binutils */
309 .name = "addr2line", 320 .name = "addr2line",
310 .test = "addr2line --help &> /dev/null", 321 .test = "addr2line --help &> /dev/null",
311 .func = _addr2line 322 .func = _addr2line,
323 .prog = "addr2line"
312 }, 324 },
313 { /* For imported GNU binutils */ 325 { /* For imported GNU binutils */
314 .name = "GNU addr2line", 326 .name = "GNU addr2line",
315 .test = "gaddr2line --help &> /dev/null", 327 .test = "gaddr2line --help &> /dev/null",
316 .func = _addr2line 328 .func = _addr2line,
329 .prog = "addr2line"
317 }, 330 },
318 { NULL, NULL, NULL } /* Sentinel */ 331 { NULL, NULL, NULL } /* Sentinel */
319 }; 332 };