hamano #1479(2007/07/26 15:02 GMT) [ C ] Rating6/6=1.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#include <stdio.h> #include <stdlib.h> #include <bfd.h> static bfd *abfd; static int size; static asymbol **symbols; static asection *section; const char *foo() { int ret; void *addr; const char *file; const char *func; unsigned int line; addr = __builtin_return_address(0); ret = bfd_find_nearest_line(abfd, section, symbols, (long)addr, &file, &func, &line); return func; } const char *bar() { return foo(); } const char *baz() { return foo(); } int main() { abfd = bfd_openr("/proc/self/exe", NULL); bfd_check_format(abfd, bfd_object); size = bfd_get_symtab_upper_bound(abfd); symbols = (asymbol**)malloc(size); section = bfd_get_section_by_name(abfd, ".debug_info"); printf("%s\n", bar()); printf("%s\n", baz()); free(symbols); return 0; }
Rating6/6=1.00-0+
[ reply ]
hamano
#1479()
[
C
]
Rating6/6=1.00
Rating6/6=1.00-0+
[ reply ]