mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-profile: add instrument to bundle symbols
This instrument does as our previous symbols_source did and will augment the capture with additional symbols that improves the chances you'll get proper symbolization on machines that did not create the capture.
This commit is contained in:
@ -14,6 +14,7 @@ libsysprof_profile_public_sources = [
|
||||
'sysprof-recording.c',
|
||||
'sysprof-sampler.c',
|
||||
'sysprof-spawnable.c',
|
||||
'sysprof-symbols-bundle.c',
|
||||
'sysprof-system-logs.c',
|
||||
'sysprof-tracer.c',
|
||||
]
|
||||
@ -46,6 +47,7 @@ libsysprof_profile_public_headers = [
|
||||
'sysprof-recording.h',
|
||||
'sysprof-sampler.h',
|
||||
'sysprof-spawnable.h',
|
||||
'sysprof-symbols-bundle.h',
|
||||
'sysprof-system-logs.h',
|
||||
'sysprof-tracer.h',
|
||||
]
|
||||
@ -67,7 +69,7 @@ libsysprof_profile_deps = [
|
||||
libsystemd_dep,
|
||||
|
||||
liblinereader_static_dep,
|
||||
libsysprof_capture_dep,
|
||||
libsysprof_analyze_dep,
|
||||
]
|
||||
|
||||
libsysprof_profile_static = static_library(
|
||||
|
||||
@ -40,6 +40,7 @@ G_BEGIN_DECLS
|
||||
# include "sysprof-recording.h"
|
||||
# include "sysprof-sampler.h"
|
||||
# include "sysprof-spawnable.h"
|
||||
# include "sysprof-symbols-bundle.h"
|
||||
# include "sysprof-system-logs.h"
|
||||
# include "sysprof-tracer.h"
|
||||
#undef SYSPROF_PROFILE_INSIDE
|
||||
|
||||
131
src/libsysprof-profile/sysprof-symbols-bundle.c
Normal file
131
src/libsysprof-profile/sysprof-symbols-bundle.c
Normal file
@ -0,0 +1,131 @@
|
||||
/* sysprof-symbols-bundle.c
|
||||
*
|
||||
* Copyright 2023 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 <errno.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include <sysprof-analyze.h>
|
||||
|
||||
#include "sysprof-instrument-private.h"
|
||||
#include "sysprof-recording-private.h"
|
||||
#include "sysprof-symbols-bundle.h"
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCaptureReader, sysprof_capture_reader_unref)
|
||||
|
||||
static const DexAsyncPairInfo load_info =
|
||||
DEX_ASYNC_PAIR_INFO_OBJECT (sysprof_document_loader_load_async,
|
||||
sysprof_document_loader_load_finish);
|
||||
|
||||
struct _SysprofSymbolsBundle
|
||||
{
|
||||
SysprofInstrument parent_instance;
|
||||
};
|
||||
|
||||
struct _SysprofSymbolsBundleClass
|
||||
{
|
||||
SysprofInstrumentClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofSymbolsBundle, sysprof_symbols_bundle, SYSPROF_TYPE_INSTRUMENT)
|
||||
|
||||
static DexFuture *
|
||||
sysprof_symbols_bundle_augment_fiber (gpointer user_data)
|
||||
{
|
||||
const DexAsyncPairInfo serialize_info = DEX_ASYNC_PAIR_INFO_BOXED (
|
||||
sysprof_document_serialize_symbols_async,
|
||||
sysprof_document_serialize_symbols_finish,
|
||||
G_TYPE_BYTES);
|
||||
|
||||
g_autoptr(SysprofDocumentLoader) loader = NULL;
|
||||
g_autoptr(SysprofDocument) document = NULL;
|
||||
g_autoptr(GBytes) bytes = NULL;
|
||||
SysprofRecording *recording = user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autofd int fd = -1;
|
||||
|
||||
g_assert (SYSPROF_IS_RECORDING (recording));
|
||||
|
||||
if (-1 == (fd = sysprof_recording_dup_fd (recording)))
|
||||
return dex_future_new_for_errno (errno);
|
||||
g_assert (fd > -1);
|
||||
|
||||
if (!(loader = sysprof_document_loader_new_for_fd (fd, &error)))
|
||||
return dex_future_new_for_error (g_steal_pointer (&error));
|
||||
g_assert (SYSPROF_IS_DOCUMENT_LOADER (loader));
|
||||
|
||||
if (!(document = dex_await_object (dex_async_pair_new (loader, &load_info), &error)))
|
||||
return dex_future_new_for_error (g_steal_pointer (&error));
|
||||
g_assert (SYSPROF_IS_DOCUMENT (document));
|
||||
|
||||
if (!(bytes = dex_await_boxed (dex_async_pair_new (document, &serialize_info), &error)))
|
||||
return dex_future_new_for_error (g_steal_pointer (&error));
|
||||
|
||||
_sysprof_recording_add_file_data (recording,
|
||||
"__symbols__",
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
g_bytes_get_size (bytes));
|
||||
|
||||
return dex_future_new_for_boolean (TRUE);
|
||||
}
|
||||
|
||||
static DexFuture *
|
||||
sysprof_symbols_bundle_augment (SysprofInstrument *instrument,
|
||||
SysprofRecording *recording)
|
||||
{
|
||||
g_assert (SYSPROF_IS_SYMBOLS_BUNDLE (instrument));
|
||||
g_assert (SYSPROF_IS_RECORDING (recording));
|
||||
|
||||
return dex_scheduler_spawn (NULL, 0,
|
||||
sysprof_symbols_bundle_augment_fiber,
|
||||
g_object_ref (recording),
|
||||
g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_symbols_bundle_class_init (SysprofSymbolsBundleClass *klass)
|
||||
{
|
||||
SysprofInstrumentClass *instrument_class = SYSPROF_INSTRUMENT_CLASS (klass);
|
||||
|
||||
instrument_class->augment = sysprof_symbols_bundle_augment;
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_symbols_bundle_init (SysprofSymbolsBundle *self)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_symbols_bundle_new:
|
||||
* @self: a #SysprofSymbolsBundle
|
||||
*
|
||||
* Creates a new instrment that will decode symbols at the end of a recording
|
||||
* and attach them to the recording.
|
||||
*
|
||||
* Returns: (transfer full): a #SysprofSymbolsBundle
|
||||
*/
|
||||
SysprofInstrument *
|
||||
sysprof_symbols_bundle_new (void)
|
||||
{
|
||||
return g_object_new (SYSPROF_TYPE_SYMBOLS_BUNDLE, NULL);
|
||||
}
|
||||
42
src/libsysprof-profile/sysprof-symbols-bundle.h
Normal file
42
src/libsysprof-profile/sysprof-symbols-bundle.h
Normal file
@ -0,0 +1,42 @@
|
||||
/* sysprof-symbols-bundle.h
|
||||
*
|
||||
* Copyright 2023 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-instrument.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_SYMBOLS_BUNDLE (sysprof_symbols_bundle_get_type())
|
||||
#define SYSPROF_IS_SYMBOLS_BUNDLE(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_SYMBOLS_BUNDLE)
|
||||
#define SYSPROF_SYMBOLS_BUNDLE(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_SYMBOLS_BUNDLE, SysprofSymbolsBundle)
|
||||
#define SYSPROF_SYMBOLS_BUNDLE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_SYMBOLS_BUNDLE, SysprofSymbolsBundleClass)
|
||||
|
||||
typedef struct _SysprofSymbolsBundle SysprofSymbolsBundle;
|
||||
typedef struct _SysprofSymbolsBundleClass SysprofSymbolsBundleClass;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GType sysprof_symbols_bundle_get_type (void) G_GNUC_CONST;
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofInstrument *sysprof_symbols_bundle_new (void);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofSymbolsBundle, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
@ -519,6 +519,8 @@ main (int argc,
|
||||
"org.gnome.Shell",
|
||||
"/org/gnome/Sysprof3/Profiler"));
|
||||
|
||||
if (decode)
|
||||
sysprof_profiler_add_instrument (profiler, sysprof_symbols_bundle_new ());
|
||||
|
||||
/* If -- was ommitted or there are no commands, just profile the entire
|
||||
* system without spawning anything. Really only useful when testing the
|
||||
|
||||
@ -491,8 +491,7 @@ Examples:\n\
|
||||
sysprof_profiler_add_instrument (profiler, sysprof_disk_usage_new ());
|
||||
|
||||
if (!no_decode)
|
||||
g_warning ("Implement symbol augmentation");
|
||||
//sysprof_profiler_add_instrument (profiler, sysprof_symbol_augmentation_new ());
|
||||
sysprof_profiler_add_instrument (profiler, sysprof_symbols_bundle_new ());
|
||||
|
||||
if (!no_cpu)
|
||||
sysprof_profiler_add_instrument (profiler, sysprof_cpu_usage_new ());
|
||||
|
||||
Reference in New Issue
Block a user