mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-31 21:34:09 +01:00
backtrace: Try to find absolute executable path
This allows us to get backtraces from test_runner which does not start iwd from a current working directory that is a parent of the iwd executable.
This commit is contained in:
parent
44f23e7a5f
commit
2e820abea1
@ -156,14 +156,33 @@ static void signal_handler(int signo)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void __iwd_backtrace_init(const char *program)
|
||||
void __iwd_backtrace_init()
|
||||
{
|
||||
static char path[PATH_MAX];
|
||||
static char cwd[PATH_MAX];
|
||||
struct sigaction sa;
|
||||
sigset_t mask;
|
||||
ssize_t len;
|
||||
|
||||
program_exec = program;
|
||||
program_path = getcwd(path, sizeof(path));
|
||||
/* Attempt to get the full path to our executable */
|
||||
len = readlink("/proc/self/exe", path, sizeof(path) - 1);
|
||||
if (len > 0) {
|
||||
int i;
|
||||
path[len] = '\0';
|
||||
|
||||
for (i = len - 1; i >= 0; i--) {
|
||||
if (path[i] != '/')
|
||||
continue;
|
||||
|
||||
program_exec = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (program_exec == NULL)
|
||||
return;
|
||||
|
||||
program_path = getcwd(cwd, sizeof(cwd));
|
||||
|
||||
sigemptyset(&mask);
|
||||
sa.sa_handler = signal_handler;
|
||||
|
@ -20,6 +20,6 @@
|
||||
*
|
||||
*/
|
||||
#ifdef __GLIBC__
|
||||
void __iwd_backtrace_init(const char *program);
|
||||
void __iwd_backtrace_init();
|
||||
void __iwd_backtrace_print(unsigned int offset);
|
||||
#endif
|
||||
|
@ -197,7 +197,7 @@ int main(int argc, char *argv[])
|
||||
l_debug_enable("*");
|
||||
|
||||
#ifdef __GLIBC__
|
||||
__iwd_backtrace_init(argv[0]);
|
||||
__iwd_backtrace_init();
|
||||
#endif
|
||||
|
||||
l_info("Wireless daemon version %s", VERSION);
|
||||
|
Loading…
Reference in New Issue
Block a user