mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
podman: add debug directories from podman containers
This is meant to allow us to find the debug files for a given library for podman containers running as the current user. However, we still need to try to translate the fuse-overlayfs paths when parsing the /proc/pid/mounts or we'll have incorrect paths coming from the event stream.
This commit is contained in:
@ -69,6 +69,7 @@ libsysprof_private_sources = [
|
||||
'sysprof-line-reader.c',
|
||||
'sysprof-map-lookaside.c',
|
||||
'sysprof-mountinfo.c',
|
||||
'sysprof-podman.c',
|
||||
'sysprof-polkit.c',
|
||||
'sysprof-symbol-map.c',
|
||||
ipc_service_src,
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#include "sysprof-elf-symbol-resolver.h"
|
||||
#include "sysprof-flatpak.h"
|
||||
#include "sysprof-map-lookaside.h"
|
||||
#include "sysprof-podman.h"
|
||||
|
||||
struct _SysprofElfSymbolResolver
|
||||
{
|
||||
@ -92,12 +93,20 @@ free_element_string (gpointer data)
|
||||
static void
|
||||
sysprof_elf_symbol_resolver_init (SysprofElfSymbolResolver *self)
|
||||
{
|
||||
g_auto(GStrv) podman_dirs = NULL;
|
||||
|
||||
self->debug_dirs = g_array_new (TRUE, FALSE, sizeof (gchar *));
|
||||
g_array_set_clear_func (self->debug_dirs, free_element_string);
|
||||
|
||||
sysprof_elf_symbol_resolver_add_debug_dir (self, "/usr/lib/debug");
|
||||
sysprof_elf_symbol_resolver_add_debug_dir (self, "/usr/lib32/debug");
|
||||
sysprof_elf_symbol_resolver_add_debug_dir (self, "/usr/lib64/debug");
|
||||
|
||||
/* The user may have podman/toolbox containers */
|
||||
podman_dirs = sysprof_podman_debug_dirs ();
|
||||
for (guint i = 0; podman_dirs[i]; i++)
|
||||
sysprof_elf_symbol_resolver_add_debug_dir (self, podman_dirs[i]);
|
||||
|
||||
if (is_flatpak ())
|
||||
{
|
||||
g_auto(GStrv) debug_dirs = sysprof_flatpak_debug_dirs ();
|
||||
|
||||
65
src/libsysprof/sysprof-podman.c
Normal file
65
src/libsysprof/sysprof-podman.c
Normal file
@ -0,0 +1,65 @@
|
||||
/* sysprof-podman.c
|
||||
*
|
||||
* Copyright 2019 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
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "sysprof-podman"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sysprof-podman.h"
|
||||
|
||||
void
|
||||
_sysprof_podman_debug_dirs (GPtrArray *dirs)
|
||||
{
|
||||
g_autofree gchar *base_path = NULL;
|
||||
g_autoptr(GDir) dir = NULL;
|
||||
const gchar *name;
|
||||
|
||||
g_assert (dirs != NULL);
|
||||
|
||||
base_path = g_build_filename (g_get_user_data_dir (),
|
||||
"containres",
|
||||
"storage",
|
||||
"overlay",
|
||||
NULL);
|
||||
|
||||
if (!(dir = g_dir_open (base_path, 0, NULL)))
|
||||
return;
|
||||
|
||||
while ((name = g_dir_read_name (dir)))
|
||||
{
|
||||
g_autofree gchar *debug_path = NULL;
|
||||
|
||||
debug_path = g_build_filename (base_path, name, "diff",
|
||||
"usr", "lib", "debug",
|
||||
NULL);
|
||||
|
||||
if (g_file_test (debug_path, G_FILE_TEST_IS_DIR))
|
||||
g_ptr_array_add (dirs, g_steal_pointer (&debug_path));
|
||||
}
|
||||
}
|
||||
|
||||
gchar **
|
||||
sysprof_podman_debug_dirs (void)
|
||||
{
|
||||
GPtrArray *dirs = g_ptr_array_new ();
|
||||
_sysprof_podman_debug_dirs (dirs);
|
||||
g_ptr_array_add (dirs, NULL);
|
||||
return (gchar **)g_ptr_array_free (dirs, FALSE);
|
||||
}
|
||||
29
src/libsysprof/sysprof-podman.h
Normal file
29
src/libsysprof/sysprof-podman.h
Normal file
@ -0,0 +1,29 @@
|
||||
/* sysprof-podman.h
|
||||
*
|
||||
* Copyright 2020 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 <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gchar **sysprof_podman_debug_dirs (void);
|
||||
|
||||
G_END_DECLS
|
||||
Reference in New Issue
Block a user