diff options
author | Roland McGrath <roland@redhat.com> | 2011-02-11 12:29:45 -0800 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2011-02-11 12:29:45 -0800 |
commit | 6ecdead8c0fbba51e8b2561e4d54dd7be3f69204 (patch) | |
tree | c4cf874ff7c9f26b3c64856bbaa4bb824baaf5a5 | |
parent | 4a14ef7b9a4b274fd45d17512cf0da42956b672b (diff) | |
download | elfutils-6ecdead8c0fbba51e8b2561e4d54dd7be3f69204.tar.gz |
libdwfl: Search for Linux kernel binaries with compression file name suffixes.
-rw-r--r-- | libdwfl/ChangeLog | 5 | ||||
-rw-r--r-- | libdwfl/linux-kernel-modules.c | 46 |
2 files changed, 49 insertions, 2 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 6a31f1d5..0cbeb850 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2011-02-11 Roland McGrath <roland@redhat.com> + + * linux-kernel-modules.c (try_kernel_name): Try .gz, .bz2, .xz + suffixes if corresponding decompression support is enabled. + 2011-02-01 Roland McGrath <roland@redhat.com> * dwfl_module_getdwarf.c (find_prelink_address_sync): Use the diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 2479292a..f3d9af10 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -1,5 +1,5 @@ /* Standard libdwfl callbacks for debugging the running Linux kernel. - Copyright (C) 2005-2010 Red Hat, Inc. + Copyright (C) 2005-2011 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -78,6 +78,19 @@ #define MODULE_SECT_NAME_LEN 32 /* Minimum any linux/module.h has had. */ +static const char *vmlinux_suffixes[] = + { +#ifdef USE_ZLIB + ".gz", +#endif +#ifdef USE_BZLIB + ".bz2", +#endif +#ifdef USE_LZMA + ".xz", +#endif + }; + /* Try to open the given file as it is or under the debuginfo directory. */ static int try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug) @@ -91,6 +104,7 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug) ? *dwfl->callbacks->debuginfo_path : NULL) ?: DEFAULT_DEBUGINFO_PATH)[0] == ':') ? -1 : TEMP_FAILURE_RETRY (open64 (*fname, O_RDONLY))); + if (fd < 0) { char *debugfname = NULL; @@ -106,8 +120,36 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug) fd = INTUSE(dwfl_standard_find_debuginfo) (&fakemod, NULL, NULL, 0, *fname, NULL, 0, &debugfname); + if (debugfname != NULL) + { + free (*fname); + *fname = debugfname; + } + } + + if (fd < 0) + for (size_t i = 0; + i < sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0]; + ++i) + { + char *zname; + if (asprintf (&zname, "%s%s", *fname, vmlinux_suffixes[i]) > 0) + { + fd = TEMP_FAILURE_RETRY (open64 (zname, O_RDONLY)); + if (fd < 0) + free (zname); + else + { + free (*fname); + *fname = zname; + } + } + } + + if (fd < 0) + { free (*fname); - *fname = debugfname; + *fname = NULL; } return fd; |