343 return add_thread_info(ph, pthread_id, lwp_id) != NULL; |
343 return add_thread_info(ph, pthread_id, lwp_id) != NULL; |
344 } |
344 } |
345 |
345 |
346 static bool read_lib_info(struct ps_prochandle* ph) { |
346 static bool read_lib_info(struct ps_prochandle* ph) { |
347 char fname[32]; |
347 char fname[32]; |
348 char buf[256]; |
348 char buf[PATH_MAX]; |
349 FILE *fp = NULL; |
349 FILE *fp = NULL; |
350 |
350 |
351 sprintf(fname, "/proc/%d/maps", ph->pid); |
351 sprintf(fname, "/proc/%d/maps", ph->pid); |
352 fp = fopen(fname, "r"); |
352 fp = fopen(fname, "r"); |
353 if (fp == NULL) { |
353 if (fp == NULL) { |
354 print_debug("can't open /proc/%d/maps file\n", ph->pid); |
354 print_debug("can't open /proc/%d/maps file\n", ph->pid); |
355 return false; |
355 return false; |
356 } |
356 } |
357 |
357 |
358 while(fgets_no_cr(buf, 256, fp)){ |
358 while(fgets_no_cr(buf, PATH_MAX, fp)){ |
359 char * word[6]; |
359 char * word[7]; |
360 int nwords = split_n_str(buf, 6, word, ' ', '\0'); |
360 int nwords = split_n_str(buf, 7, word, ' ', '\0'); |
361 if (nwords > 5 && find_lib(ph, word[5]) == false) { |
361 |
|
362 if (nwords < 6) { |
|
363 // not a shared library entry. ignore. |
|
364 continue; |
|
365 } |
|
366 |
|
367 // SA does not handle the lines with patterns: |
|
368 // "[stack]", "[heap]", "[vdso]", "[vsyscall]", etc. |
|
369 if (word[5][0] == '[') { |
|
370 // not a shared library entry. ignore. |
|
371 continue; |
|
372 } |
|
373 |
|
374 if (nwords > 6) { |
|
375 // prelink altered mapfile when the program is running. |
|
376 // Entries like one below have to be skipped |
|
377 // /lib64/libc-2.15.so (deleted) |
|
378 // SO name in entries like one below have to be stripped. |
|
379 // /lib64/libpthread-2.15.so.#prelink#.EECVts |
|
380 char *s = strstr(word[5],".#prelink#"); |
|
381 if (s == NULL) { |
|
382 // No prelink keyword. skip deleted library |
|
383 print_debug("skip shared object %s deleted by prelink\n", word[5]); |
|
384 continue; |
|
385 } |
|
386 |
|
387 // Fall through |
|
388 print_debug("rectifying shared object name %s changed by prelink\n", word[5]); |
|
389 *s = 0; |
|
390 } |
|
391 |
|
392 if (find_lib(ph, word[5]) == false) { |
362 intptr_t base; |
393 intptr_t base; |
363 lib_info* lib; |
394 lib_info* lib; |
364 #ifdef _LP64 |
395 #ifdef _LP64 |
365 sscanf(word[0], "%lx", &base); |
396 sscanf(word[0], "%lx", &base); |
366 #else |
397 #else |