From: Roland McGrath Date: Fri, 11 Feb 2011 20:29:45 +0000 (-0800) Subject: libdwfl: Search for Linux kernel binaries with compression file name suffixes. X-Git-Tag: elfutils-0.152~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ecdead8c0fbba51e8b2561e4d54dd7be3f69204;p=thirdparty%2Felfutils.git libdwfl: Search for Linux kernel binaries with compression file name suffixes. --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 6a31f1d52..0cbeb8502 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2011-02-11 Roland McGrath + + * linux-kernel-modules.c (try_kernel_name): Try .gz, .bz2, .xz + suffixes if corresponding decompression support is enabled. + 2011-02-01 Roland McGrath * 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 2479292ac..f3d9af108 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;