+2013-12-18 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * argp-std.c (offline_find_elf): Remove.
+ (offline_callbacks): Use dwfl_build_id_find_elf instead.
+ * dwfl_build_id_find_elf.c (dwfl_build_id_find_elf): Move here the code
+ removed above.
+
2013-12-18 Jan Kratochvil <jan.kratochvil@redhat.com>
unwinder: s390 and s390x
{ NULL, 0, NULL, 0, NULL, 0 }
};
-/* Wrapper to provide proper FILE_NAME for -e|--executable. */
-static int
-offline_find_elf (Dwfl_Module *mod, void **userdata, const char *modname,
- Dwarf_Addr base, char **file_name, Elf **elfp)
-{
- if (modname != NULL && (strcmp (modname, "[exe]") == 0
- || strcmp (modname, "[pie]") == 0)
- && mod->dwfl->executable_for_core)
- {
- /* When both --core and --executable are given in whatever order
- dwfl_core_file_report is called first and this callback will replace
- the Dwfl_Module main.name with the recorded --executable file when the
- modname is [exe] or [pie] (which then triggers opening and reporting
- of the executable). */
- char *e_dup = strdup (mod->dwfl->executable_for_core);
- if (e_dup)
- {
- free (*file_name);
- *file_name = e_dup;
- return -1;
- }
- }
- return INTUSE(dwfl_build_id_find_elf) (mod, userdata, modname, base,
- file_name, elfp);
-}
-
static char *debuginfo_path;
static const Dwfl_Callbacks offline_callbacks =
.section_address = INTUSE(dwfl_offline_section_address),
/* We use this table for core files too. */
- .find_elf = offline_find_elf,
+ .find_elf = INTUSE(dwfl_build_id_find_elf),
};
static const Dwfl_Callbacks proc_callbacks =
char **file_name, Elf **elfp)
{
*elfp = NULL;
+ if (modname != NULL && mod->dwfl->executable_for_core != NULL
+ && (strcmp (modname, "[exe]") == 0 || strcmp (modname, "[pie]") == 0))
+ {
+ /* When dwfl_core_file_report was called with a non-NULL executable file
+ name this callback will replace the Dwfl_Module main.name with the
+ recorded executable file when the modname is [exe] or [pie] (which
+ then triggers opening and reporting of the executable). */
+ int fd = open64 (mod->dwfl->executable_for_core, O_RDONLY);
+ if (fd >= 0)
+ {
+ *file_name = strdup (mod->dwfl->executable_for_core);
+ if (*file_name != NULL)
+ return fd;
+ else
+ close (fd);
+ }
+ }
int fd = __libdwfl_open_by_build_id (mod, false, file_name);
if (fd >= 0)
{