[sysprof] utils: add symbol range support for binfile and elfparser
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] utils: add symbol range support for binfile and elfparser
- Date: Wed, 29 May 2019 22:48:51 +0000 (UTC)
commit e39feeeeb05368f7407651ed1a45fb5695dc5dcd
Author: Christian Hergert <chergert redhat com>
Date: Tue May 28 12:13:49 2019 -0700
utils: add symbol range support for binfile and elfparser
src/libsysprof/binfile.c | 23 ++++++++++++++++++++++-
src/libsysprof/binfile.h | 24 ++++++++++++++----------
src/libsysprof/elfparser.c | 12 +++++++++++-
src/libsysprof/elfparser.h | 24 ++++++++++++++----------
4 files changed, 61 insertions(+), 22 deletions(-)
---
diff --git a/src/libsysprof/binfile.c b/src/libsysprof/binfile.c
index 8a427a2..80fd4fa 100644
--- a/src/libsysprof/binfile.c
+++ b/src/libsysprof/binfile.c
@@ -519,7 +519,7 @@ bin_symbol_get_name (bin_file_t *file,
}
gulong
-bin_symbol_get_address (bin_file_t *file,
+bin_symbol_get_address (bin_file_t *file,
const bin_symbol_t *symbol)
{
if (file->undefined_name == (char *)symbol)
@@ -536,3 +536,24 @@ bin_symbol_get_address (bin_file_t *file,
return elf_parser_get_sym_address (elf, sym);
}
}
+
+void
+bin_symbol_get_address_range (bin_file_t *file,
+ const bin_symbol_t *symbol,
+ gulong *begin,
+ gulong *end)
+{
+ if (file->undefined_name == (char *)symbol)
+ {
+ *begin = 0;
+ *end = 0;
+ }
+ else
+ {
+ ElfParser *elf;
+ const ElfSym *sym;
+
+ sym = get_elf_sym (file, symbol, &elf);
+ elf_parser_get_sym_address_range (elf, sym, begin, end);
+ }
+}
diff --git a/src/libsysprof/binfile.h b/src/libsysprof/binfile.h
index 3776958..f02868c 100644
--- a/src/libsysprof/binfile.h
+++ b/src/libsysprof/binfile.h
@@ -32,15 +32,19 @@ typedef struct bin_symbol_t bin_symbol_t;
/* Binary File */
-bin_file_t *bin_file_new (const char *filename);
-void bin_file_free (bin_file_t *bin_file);
-const bin_symbol_t *bin_file_lookup_symbol (bin_file_t *bin_file,
- gulong address);
-gboolean bin_file_check_inode (bin_file_t *bin_file,
- ino_t inode);
-const char *bin_symbol_get_name (bin_file_t *bin_file,
- const bin_symbol_t *symbol);
-gulong bin_symbol_get_address (bin_file_t *bin_file,
- const bin_symbol_t *symbol);
+bin_file_t *bin_file_new (const char *filename);
+void bin_file_free (bin_file_t *bin_file);
+const bin_symbol_t *bin_file_lookup_symbol (bin_file_t *bin_file,
+ gulong address);
+gboolean bin_file_check_inode (bin_file_t *bin_file,
+ ino_t inode);
+const char *bin_symbol_get_name (bin_file_t *bin_file,
+ const bin_symbol_t *symbol);
+gulong bin_symbol_get_address (bin_file_t *bin_file,
+ const bin_symbol_t *symbol);
+void bin_symbol_get_address_range (bin_file_t *bin_file,
+ const bin_symbol_t *symbol,
+ gulong *begin,
+ gulong *end);
#endif
diff --git a/src/libsysprof/elfparser.c b/src/libsysprof/elfparser.c
index 59b7815..376a1f0 100644
--- a/src/libsysprof/elfparser.c
+++ b/src/libsysprof/elfparser.c
@@ -805,12 +805,22 @@ elf_parser_owns_symbol (ElfParser *parser,
}
gulong
-elf_parser_get_sym_address (ElfParser *parser,
+elf_parser_get_sym_address (ElfParser *parser,
const ElfSym *sym)
{
return sym->address - parser->text_section->load_address;
}
+void
+elf_parser_get_sym_address_range (ElfParser *parser,
+ const ElfSym *sym,
+ gulong *begin,
+ gulong *end)
+{
+ *begin = sym->address - parser->text_section->load_address;
+ *end = *begin + st_size (parser, sym->table, sym->offset);
+}
+
/*
* Utility functions
*/
diff --git a/src/libsysprof/elfparser.h b/src/libsysprof/elfparser.h
index b22cc38..160e4c9 100644
--- a/src/libsysprof/elfparser.h
+++ b/src/libsysprof/elfparser.h
@@ -45,14 +45,18 @@ gulong elf_parser_get_text_offset (ElfParser *parser);
* of the file would have been mapped, so a - (m - o) is the position
* in the file of a.
*/
-const ElfSym *elf_parser_lookup_symbol (ElfParser *parser,
- gulong address);
-guint32 elf_parser_get_crc32 (ElfParser *parser);
-const char *elf_parser_get_sym_name (ElfParser *parser,
- const ElfSym *sym);
-gulong elf_parser_get_sym_address (ElfParser *parser,
- const ElfSym *sym);
-gboolean elf_parser_owns_symbol (ElfParser *parser,
- const ElfSym *sym);
-char *elf_demangle (const char *name);
+const ElfSym *elf_parser_lookup_symbol (ElfParser *parser,
+ gulong address);
+guint32 elf_parser_get_crc32 (ElfParser *parser);
+const char *elf_parser_get_sym_name (ElfParser *parser,
+ const ElfSym *sym);
+gulong elf_parser_get_sym_address (ElfParser *parser,
+ const ElfSym *sym);
+gboolean elf_parser_owns_symbol (ElfParser *parser,
+ const ElfSym *sym);
+char *elf_demangle (const char *name);
+void elf_parser_get_sym_address_range (ElfParser *parser,
+ const ElfSym *sym,
+ gulong *begin,
+ gulong *end);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]