mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-analyze: load ElfParser for GMappedFile
This commit is contained in:
@ -299,7 +299,7 @@ sysprof_elf_loader_load (SysprofElfLoader *self,
|
|||||||
if (!(mapped_file = g_mapped_file_new (path, FALSE, NULL)))
|
if (!(mapped_file = g_mapped_file_new (path, FALSE, NULL)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!(elf = sysprof_elf_new (mapped_file, &local_error)))
|
if (!(elf = sysprof_elf_new (path, g_steal_pointer (&mapped_file), &local_error)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((debug_link = sysprof_elf_get_debug_link (elf)))
|
if ((debug_link = sysprof_elf_get_debug_link (elf)))
|
||||||
|
|||||||
@ -28,7 +28,8 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (SysprofElf, sysprof_elf, SYSPROF, ELF, GObject)
|
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);
|
GError **error);
|
||||||
const char *sysprof_elf_get_file (SysprofElf *self);
|
const char *sysprof_elf_get_file (SysprofElf *self);
|
||||||
const char *sysprof_elf_get_build_id (SysprofElf *self);
|
const char *sysprof_elf_get_build_id (SysprofElf *self);
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "../libsysprof/elfparser.h"
|
||||||
|
|
||||||
#include "sysprof-elf-private.h"
|
#include "sysprof-elf-private.h"
|
||||||
|
|
||||||
struct _SysprofElf
|
struct _SysprofElf
|
||||||
@ -29,6 +31,7 @@ struct _SysprofElf
|
|||||||
char *debug_link;
|
char *debug_link;
|
||||||
char *file;
|
char *file;
|
||||||
SysprofElf *debug_link_elf;
|
SysprofElf *debug_link_elf;
|
||||||
|
ElfParser *parser;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -52,6 +55,7 @@ sysprof_elf_finalize (GObject *object)
|
|||||||
g_clear_pointer (&self->build_id, g_free);
|
g_clear_pointer (&self->build_id, g_free);
|
||||||
g_clear_pointer (&self->debug_link, g_free);
|
g_clear_pointer (&self->debug_link, g_free);
|
||||||
g_clear_pointer (&self->file, 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_clear_object (&self->debug_link_elf);
|
||||||
|
|
||||||
G_OBJECT_CLASS (sysprof_elf_parent_class)->finalize (object);
|
G_OBJECT_CLASS (sysprof_elf_parent_class)->finalize (object);
|
||||||
@ -145,12 +149,23 @@ sysprof_elf_init (SysprofElf *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SysprofElf *
|
SysprofElf *
|
||||||
sysprof_elf_new (GMappedFile *mapped_file,
|
sysprof_elf_new (const char *filename,
|
||||||
|
GMappedFile *mapped_file,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
SysprofElf *self;
|
||||||
|
ElfParser *parser;
|
||||||
|
|
||||||
g_return_val_if_fail (mapped_file != NULL, NULL);
|
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 *
|
const char *
|
||||||
|
|||||||
Reference in New Issue
Block a user