mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-02-01 05:54:08 +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);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __iwd_backtrace_init(const char *program)
|
void __iwd_backtrace_init()
|
||||||
{
|
{
|
||||||
static char path[PATH_MAX];
|
static char path[PATH_MAX];
|
||||||
|
static char cwd[PATH_MAX];
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
program_exec = program;
|
/* Attempt to get the full path to our executable */
|
||||||
program_path = getcwd(path, sizeof(path));
|
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);
|
sigemptyset(&mask);
|
||||||
sa.sa_handler = signal_handler;
|
sa.sa_handler = signal_handler;
|
||||||
|
@ -20,6 +20,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
void __iwd_backtrace_init(const char *program);
|
void __iwd_backtrace_init();
|
||||||
void __iwd_backtrace_print(unsigned int offset);
|
void __iwd_backtrace_print(unsigned int offset);
|
||||||
#endif
|
#endif
|
||||||
|
@ -197,7 +197,7 @@ int main(int argc, char *argv[])
|
|||||||
l_debug_enable("*");
|
l_debug_enable("*");
|
||||||
|
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
__iwd_backtrace_init(argv[0]);
|
__iwd_backtrace_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
l_info("Wireless daemon version %s", VERSION);
|
l_info("Wireless daemon version %s", VERSION);
|
||||||
|
Loading…
Reference in New Issue
Block a user