On Wed, 18 Dec 2013 14:43:18 +0100, Mark Wielaard wrote:
> This should now mention "When dwfl_core_file_report was called with a
> non-NULL executable file name..." instead of the argp argument switches.
Done.
Checked in.
Thanks,
Jan
--- Begin Message ---
Signed-off-by: Jan Kratochvil <[email protected]>
---
libdwfl/ChangeLog | 7 +++++++
libdwfl/argp-std.c | 28 +---------------------------
libdwfl/dwfl_build_id_find_elf.c | 17 +++++++++++++++++
3 files changed, 25 insertions(+), 27 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index e719df9..b3c2b83 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,12 @@
2013-12-18 Jan Kratochvil <[email protected]>
+ * 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 <[email protected]>
+
unwinder: s390 and s390x
* dwfl_frame_pc.c (dwfl_frame_pc): Call ebl_normalize_pc.
* frame_unwind.c (new_unwound): New function from ...
diff --git a/libdwfl/argp-std.c b/libdwfl/argp-std.c
index 322cdf4..cf178ee 100644
--- a/libdwfl/argp-std.c
+++ b/libdwfl/argp-std.c
@@ -60,32 +60,6 @@ static const struct argp_option options[] =
{ 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 =
@@ -96,7 +70,7 @@ 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 =
diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
index 9272c1f..a4f0326 100644
--- a/libdwfl/dwfl_build_id_find_elf.c
+++ b/libdwfl/dwfl_build_id_find_elf.c
@@ -116,6 +116,23 @@ dwfl_build_id_find_elf (Dwfl_Module *mod,
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)
{
--
1.8.3.1
--- End Message ---