mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 15:10:53 +00:00
Add test for debug link parsing
Signed-off-by: Pauli Nieminen <suokkos@gmail.com>
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
6a5dfd385c
commit
3c11010659
34
testelf.c
34
testelf.c
@ -1,5 +1,6 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "elfparser.h"
|
#include "elfparser.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
const char *n;
|
const char *n;
|
||||||
|
|
||||||
@ -34,8 +35,10 @@ int
|
|||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
ElfParser *elf;
|
ElfParser *elf;
|
||||||
|
ElfParser *debug = NULL;
|
||||||
const char *build_id;
|
const char *build_id;
|
||||||
const char *filename;
|
const char *filename;
|
||||||
|
const char *dir;
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
filename = "/usr/lib/libgtk-x11-2.0.so";
|
filename = "/usr/lib/libgtk-x11-2.0.so";
|
||||||
@ -50,11 +53,38 @@ main (int argc, char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dir = g_path_get_dirname (filename);
|
||||||
|
|
||||||
build_id = elf_parser_get_build_id (elf);
|
build_id = elf_parser_get_build_id (elf);
|
||||||
|
|
||||||
g_print ("build ID: %s\n", build_id);
|
guint crc = elf_parser_get_crc32 (elf);
|
||||||
|
|
||||||
elf_parser_get_crc32 (elf);
|
g_print ("build ID: %s crc: %x\n", build_id, crc);
|
||||||
|
filename = elf_parser_get_debug_link(elf, &crc);
|
||||||
|
if (filename)
|
||||||
|
{
|
||||||
|
filename = g_build_filename ("/usr", "lib", "debug", dir, filename, NULL);
|
||||||
|
g_print ("Debug link: %s crc: %x\n", filename, crc);
|
||||||
|
debug = elf_parser_new (filename, NULL);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
const char *build = elf_parser_get_build_id (debug);
|
||||||
|
guint crc_debug = elf_parser_get_crc32 (debug);
|
||||||
|
g_print ("Debug link build ID: %s crc: %x\n", build, crc_debug);
|
||||||
|
if (strcmp(build, build_id) != 0 || crc_debug != crc)
|
||||||
|
g_print ("Build ID or crc not matching!\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_print ("Separate debug symbol file not found\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_print ("No debug link\n");
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
for (i = 0; i < 5000000; ++i)
|
for (i = 0; i < 5000000; ++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user