elf: add helpers for test utilities to verify decoding

This commit is contained in:
Christian Hergert
2021-09-21 11:50:03 -07:00
parent fb33d382cc
commit 4c6912e804
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,33 @@
/* sysprof-elf-symbol-resolver-private.h
*
* 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
*/
#pragma once
#include "sysprof-elf-symbol-resolver.h"
G_BEGIN_DECLS
char *_sysprof_elf_symbol_resolver_resolve_path (SysprofElfSymbolResolver *self,
GPid pid,
const char *path);
const char *_sysprof_elf_symbol_resolver_get_pid_kind (SysprofElfSymbolResolver *self,
GPid pid);
G_END_DECLS

View File

@ -606,3 +606,44 @@ sysprof_elf_symbol_resolver_add_debug_dir (SysprofElfSymbolResolver *self,
/* Do Nothing */
/* XXX: Mark as deprecated post 41 or remove with Gtk4 port */
}
char *
_sysprof_elf_symbol_resolver_resolve_path (SysprofElfSymbolResolver *self,
GPid pid,
const char *path)
{
ProcessInfo *pi;
g_return_val_if_fail (SYSPROF_IS_ELF_SYMBOL_RESOLVER (self), NULL);
if (!(pi = g_hash_table_lookup (self->processes, GINT_TO_POINTER (pid))))
return NULL;
if (pi->resolver == NULL)
return NULL;
return _sysprof_path_resolver_resolve (pi->resolver, path);
}
const char *
_sysprof_elf_symbol_resolver_get_pid_kind (SysprofElfSymbolResolver *self,
GPid pid)
{
ProcessInfo *pi;
g_return_val_if_fail (SYSPROF_IS_ELF_SYMBOL_RESOLVER (self), NULL);
if (!(pi = g_hash_table_lookup (self->processes, GINT_TO_POINTER (pid))))
return "unknown";
if (pi->kind == PROCESS_KIND_FLATPAK)
return "Flatpak";
if (pi->kind == PROCESS_KIND_PODMAN)
return "Podman";
if (pi->kind == PROCESS_KIND_STANDARD)
return "Standard";
return "unknown";
}