Commit 84a83f36 authored by David Johnson's avatar David Johnson
Browse files

Fix module ELF/debuginfo file path search.

I assume what happened here is that when we added the debuginfo root
prefix business, and expanded the search for vmlinux, that we never did
that for modules; but not sure.  Anyway, this fixes the module search so
it is similar to searching for vmlinux.
parent ef03a69f
Pipeline #2174 passed with stages
in 5 minutes and 22 seconds
/*
* Copyright (c) 2013, 2014, 2015, 2016 The University of Utah
* Copyright (c) 2013, 2014, 2015, 2016, 2017 The University of Utah
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -231,21 +231,46 @@ int os_linux_attach(struct target *target) {
strdup(lstate->kernel_sysmap_filename));
}
/* Figure out where the modules are. */
if ((tmp = strstr(lstate->kernel_filename,"vmlinuz-"))) {
lstate->kernel_module_dir = malloc(PATH_MAX);
snprintf(lstate->kernel_module_dir,PATH_MAX,
"/lib/modules/%s",tmp+strlen("vmlinuz-"));
}
else if ((tmp = strstr(lstate->kernel_filename,"vmlinux-syms-"))) {
lstate->kernel_module_dir = malloc(PATH_MAX);
snprintf(lstate->kernel_module_dir,PATH_MAX,
"/lib/modules/%s",tmp+strlen("vmlinux-syms-"));
}
else if ((tmp = strstr(lstate->kernel_filename,"vmlinux-"))) {
/* Figure out the kernel version, so we can search for modules later. */
tmp = strstr(lstate->kernel_filename,"vmlinuz-") + strlen("vmlinuz-");
if (!tmp)
tmp = strstr(lstate->kernel_filename,"vmlinux-syms-") + strlen("vmlinux-syms-");
if (!tmp)
tmp = strstr(lstate->kernel_filename,"vmlinux-") + strlen("vmlinux-");
/*
* If we found something, look for the kernel module dir. We look in
* two places:
*
* /usr/lib/debug/lib/modules/<kernel_version>
* /lib/modules/<kernel_version>
*/
if (tmp) {
lstate->kernel_module_dir = malloc(PATH_MAX);
snprintf(lstate->kernel_module_dir,PATH_MAX,
"/lib/modules/%s",tmp+strlen("vmlinux-"));
lstate->kernel_module_dir = '\0';
if (lstate->kernel_module_dir[0] == '\0') {
snprintf(lstate->kernel_module_dir,PATH_MAX,
"%s/usr/lib/debug/lib/modules/%s",
(target->spec->debugfile_root_prefix) \
? target->spec->debugfile_root_prefix : "",
tmp);
if (access(lstate->kernel_module_dir,R_OK))
lstate->kernel_module_dir[0] = '\0';
}
if (lstate->kernel_module_dir[0] == '\0') {
snprintf(lstate->kernel_module_dir,PATH_MAX,
"%s/lib/modules/%s",
(target->spec->debugfile_root_prefix) \
? target->spec->debugfile_root_prefix : "",
tmp);
if (access(lstate->kernel_module_dir,R_OK))
lstate->kernel_module_dir[0] = '\0';
}
if (lstate->kernel_module_dir[0] == '\0') {
free(lstate->kernel_module_dir);
lstate->kernel_module_dir = NULL;
}
}
if (sscanf(lstate->kernel_version,"%m[0-9].%m[0-9].%m[0-9]",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment