mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-11 23:51:06 +00:00
tests: add util to extract build-id
Easier to remember than readelf stuff and tests the same code paths.
This commit is contained in:
@ -95,6 +95,11 @@ memory_stack_stash = executable('memory-stack-stash', 'memory-stack-stash.c',
|
|||||||
dependencies: test_deps,
|
dependencies: test_deps,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
read_build_id = executable('read-build-id', 'read-build-id.c',
|
||||||
|
c_args: test_cflags,
|
||||||
|
dependencies: test_deps,
|
||||||
|
)
|
||||||
|
|
||||||
show_page_usage = executable('show-page-usage', 'show-page-usage.c',
|
show_page_usage = executable('show-page-usage', 'show-page-usage.c',
|
||||||
c_args: test_cflags,
|
c_args: test_cflags,
|
||||||
dependencies: test_deps + [dependency('cairo')],
|
dependencies: test_deps + [dependency('cairo')],
|
||||||
|
|||||||
52
src/tests/read-build-id.c
Normal file
52
src/tests/read-build-id.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* read-build-id.c
|
||||||
|
*
|
||||||
|
* Copyright 2021 Christian Hergert <chergert@redhat.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "elfparser.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc,
|
||||||
|
char *argv[])
|
||||||
|
{
|
||||||
|
for (guint i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
const char *filename = argv[i];
|
||||||
|
ElfParser *parser = elf_parser_new (filename, &error);
|
||||||
|
const char *build_id;
|
||||||
|
|
||||||
|
if (parser == NULL)
|
||||||
|
{
|
||||||
|
if (error != NULL)
|
||||||
|
g_printerr ("%s: %s\n", filename, error->message);
|
||||||
|
else
|
||||||
|
g_printerr ("%s: Failed to load as ELF\n", filename);
|
||||||
|
g_clear_error (&error);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
build_id = elf_parser_get_build_id (parser);
|
||||||
|
g_print ("%s: %s\n", filename, build_id);
|
||||||
|
elf_parser_free (parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user