mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof: add versioning macros
This also moves stackstash.[ch] into a location that can be embedded by both the libsysprof and libsysprof-ui code. We pass native pointers to the structure as a gpointer in the public API to allow for this. The performance of that code is incredibly sensitive to the interactivity of Sysprof.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
/* demangle.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -16,8 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DEMANGLE_H
|
||||
#define DEMANGLE_H
|
||||
#pragma once
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@ -26,5 +25,3 @@ G_BEGIN_DECLS
|
||||
gchar *sysprof_cplus_demangle (const gchar *name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* DEMANGLE_H */
|
||||
|
||||
@ -54,4 +54,3 @@ gulong elf_parser_get_sym_address (ElfParser *parser,
|
||||
gboolean elf_parser_owns_symbol (ElfParser *parser,
|
||||
const ElfSym *sym);
|
||||
char * elf_demangle (const char *name);
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@ libsysprof_public_sources = [
|
||||
|
||||
libsysprof_public_headers = [
|
||||
'sp-callgraph-profile.h',
|
||||
'sp-callgraph-profile-private.h',
|
||||
'sp-capture-gobject.h',
|
||||
'sp-elf-symbol-resolver.h',
|
||||
'sp-hostinfo-source.h',
|
||||
@ -45,10 +44,10 @@ libsysprof_public_headers = [
|
||||
]
|
||||
|
||||
libsysprof_private_sources = [
|
||||
'../stackstash.c',
|
||||
'binfile.c',
|
||||
'demangle.cpp',
|
||||
'elfparser.c',
|
||||
'stackstash.c',
|
||||
'sp-source-util.c',
|
||||
'sp-line-reader.c',
|
||||
]
|
||||
@ -90,12 +89,15 @@ if get_option('with_sysprofd') != 'none'
|
||||
libsysprof_deps += dependency('polkit-gobject-1')
|
||||
endif
|
||||
|
||||
libsysprof = shared_library('sysprof-@0@'.format(libsysprof_api_version),
|
||||
libsysprof = shared_library(
|
||||
'sysprof-@0@'.format(libsysprof_api_version),
|
||||
libsysprof_public_sources + libsysprof_private_sources,
|
||||
dependencies: libsysprof_deps,
|
||||
c_args: libsysprof_c_args,
|
||||
install: true,
|
||||
install_dir: get_option('libdir'),
|
||||
|
||||
dependencies: libsysprof_deps,
|
||||
c_args: libsysprof_c_args,
|
||||
install: true,
|
||||
install_dir: get_option('libdir'),
|
||||
gnu_symbol_visibility: 'hidden',
|
||||
)
|
||||
|
||||
libsysprof_dep = declare_dependency(
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
/* sp-callgraph-profile-private.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef SP_CALLGRAPH_PROFILE_PRIVATE_H
|
||||
#define SP_CALLGRAPH_PROFILE_PRIVATE_H
|
||||
|
||||
#include "sp-callgraph-profile.h"
|
||||
#include "stackstash.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
StackStash *sp_callgraph_profile_get_stash (SpCallgraphProfile *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_CALLGRAPH_PROFILE_PRIVATE_H */
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-callgraph-profile.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,6 +14,8 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* Sysprof -- Sampling, systemwide CPU profiler
|
||||
@ -34,20 +36,22 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <string.h>
|
||||
#include <sysprof-capture.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../stackstash.h"
|
||||
|
||||
#include "sp-callgraph-profile.h"
|
||||
#include "sp-callgraph-profile-private.h"
|
||||
#include "sp-capture-reader.h"
|
||||
#include "sp-elf-symbol-resolver.h"
|
||||
#include "sp-jitmap-symbol-resolver.h"
|
||||
#include "sp-map-lookaside.h"
|
||||
#include "sp-kernel-symbol-resolver.h"
|
||||
#include "sp-map-lookaside.h"
|
||||
#include "sp-selection.h"
|
||||
#include "stackstash.h"
|
||||
|
||||
#define CHECK_CANCELLABLE_INTERVAL 100
|
||||
|
||||
@ -499,7 +503,7 @@ profile_iface_init (SpProfileInterface *iface)
|
||||
iface->set_reader = sp_callgraph_profile_set_reader;
|
||||
}
|
||||
|
||||
StackStash *
|
||||
gpointer
|
||||
sp_callgraph_profile_get_stash (SpCallgraphProfile *self)
|
||||
{
|
||||
g_return_val_if_fail (SP_IS_CALLGRAPH_PROFILE (self), NULL);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-callgraph-profile.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,10 +14,13 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_CALLGRAPH_PROFILE_H
|
||||
#define SP_CALLGRAPH_PROFILE_H
|
||||
#pragma once
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-profile.h"
|
||||
#include "sp-selection.h"
|
||||
@ -26,13 +29,17 @@ G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_CALLGRAPH_PROFILE (sp_callgraph_profile_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpCallgraphProfile, sp_callgraph_profile, SP, CALLGRAPH_PROFILE, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpProfile *sp_callgraph_profile_new (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpProfile *sp_callgraph_profile_new_with_selection (SpSelection *selection);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gpointer sp_callgraph_profile_get_stash (SpCallgraphProfile *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GQuark sp_callgraph_profile_get_tag (SpCallgraphProfile *self,
|
||||
const gchar *symbol);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_CALLGRAPH_PROFILE_H */
|
||||
|
||||
@ -18,8 +18,12 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-capture-gobject.h"
|
||||
|
||||
#include <sysprof-capture.h>
|
||||
|
||||
G_DEFINE_BOXED_TYPE (SpCaptureReader, sp_capture_reader, (GBoxedCopyFunc)sp_capture_reader_ref, (GBoxedFreeFunc)sp_capture_reader_unref)
|
||||
G_DEFINE_BOXED_TYPE (SpCaptureWriter, sp_capture_writer, (GBoxedCopyFunc)sp_capture_writer_ref, (GBoxedFreeFunc)sp_capture_writer_unref)
|
||||
G_DEFINE_BOXED_TYPE (SpCaptureCursor, sp_capture_cursor, (GBoxedCopyFunc)sp_capture_cursor_ref, (GBoxedFreeFunc)sp_capture_cursor_unref)
|
||||
|
||||
@ -21,7 +21,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <sysprof-capture.h>
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -29,8 +30,11 @@ G_BEGIN_DECLS
|
||||
#define SP_TYPE_CAPTURE_WRITER (sp_capture_writer_get_type())
|
||||
#define SP_TYPE_CAPTURE_CURSOR (sp_capture_cursor_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GType sp_capture_reader_get_type (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GType sp_capture_writer_get_type (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GType sp_capture_cursor_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-elf-symbol-resolver.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,13 +14,17 @@
|
||||
*
|
||||
* 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 <string.h>
|
||||
|
||||
#include "sp-elf-symbol-resolver.h"
|
||||
#include "binfile.h"
|
||||
#include "elfparser.h"
|
||||
#include "sp-elf-symbol-resolver.h"
|
||||
#include "sp-map-lookaside.h"
|
||||
|
||||
struct _SpElfSymbolResolver
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-elf-symbol-resolver.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,13 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_ELF_SYMBOL_RESOLVER_H
|
||||
#define SP_ELF_SYMBOL_RESOLVER_H
|
||||
#pragma once
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-symbol-resolver.h"
|
||||
|
||||
@ -25,10 +28,10 @@ G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_ELF_SYMBOL_RESOLVER (sp_elf_symbol_resolver_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpElfSymbolResolver, sp_elf_symbol_resolver, SP, ELF_SYMBOL_RESOLVER, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpSymbolResolver *sp_elf_symbol_resolver_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_ELF_SYMBOL_RESOLVER_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-gjs-source.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-gjs-source.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,11 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_GJS_SOURCE_H
|
||||
#define SP_GJS_SOURCE_H
|
||||
#pragma once
|
||||
|
||||
#include "sp-source.h"
|
||||
|
||||
@ -30,5 +31,3 @@ G_DECLARE_FINAL_TYPE (SpGjsSource, sp_gjs_source, SP, GJS_SOURCE, GObject)
|
||||
SpSource *sp_gjs_source_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_GJS_SOURCE_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-hostinfo-source.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-hostinfo-source.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,10 +14,13 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_HOSTINFO_SOURCE_H
|
||||
#define SP_HOSTINFO_SOURCE_H
|
||||
#pragma once
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-source.h"
|
||||
|
||||
@ -25,11 +28,10 @@ G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_HOSTINFO_SOURCE (sp_hostinfo_source_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpHostinfoSource, sp_hostinfo_source, SP, HOSTINFO_SOURCE, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpSource *sp_hostinfo_source_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_HOSTINFO_SOURCE_H */
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-jitmap-symbol-resolver.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 "sp-kernel-symbol.h"
|
||||
#include "sp-jitmap-symbol-resolver.h"
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-jitmap-symbol-resolver.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,11 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_JITMAP_SYMBOL_RESOLVER_H
|
||||
#define SP_JITMAP_SYMBOL_RESOLVER_H
|
||||
#pragma once
|
||||
|
||||
#include "sp-symbol-resolver.h"
|
||||
|
||||
@ -30,5 +31,3 @@ G_DECLARE_FINAL_TYPE (SpJitmapSymbolResolver, sp_jitmap_symbol_resolver, SP, JIT
|
||||
SpSymbolResolver *sp_jitmap_symbol_resolver_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_JITMAP_SYMBOL_RESOLVER_H */
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
|
||||
#define G_LOG_DOMAIN "sp-kallsyms"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-kernel-symbol-resolver.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 "sp-kernel-symbol.h"
|
||||
#include "sp-kernel-symbol-resolver.h"
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-kernel-symbol-resolver.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,11 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_KERNEL_SYMBOL_RESOLVER_H
|
||||
#define SP_KERNEL_SYMBOL_RESOLVER_H
|
||||
#pragma once
|
||||
|
||||
#include "sp-symbol-resolver.h"
|
||||
|
||||
@ -30,5 +31,3 @@ G_DECLARE_FINAL_TYPE (SpKernelSymbolResolver, sp_kernel_symbol_resolver, SP, KER
|
||||
SpSymbolResolver *sp_kernel_symbol_resolver_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_KERNEL_SYMBOL_RESOLVER_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-kernel-symbol.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,6 +14,8 @@
|
||||
*
|
||||
* 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 "sp-kernel-symbol"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-kernel-symbol.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,11 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_KERNEL_SYMBOL_H
|
||||
#define SP_KERNEL_SYMBOL_H
|
||||
#pragma once
|
||||
|
||||
#include "sp-capture-types.h"
|
||||
|
||||
@ -32,5 +33,3 @@ typedef struct
|
||||
const SpKernelSymbol *sp_kernel_symbol_from_address (SpCaptureAddress address);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_KERNEL_SYMBOL_H */
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "sp-line-reader.h"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-local-profiler.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-local-profiler.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,17 +14,21 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_LOCAL_PROFILER_H
|
||||
#define SP_LOCAL_PROFILER_H
|
||||
#pragma once
|
||||
|
||||
#include "sp-profiler.h"
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_LOCAL_PROFILER (sp_local_profiler_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_DERIVABLE_TYPE (SpLocalProfiler, sp_local_profiler, SP, LOCAL_PROFILER, GObject)
|
||||
|
||||
struct _SpLocalProfilerClass
|
||||
@ -33,8 +37,7 @@ struct _SpLocalProfilerClass
|
||||
gpointer padding[8];
|
||||
};
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpProfiler *sp_local_profiler_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_LOCAL_PROFILER_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-map-lookaside.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 "sp-map-lookaside.h"
|
||||
|
||||
struct _SpMapLookaside
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-map-lookaside.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,11 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_MAP_LOOKASIDE_H
|
||||
#define SP_MAP_LOOKASIDE_H
|
||||
#pragma once
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@ -46,5 +47,3 @@ void sp_map_lookaside_free (SpMapLookaside *self);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpMapLookaside, sp_map_lookaside_free)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_MAP_LOOKASIDE_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-memory-source.c
|
||||
*
|
||||
* Copyright 2018 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2018-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
|
||||
@ -18,10 +18,10 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define G_LOG_DOMAIN "sp-memory-source"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-memory-source.h
|
||||
*
|
||||
* Copyright 2018 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2018-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
|
||||
@ -20,14 +20,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-source.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_MEMORY_SOURCE (sp_memory_source_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpMemorySource, sp_memory_source, SP, MEMORY_SOURCE, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpSource *sp_memory_source_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-perf-counter.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,6 +14,8 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* Sysprof -- Sampling, systemwide CPU profiler
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-perf-counter.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,11 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_PERF_COUNTER_H
|
||||
#define SP_PERF_COUNTER_H
|
||||
#pragma once
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <linux/perf_event.h>
|
||||
@ -150,5 +151,3 @@ SpPerfCounter *sp_perf_counter_ref (SpPerfCounter *self);
|
||||
void sp_perf_counter_unref (SpPerfCounter *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_PERF_COUNTER_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-perf-source.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,6 +14,8 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* Sysprof -- Sampling, systemwide CPU profiler
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-perf-source.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,13 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_PERF_SOURCE_H
|
||||
#define SP_PERF_SOURCE_H
|
||||
#pragma once
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-source.h"
|
||||
|
||||
@ -25,12 +28,13 @@ G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PERF_SOURCE (sp_perf_source_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpPerfSource, sp_perf_source, SP, PERF_SOURCE, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpSource *sp_perf_source_new (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_perf_source_set_target_pid (SpPerfSource *self,
|
||||
GPid pid);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_PERF_SOURCE_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-proc-source.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,6 +14,8 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* Sysprof -- Sampling, systemwide CPU profiler
|
||||
@ -35,6 +37,8 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-proc-source.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,13 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_PROC_SOURCE_H
|
||||
#define SP_PROC_SOURCE_H
|
||||
#pragma once
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-source.h"
|
||||
|
||||
@ -25,12 +28,13 @@ G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PROC_SOURCE (sp_proc_source_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpProcSource, sp_proc_source, SP, PROC_SOURCE, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpSource *sp_proc_source_new (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gchar *sp_proc_source_get_command_line (GPid pid,
|
||||
gboolean *is_kernel);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_PROC_SOURCE_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-process-model-item.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 <string.h>
|
||||
|
||||
#include "sp-process-model-item.h"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-process-model-item.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,10 +14,13 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_PROCESS_MODEL_ITEM_H
|
||||
#define SP_PROCESS_MODEL_ITEM_H
|
||||
#pragma once
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
@ -25,17 +28,23 @@ G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PROCESS_MODEL_ITEM (sp_process_model_item_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpProcessModelItem, sp_process_model_item, SP, PROCESS_MODEL_ITEM, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpProcessModelItem *sp_process_model_item_new (GPid pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
guint sp_process_model_item_hash (SpProcessModelItem *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_process_model_item_equal (SpProcessModelItem *self,
|
||||
SpProcessModelItem *other);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GPid sp_process_model_item_get_pid (SpProcessModelItem *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sp_process_model_item_get_command_line (SpProcessModelItem *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_process_model_item_is_kernel (SpProcessModelItem *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar * const *sp_process_model_item_get_argv (SpProcessModelItem *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_PROCESS_MODEL_ITEM_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-process-model.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#include "sp-process-model.h"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-process-model.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,23 +14,28 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_PROCESS_MODEL_H
|
||||
#define SP_PROCESS_MODEL_H
|
||||
#pragma once
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PROCESS_MODEL (sp_process_model_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpProcessModel, sp_process_model, SP, PROCESS_MODEL, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpProcessModel *sp_process_model_new (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_process_model_reload (SpProcessModel *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_process_model_queue_reload (SpProcessModel *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_PROCESS_MODEL_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-profile.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 "sp-profile.h"
|
||||
|
||||
G_DEFINE_INTERFACE (SpProfile, sp_profile, G_TYPE_OBJECT)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-profile.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
@ -14,19 +14,23 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_PROFILE_H
|
||||
#define SP_PROFILE_H
|
||||
#pragma once
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-capture-reader.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PROFILE (sp_profile_get_type ())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_INTERFACE (SpProfile, sp_profile, SP, PROFILE, GObject)
|
||||
|
||||
struct _SpProfileInterface
|
||||
@ -44,16 +48,17 @@ struct _SpProfileInterface
|
||||
GError **error);
|
||||
};
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profile_set_reader (SpProfile *self,
|
||||
SpCaptureReader *reader);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profile_generate (SpProfile *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_profile_generate_finish (SpProfile *self,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_PROFILE_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-profiler.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,8 +14,14 @@
|
||||
*
|
||||
* 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 "sp-profiler"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-profiler.h"
|
||||
|
||||
G_DEFINE_INTERFACE (SpProfiler, sp_profiler, G_TYPE_OBJECT)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-profiler.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,13 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_PROFILER_H
|
||||
#define SP_PROFILER_H
|
||||
#pragma once
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
#include "sp-capture-writer.h"
|
||||
#include "sp-source.h"
|
||||
@ -26,6 +29,7 @@ G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_PROFILER (sp_profiler_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_INTERFACE (SpProfiler, sp_profiler, SP, PROFILER, GObject)
|
||||
|
||||
struct _SpProfilerInterface
|
||||
@ -123,39 +127,58 @@ struct _SpProfilerInterface
|
||||
guint *n_pids);
|
||||
};
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_emit_failed (SpProfiler *self,
|
||||
const GError *error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_emit_stopped (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gdouble sp_profiler_get_elapsed (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_profiler_get_is_mutable (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_profiler_get_spawn_inherit_environ (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_set_spawn_inherit_environ (SpProfiler *self,
|
||||
gboolean spawn_inherit_environ);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_profiler_get_whole_system (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_set_whole_system (SpProfiler *self,
|
||||
gboolean whole_system);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_profiler_get_spawn (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_set_spawn (SpProfiler *self,
|
||||
gboolean spawn);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_set_spawn_argv (SpProfiler *self,
|
||||
const gchar * const *spawn_argv);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_set_spawn_env (SpProfiler *self,
|
||||
const gchar * const *spawn_env);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_add_source (SpProfiler *self,
|
||||
SpSource *source);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_set_writer (SpProfiler *self,
|
||||
SpCaptureWriter *writer);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpCaptureWriter *sp_profiler_get_writer (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_profiler_get_is_running (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_start (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_stop (SpProfiler *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_add_pid (SpProfiler *self,
|
||||
GPid pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_profiler_remove_pid (SpProfiler *self,
|
||||
GPid pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const GPid *sp_profiler_get_pids (SpProfiler *self,
|
||||
guint *n_pids);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_PROFILER_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-selection.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,14 @@
|
||||
*
|
||||
* 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 "sp-selection"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "sp-selection.h"
|
||||
|
||||
struct _SpSelection
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-selection.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,17 +14,21 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_SELECTION_H
|
||||
#define SP_SELECTION_H
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "sysprof-version-macros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SP_TYPE_SELECTION (sp_selection_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SpSelection, sp_selection, SP, SELECTION, GObject)
|
||||
|
||||
typedef void (*SpSelectionForeachFunc) (SpSelection *self,
|
||||
@ -32,21 +36,26 @@ typedef void (*SpSelectionForeachFunc) (SpSelection *self,
|
||||
gint64 end_time,
|
||||
gpointer user_data);
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_selection_get_has_selection (SpSelection *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sp_selection_contains (SpSelection *self,
|
||||
gint64 time_at);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_selection_select_range (SpSelection *self,
|
||||
gint64 begin_time,
|
||||
gint64 end_time);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_selection_unselect_range (SpSelection *self,
|
||||
gint64 begin,
|
||||
gint64 end);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_selection_unselect_all (SpSelection *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sp_selection_foreach (SpSelection *self,
|
||||
SpSelectionForeachFunc foreach_func,
|
||||
gpointer user_data);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SpSelection *sp_selection_copy (const SpSelection *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_SELECTION_H */
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-source.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 "sp-source.h"
|
||||
|
||||
G_DEFINE_INTERFACE (SpSource, sp_source, G_TYPE_OBJECT)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-source.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,11 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_SOURCE_H
|
||||
#define SP_SOURCE_H
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
@ -129,5 +130,3 @@ void sp_source_start (SpSource *self);
|
||||
void sp_source_stop (SpSource *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_SOURCE_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-symbol-dirs.c
|
||||
*
|
||||
* Copyright 2017 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2017-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
|
||||
@ -14,6 +14,8 @@
|
||||
*
|
||||
* 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"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-symbol-dirs.h
|
||||
*
|
||||
* Copyright 2017 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2017-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
|
||||
@ -14,10 +14,11 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_SYMBOL_DIRS_H
|
||||
#define SP_SYMBOL_DIRS_H
|
||||
#pragma once
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@ -29,5 +30,3 @@ gchar **sp_symbol_dirs_get_paths (const gchar *dir,
|
||||
const gchar *name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_SYMBOL_DIRS_H */
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-symbol-resolver.c
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,8 +14,12 @@
|
||||
*
|
||||
* 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 "sp-symbol-resolver.h"
|
||||
|
||||
G_DEFINE_INTERFACE (SpSymbolResolver, sp_symbol_resolver, G_TYPE_OBJECT)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* sp-symbol-resolver.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <chergert@redhat.com>
|
||||
* Copyright 2016-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
|
||||
@ -14,10 +14,11 @@
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef SP_SYMBOL_RESOLVER_H
|
||||
#define SP_SYMBOL_RESOLVER_H
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
@ -64,5 +65,3 @@ gchar *sp_symbol_resolver_resolve_with_context (SpSymbolResolver *self,
|
||||
GQuark *tag);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* SP_SYMBOL_RESOLVER_H */
|
||||
|
||||
@ -1,387 +0,0 @@
|
||||
/* Sysprof -- Sampling, systemwide CPU profiler
|
||||
* Copyright 2004, Red Hat, Inc.
|
||||
* Copyright 2004, 2005, Soeren Sandmann
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "stackstash.h"
|
||||
|
||||
struct StackStash
|
||||
{
|
||||
int ref_count;
|
||||
StackNode * root;
|
||||
GHashTable * nodes_by_data;
|
||||
GDestroyNotify destroy;
|
||||
|
||||
StackNode * cached_nodes;
|
||||
GPtrArray * blocks;
|
||||
};
|
||||
|
||||
static void
|
||||
decorate_node (StackNode *node,
|
||||
StackStash *stash)
|
||||
{
|
||||
StackNode *n;
|
||||
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
decorate_node (node->siblings, stash);
|
||||
decorate_node (node->children, stash);
|
||||
|
||||
node->next = g_hash_table_lookup (stash->nodes_by_data, &node->data);
|
||||
g_hash_table_insert (stash->nodes_by_data, &node->data, node);
|
||||
|
||||
/* FIXME: This could be done more efficiently
|
||||
* by keeping track of the ancestors we have seen.
|
||||
*/
|
||||
node->toplevel = TRUE;
|
||||
for (n = node->parent; n != NULL; n = n->parent)
|
||||
{
|
||||
if (n->data == node->data)
|
||||
{
|
||||
node->toplevel = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
address_hash (gconstpointer key)
|
||||
{
|
||||
const uint64_t *addr = key;
|
||||
|
||||
return *addr;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
address_equal (gconstpointer key1, gconstpointer key2)
|
||||
{
|
||||
const uint64_t *addr1 = key1;
|
||||
const uint64_t *addr2 = key2;
|
||||
|
||||
return *addr1 == *addr2;
|
||||
}
|
||||
|
||||
static void
|
||||
stack_stash_decorate (StackStash *stash)
|
||||
{
|
||||
if (stash->nodes_by_data)
|
||||
return;
|
||||
|
||||
stash->nodes_by_data = g_hash_table_new (address_hash, address_equal);
|
||||
|
||||
decorate_node (stash->root, stash);
|
||||
}
|
||||
|
||||
static void
|
||||
free_key (gpointer key,
|
||||
gpointer value,
|
||||
gpointer data)
|
||||
{
|
||||
GDestroyNotify destroy = data;
|
||||
uint64_t u64 = *(uint64_t *)key;
|
||||
|
||||
destroy (U64_TO_POINTER (u64));
|
||||
}
|
||||
|
||||
static void
|
||||
stack_stash_undecorate (StackStash *stash)
|
||||
{
|
||||
if (stash->nodes_by_data)
|
||||
{
|
||||
if (stash->destroy)
|
||||
{
|
||||
g_hash_table_foreach (
|
||||
stash->nodes_by_data, free_key, stash->destroy);
|
||||
}
|
||||
|
||||
g_hash_table_destroy (stash->nodes_by_data);
|
||||
stash->nodes_by_data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
get_nodes_by_data (StackStash *stash)
|
||||
{
|
||||
if (!stash->nodes_by_data)
|
||||
stack_stash_decorate (stash);
|
||||
|
||||
return stash->nodes_by_data;
|
||||
}
|
||||
|
||||
StackNode *
|
||||
stack_node_new (StackStash *stash)
|
||||
{
|
||||
StackNode *node;
|
||||
|
||||
if (!stash->cached_nodes)
|
||||
{
|
||||
#define BLOCK_SIZE 32768
|
||||
#define N_NODES (BLOCK_SIZE / sizeof (StackNode))
|
||||
|
||||
StackNode *block = g_malloc (BLOCK_SIZE);
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < N_NODES; ++i)
|
||||
{
|
||||
block[i].next = stash->cached_nodes;
|
||||
stash->cached_nodes = &(block[i]);
|
||||
}
|
||||
|
||||
g_ptr_array_add (stash->blocks, block);
|
||||
}
|
||||
|
||||
node = stash->cached_nodes;
|
||||
stash->cached_nodes = node->next;
|
||||
|
||||
node->siblings = NULL;
|
||||
node->children = NULL;
|
||||
node->data = 0;
|
||||
node->parent = NULL;
|
||||
node->size = 0;
|
||||
node->next = NULL;
|
||||
node->total = 0;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/* "destroy", if non-NULL, is called once on every address */
|
||||
static StackStash *
|
||||
create_stack_stash (GDestroyNotify destroy)
|
||||
{
|
||||
StackStash *stash = g_new (StackStash, 1);
|
||||
|
||||
stash->root = NULL;
|
||||
stash->nodes_by_data = NULL;
|
||||
stash->ref_count = 1;
|
||||
stash->destroy = destroy;
|
||||
|
||||
stash->cached_nodes = NULL;
|
||||
stash->blocks = g_ptr_array_new ();
|
||||
|
||||
return stash;
|
||||
}
|
||||
|
||||
/* Stach */
|
||||
StackStash *
|
||||
stack_stash_new (GDestroyNotify destroy)
|
||||
{
|
||||
return create_stack_stash (destroy);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
stack_stash_free (StackStash *stash)
|
||||
{
|
||||
guint i;
|
||||
|
||||
stack_stash_undecorate (stash);
|
||||
|
||||
for (i = 0; i < stash->blocks->len; ++i)
|
||||
g_free (stash->blocks->pdata[i]);
|
||||
|
||||
g_ptr_array_free (stash->blocks, TRUE);
|
||||
|
||||
g_free (stash);
|
||||
}
|
||||
|
||||
StackNode *
|
||||
stack_stash_add_trace (StackStash *stash,
|
||||
const uint64_t *addrs,
|
||||
int n_addrs,
|
||||
int size)
|
||||
{
|
||||
StackNode **location = &(stash->root);
|
||||
StackNode *parent = NULL;
|
||||
int i;
|
||||
|
||||
if (!n_addrs)
|
||||
return NULL;
|
||||
|
||||
if (stash->nodes_by_data)
|
||||
stack_stash_undecorate (stash);
|
||||
|
||||
for (i = n_addrs - 1; i >= 0; --i)
|
||||
{
|
||||
StackNode *match = NULL;
|
||||
StackNode *prev;
|
||||
|
||||
/* FIXME: On x86-64 we don't get proper stacktraces which means
|
||||
* each node can have tons of children. That makes this loop
|
||||
* here show up on profiles.
|
||||
*
|
||||
* Not sure what can be done about it aside from actually fixing
|
||||
* x86-64 to get stacktraces.
|
||||
*/
|
||||
prev = NULL;
|
||||
for (match = *location; match; prev = match, match = match->siblings)
|
||||
{
|
||||
if (match->data == addrs[i])
|
||||
{
|
||||
if (prev)
|
||||
{
|
||||
/* move to front */
|
||||
prev->siblings = match->siblings;
|
||||
match->siblings = *location;
|
||||
*location = match;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match)
|
||||
{
|
||||
match = stack_node_new (stash);
|
||||
match->data = addrs[i];
|
||||
match->siblings = *location;
|
||||
match->parent = parent;
|
||||
*location = match;
|
||||
}
|
||||
|
||||
match->total += size;
|
||||
|
||||
location = &(match->children);
|
||||
parent = match;
|
||||
}
|
||||
|
||||
parent->size += size;
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
static void
|
||||
do_callback (StackNode *node,
|
||||
StackLink *trace,
|
||||
StackFunction func,
|
||||
gpointer data)
|
||||
{
|
||||
StackLink link;
|
||||
|
||||
if (trace)
|
||||
trace->prev = &link;
|
||||
|
||||
link.next = trace;
|
||||
link.prev = NULL;
|
||||
|
||||
while (node)
|
||||
{
|
||||
link.data = node->data;
|
||||
|
||||
if (node->size)
|
||||
func (&link, node->size, data);
|
||||
|
||||
do_callback (node->children, &link, func, data);
|
||||
|
||||
node = node->siblings;
|
||||
}
|
||||
|
||||
if (trace)
|
||||
trace->prev = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
stack_stash_foreach (StackStash *stash,
|
||||
StackFunction stack_func,
|
||||
gpointer data)
|
||||
{
|
||||
do_callback (stash->root, NULL, stack_func, data);
|
||||
}
|
||||
|
||||
void
|
||||
stack_node_foreach_trace (StackNode *node,
|
||||
StackFunction func,
|
||||
gpointer data)
|
||||
{
|
||||
StackLink link;
|
||||
|
||||
link.next = NULL;
|
||||
link.data = node->data;
|
||||
link.prev = NULL;
|
||||
|
||||
if (node->size)
|
||||
func (&link, node->size, data);
|
||||
|
||||
do_callback (node->children, &link, func, data);
|
||||
}
|
||||
|
||||
void
|
||||
stack_stash_unref (StackStash *stash)
|
||||
{
|
||||
stash->ref_count--;
|
||||
if (stash->ref_count == 0)
|
||||
stack_stash_free (stash);
|
||||
}
|
||||
|
||||
StackStash *
|
||||
stack_stash_ref (StackStash *stash)
|
||||
{
|
||||
stash->ref_count++;
|
||||
return stash;
|
||||
}
|
||||
|
||||
StackNode *
|
||||
stack_stash_find_node (StackStash *stash,
|
||||
gpointer data)
|
||||
{
|
||||
uint64_t u64 = POINTER_TO_U64 (data);
|
||||
|
||||
g_return_val_if_fail (stash != NULL, NULL);
|
||||
|
||||
return g_hash_table_lookup (get_nodes_by_data (stash), &u64);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
StackNodeFunc func;
|
||||
gpointer data;
|
||||
} Info;
|
||||
|
||||
static void
|
||||
do_foreach (gpointer key, gpointer value, gpointer data)
|
||||
{
|
||||
Info *info = data;
|
||||
|
||||
info->func (value, info->data);
|
||||
}
|
||||
|
||||
void
|
||||
stack_stash_foreach_by_address (StackStash *stash,
|
||||
StackNodeFunc func,
|
||||
gpointer data)
|
||||
{
|
||||
Info info;
|
||||
info.func = func;
|
||||
info.data = data;
|
||||
|
||||
g_hash_table_foreach (get_nodes_by_data (stash), do_foreach, &info);
|
||||
}
|
||||
|
||||
StackNode *
|
||||
stack_stash_get_root (StackStash *stash)
|
||||
{
|
||||
return stash->root;
|
||||
}
|
||||
|
||||
void
|
||||
stack_stash_set_root (StackStash *stash,
|
||||
StackNode *root)
|
||||
{
|
||||
g_return_if_fail (stash->root == NULL);
|
||||
|
||||
stash->root = root;
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
/* Sysprof -- Sampling, systemwide CPU profiler
|
||||
* Copyright 2004, Red Hat, Inc.
|
||||
* Copyright 2004, 2005, Soeren Sandmann
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef STACK_STASH_H
|
||||
#define STACK_STASH_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct StackStash StackStash;
|
||||
typedef struct StackNode StackNode;
|
||||
typedef struct StackLink StackLink;
|
||||
|
||||
#define U64_TO_POINTER(u) ((void *)(intptr_t)u)
|
||||
#define POINTER_TO_U64(p) ((uint64_t)(intptr_t)p)
|
||||
|
||||
struct StackNode
|
||||
{
|
||||
uint64_t data;
|
||||
|
||||
guint total : 32;
|
||||
guint size : 31;
|
||||
guint toplevel : 1;
|
||||
|
||||
StackNode * parent;
|
||||
StackNode * siblings;
|
||||
StackNode * children;
|
||||
|
||||
StackNode * next;
|
||||
};
|
||||
|
||||
struct StackLink
|
||||
{
|
||||
uint64_t data;
|
||||
StackLink *next;
|
||||
StackLink *prev;
|
||||
};
|
||||
|
||||
typedef void (* StackFunction) (StackLink *trace,
|
||||
gint size,
|
||||
gpointer data);
|
||||
|
||||
typedef void (* StackNodeFunc) (StackNode *node,
|
||||
gpointer data);
|
||||
|
||||
StackStash *stack_stash_new (GDestroyNotify destroy);
|
||||
StackNode *stack_node_new (StackStash *stash);
|
||||
StackNode *stack_stash_add_trace (StackStash *stash,
|
||||
const uint64_t *addrs,
|
||||
gint n_addrs,
|
||||
int size);
|
||||
void stack_stash_foreach (StackStash *stash,
|
||||
StackFunction stack_func,
|
||||
gpointer data);
|
||||
void stack_node_foreach_trace (StackNode *node,
|
||||
StackFunction stack_func,
|
||||
gpointer data);
|
||||
StackNode *stack_stash_find_node (StackStash *stash,
|
||||
gpointer address);
|
||||
void stack_stash_foreach_by_address (StackStash *stash,
|
||||
StackNodeFunc func,
|
||||
gpointer data);
|
||||
StackNode *stack_stash_get_root (StackStash *stash);
|
||||
StackStash *stack_stash_ref (StackStash *stash);
|
||||
void stack_stash_unref (StackStash *stash);
|
||||
void stack_stash_set_root (StackStash *stash,
|
||||
StackNode *root);
|
||||
|
||||
#endif
|
||||
@ -1,6 +1,6 @@
|
||||
/* sysprof.h
|
||||
*
|
||||
* Copyright 2016 Christian Hergert <christian@hergert.me>
|
||||
* Copyright 2016-2019 Christian Hergert <christian@hergert.me>
|
||||
*
|
||||
* 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
|
||||
|
||||
Reference in New Issue
Block a user