libsysprof-analyze: load ElfParser for GMappedFile

This commit is contained in:
Christian Hergert
2023-05-19 10:40:50 -07:00
parent 8e101624bc
commit aa829f8665
3 changed files with 20 additions and 4 deletions

View File

@ -299,7 +299,7 @@ sysprof_elf_loader_load (SysprofElfLoader *self,
if (!(mapped_file = g_mapped_file_new (path, FALSE, NULL)))
continue;
if (!(elf = sysprof_elf_new (mapped_file, &local_error)))
if (!(elf = sysprof_elf_new (path, g_steal_pointer (&mapped_file), &local_error)))
continue;
if ((debug_link = sysprof_elf_get_debug_link (elf)))

View File

@ -28,7 +28,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (SysprofElf, sysprof_elf, SYSPROF, ELF, GObject)
SysprofElf *sysprof_elf_new (GMappedFile *mapped_file,
SysprofElf *sysprof_elf_new (const char *filename,
GMappedFile *mapped_file,
GError **error);
const char *sysprof_elf_get_file (SysprofElf *self);
const char *sysprof_elf_get_build_id (SysprofElf *self);

View File

@ -20,6 +20,8 @@
#include "config.h"
#include "../libsysprof/elfparser.h"
#include "sysprof-elf-private.h"
struct _SysprofElf
@ -29,6 +31,7 @@ struct _SysprofElf
char *debug_link;
char *file;
SysprofElf *debug_link_elf;
ElfParser *parser;
};
enum {
@ -52,6 +55,7 @@ sysprof_elf_finalize (GObject *object)
g_clear_pointer (&self->build_id, g_free);
g_clear_pointer (&self->debug_link, g_free);
g_clear_pointer (&self->file, g_free);
g_clear_pointer (&self->parser, elf_parser_free);
g_clear_object (&self->debug_link_elf);
G_OBJECT_CLASS (sysprof_elf_parent_class)->finalize (object);
@ -145,12 +149,23 @@ sysprof_elf_init (SysprofElf *self)
}
SysprofElf *
sysprof_elf_new (GMappedFile *mapped_file,
sysprof_elf_new (const char *filename,
GMappedFile *mapped_file,
GError **error)
{
SysprofElf *self;
ElfParser *parser;
g_return_val_if_fail (mapped_file != NULL, NULL);
return NULL;
if (!(parser = elf_parser_new_from_mmap (g_steal_pointer (&mapped_file), error)))
return NULL;
self = g_object_new (SYSPROF_TYPE_ELF, NULL);
self->file = g_strdup (filename);
self->parser = g_steal_pointer (&parser);
return self;
}
const char *