mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
build: various build fixes for macOS
This doesn't make profiling useful in any way, but it does get things to the point where I can actually open a capture file. And it would be nice if we could progress to the point of loading capture files (with correct data in-tact) and this helps us move down that path. To really do that correctly, we should make some of the widgetry disabled when it isn't useful. We also need to ensure that we add extra decoding information to capture files during shutdown so that any platform can read it back. This would also help the situation of running and reading on separate architectures.
This commit is contained in:
@ -12,6 +12,7 @@ libsysprof_capture_sources = [
|
||||
'sp-capture-cursor.c',
|
||||
'sp-capture-reader.c',
|
||||
'sp-capture-writer.c',
|
||||
'sp-capture-util.c',
|
||||
]
|
||||
|
||||
configure_file(
|
||||
|
||||
@ -56,7 +56,6 @@ libsysprof_ui_deps = [
|
||||
dependency('gio-2.0', version: glib_req_version),
|
||||
dependency('gtk+-3.0', version: gtk_req_version),
|
||||
libsysprof_dep,
|
||||
libshared_dep,
|
||||
]
|
||||
|
||||
libsysprof_ui = shared_library('sysprof-ui-@0@'.format(libsysprof_api_version),
|
||||
|
||||
@ -15,9 +15,14 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <elf.h>
|
||||
#ifdef __APPLE__
|
||||
# include <libelf.h>
|
||||
#else
|
||||
# include <elf.h>
|
||||
#endif
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "demangle.h"
|
||||
|
||||
@ -1,20 +1,17 @@
|
||||
libsysprof_c_args = [ '-DSYSPROF_COMPILATION' ]
|
||||
|
||||
libsysprof_public_sources = [
|
||||
'sp-callgraph-profile.c',
|
||||
'sp-capture-gobject.c',
|
||||
'sp-elf-symbol-resolver.c',
|
||||
'sp-gjs-source.c',
|
||||
'sp-hostinfo-source.c',
|
||||
'sp-jitmap-symbol-resolver.c',
|
||||
'sp-kernel-symbol.c',
|
||||
'sp-kernel-symbol-resolver.c',
|
||||
'sp-local-profiler.c',
|
||||
'sp-map-lookaside.c',
|
||||
'sp-memory-source.c',
|
||||
'sp-perf-counter.c',
|
||||
'sp-perf-source.c',
|
||||
'sp-process-model.c',
|
||||
'sp-process-model-item.c',
|
||||
'sp-proc-source.c',
|
||||
'sp-profile.c',
|
||||
'sp-profiler.c',
|
||||
'sp-selection.c',
|
||||
@ -28,19 +25,14 @@ libsysprof_public_headers = [
|
||||
'sp-callgraph-profile-private.h',
|
||||
'sp-capture-gobject.h',
|
||||
'sp-elf-symbol-resolver.h',
|
||||
'sp-gjs-source.h',
|
||||
'sp-hostinfo-source.h',
|
||||
'sp-jitmap-symbol-resolver.h',
|
||||
'sp-kernel-symbol.h',
|
||||
'sp-kernel-symbol-resolver.h',
|
||||
'sp-local-profiler.h',
|
||||
'sp-map-lookaside.h',
|
||||
'sp-memory-source.h',
|
||||
'sp-perf-counter.h',
|
||||
'sp-perf-source.h',
|
||||
'sp-process-model.h',
|
||||
'sp-process-model-item.h',
|
||||
'sp-proc-source.h',
|
||||
'sp-profile.h',
|
||||
'sp-profiler.h',
|
||||
'sp-selection.h',
|
||||
@ -59,13 +51,38 @@ libsysprof_private_sources = [
|
||||
]
|
||||
|
||||
libsysprof_deps = [
|
||||
cxx.find_library('stdc++'),
|
||||
dependency('gio-2.0', version: glib_req_version),
|
||||
dependency('gio-unix-2.0', version: glib_req_version),
|
||||
libsysprof_capture_dep,
|
||||
libshared_dep,
|
||||
]
|
||||
|
||||
if host_machine.system() == 'linux'
|
||||
libsysprof_public_sources += [
|
||||
'sp-gjs-source.c',
|
||||
'sp-memory-source.c',
|
||||
'sp-perf-counter.c',
|
||||
'sp-perf-source.c',
|
||||
'sp-proc-source.c',
|
||||
]
|
||||
|
||||
libsysprof_public_headers += [
|
||||
'sp-gjs-source.h',
|
||||
'sp-memory-source.h',
|
||||
'sp-perf-counter.h',
|
||||
'sp-perf-source.h',
|
||||
'sp-proc-source.h',
|
||||
]
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'darwin'
|
||||
libsysprof_deps += [ dependency('libelf') ]
|
||||
libsysprof_c_args = [ '-DNT_GNU_BUILD_ID=3', '-DELF_NOTE_GNU="GNU"', '-D__LIBELF_INTERNAL__' ]
|
||||
endif
|
||||
|
||||
if host_machine.system() != 'darwin'
|
||||
libsysprof_deps += [cxx.find_library('stdc++')]
|
||||
endif
|
||||
|
||||
if get_option('with_sysprofd') != 'none'
|
||||
libsysprof_deps += dependency('polkit-gobject-1')
|
||||
endif
|
||||
@ -73,7 +90,7 @@ endif
|
||||
libsysprof = shared_library('sysprof-@0@'.format(libsysprof_api_version),
|
||||
libsysprof_public_sources + libsysprof_private_sources,
|
||||
dependencies: libsysprof_deps,
|
||||
c_args: [ '-DSYSPROF_COMPILATION' ],
|
||||
c_args: libsysprof_c_args,
|
||||
install: true,
|
||||
install_dir: get_option('libdir'),
|
||||
)
|
||||
|
||||
@ -340,7 +340,7 @@ sp_callgraph_profile_generate_worker (GTask *task,
|
||||
last_context = SP_ADDRESS_CONTEXT_NONE;
|
||||
#endif
|
||||
|
||||
node = stack_stash_add_trace (stash, sample->addrs, sample->n_addrs, 1);
|
||||
node = stack_stash_add_trace (stash, (gpointer)sample->addrs, sample->n_addrs, 1);
|
||||
|
||||
for (iter = node; iter != NULL; iter = iter->parent)
|
||||
len++;
|
||||
@ -410,7 +410,7 @@ sp_callgraph_profile_generate_worker (GTask *task,
|
||||
|
||||
g_array_index (resolved, guint64, len++) = POINTER_TO_U64 ("[Everything]");
|
||||
|
||||
stack_stash_add_trace (resolved_stash, (SpAddress *)(gpointer)resolved->data, len, 1);
|
||||
stack_stash_add_trace (resolved_stash, (gpointer)resolved->data, len, 1);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
@ -19,7 +19,9 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "sp-process-model-item.h"
|
||||
#include "sp-proc-source.h"
|
||||
#ifdef __linux__
|
||||
# include "sp-proc-source.h"
|
||||
#endif
|
||||
|
||||
struct _SpProcessModelItem
|
||||
{
|
||||
@ -134,11 +136,13 @@ sp_process_model_item_init (SpProcessModelItem *self)
|
||||
SpProcessModelItem *
|
||||
sp_process_model_item_new (GPid pid)
|
||||
{
|
||||
g_autofree gchar *cmdline = NULL;
|
||||
SpProcessModelItem *ret;
|
||||
gchar *cmdline;
|
||||
gboolean is_kernel;
|
||||
gboolean is_kernel = FALSE;
|
||||
|
||||
#ifdef __linux__
|
||||
cmdline = sp_proc_source_get_command_line (pid, &is_kernel);
|
||||
#endif
|
||||
|
||||
ret = g_object_new (SP_TYPE_PROCESS_MODEL_ITEM,
|
||||
"command-line", cmdline,
|
||||
@ -146,8 +150,6 @@ sp_process_model_item_new (GPid pid)
|
||||
NULL);
|
||||
ret->is_kernel = is_kernel;
|
||||
|
||||
g_free (cmdline);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -29,12 +29,7 @@ G_BEGIN_DECLS
|
||||
# include "sp-local-profiler.h"
|
||||
# include "sp-profile.h"
|
||||
# include "sp-profiler.h"
|
||||
# include "sp-gjs-source.h"
|
||||
# include "sp-hostinfo-source.h"
|
||||
# include "sp-map-lookaside.h"
|
||||
# include "sp-memory-source.h"
|
||||
# include "sp-perf-source.h"
|
||||
# include "sp-proc-source.h"
|
||||
# include "sp-source.h"
|
||||
# include "sp-elf-symbol-resolver.h"
|
||||
# include "sp-jitmap-symbol-resolver.h"
|
||||
@ -44,6 +39,15 @@ G_BEGIN_DECLS
|
||||
# include "sp-symbol-resolver.h"
|
||||
# include "sp-map-lookaside.h"
|
||||
# include "sp-selection.h"
|
||||
|
||||
#ifdef __linux__
|
||||
# include "sp-gjs-source.h"
|
||||
# include "sp-hostinfo-source.h"
|
||||
# include "sp-memory-source.h"
|
||||
# include "sp-perf-source.h"
|
||||
# include "sp-proc-source.h"
|
||||
#endif
|
||||
|
||||
#undef SYSPROF_INSIDE
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@ -4,6 +4,7 @@ shared_sources = [
|
||||
'sp-error.c',
|
||||
'sp-line-reader.c',
|
||||
'sp-platform.c',
|
||||
'sp-kallsyms.c',
|
||||
]
|
||||
|
||||
shared_public_headers = [
|
||||
@ -11,14 +12,11 @@ shared_public_headers = [
|
||||
'sp-clock.h',
|
||||
'sp-error.h',
|
||||
'sp-platform.h',
|
||||
'sp-kallsyms.h',
|
||||
]
|
||||
|
||||
install_headers(shared_public_headers, subdir: sysprof_header_subdir)
|
||||
|
||||
if host_machine.system() == 'linux'
|
||||
shared_sources += ['sp-kallsyms.c']
|
||||
endif
|
||||
|
||||
libshared_deps = [
|
||||
dependency('glib-2.0'),
|
||||
]
|
||||
|
||||
6
src/shared/sp-address-fallback.h
Normal file
6
src/shared/sp-address-fallback.h
Normal file
@ -0,0 +1,6 @@
|
||||
#define PERF_CONTEXT_GUEST_USER (-2560)
|
||||
#define PERF_CONTEXT_GUEST_KERNEL (-2176)
|
||||
#define PERF_CONTEXT_GUEST (-2048)
|
||||
#define PERF_CONTEXT_USER (-512)
|
||||
#define PERF_CONTEXT_KERNEL (-128)
|
||||
#define PERF_CONTEXT_HV (-32)
|
||||
@ -18,7 +18,11 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include <linux/perf_event.h>
|
||||
#ifdef __linux__
|
||||
# include <linux/perf_event.h>
|
||||
#else
|
||||
# include "sp-address-fallback.h"
|
||||
#endif
|
||||
|
||||
#include "sp-address.h"
|
||||
|
||||
|
||||
@ -28,8 +28,10 @@ sp_clock_init (void)
|
||||
static const gint clock_ids[] = {
|
||||
CLOCK_MONOTONIC,
|
||||
CLOCK_MONOTONIC_RAW,
|
||||
#ifdef __linux__
|
||||
CLOCK_MONOTONIC_COARSE,
|
||||
CLOCK_REALTIME_COARSE,
|
||||
#endif
|
||||
CLOCK_REALTIME,
|
||||
};
|
||||
|
||||
|
||||
@ -14,6 +14,9 @@ sysprof_resources = gnome.compile_resources('sysprof-resources', 'sysprof.gresou
|
||||
|
||||
sysprof_deps = [
|
||||
cc.find_library('m', required: false),
|
||||
libshared_dep,
|
||||
libsysprof_capture_dep,
|
||||
libsysprof_dep,
|
||||
libsysprof_ui_dep,
|
||||
]
|
||||
|
||||
@ -22,7 +25,6 @@ sysprof = executable('sysprof', sysprof_resources + sysprof_sources,
|
||||
gui_app: true,
|
||||
install_dir: get_option('bindir'),
|
||||
install: true,
|
||||
pie: true,
|
||||
)
|
||||
|
||||
endif
|
||||
|
||||
@ -400,6 +400,7 @@ static void
|
||||
sp_window_add_sources (SpWindow *window,
|
||||
SpProfiler *profiler)
|
||||
{
|
||||
#ifdef __linux__
|
||||
g_autoptr(SpSource) host_source = NULL;
|
||||
g_autoptr(SpSource) proc_source = NULL;
|
||||
g_autoptr(SpSource) perf_source = NULL;
|
||||
@ -419,6 +420,7 @@ sp_window_add_sources (SpWindow *window,
|
||||
|
||||
memory_source = sp_memory_source_new ();
|
||||
sp_profiler_add_source (profiler, memory_source);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -6,18 +6,22 @@ test_env = [
|
||||
'MALLOC_CHECK_=2',
|
||||
]
|
||||
|
||||
test_deps = [
|
||||
libsysprof_dep,
|
||||
]
|
||||
|
||||
test_cflags = [
|
||||
'-DTEST_DATA_DIR="@0@/data/"'.format(meson.current_source_dir()),
|
||||
]
|
||||
|
||||
test_capture = executable('test-capture', 'test-capture.c',
|
||||
c_args: test_cflags,
|
||||
dependencies: libsysprof_capture_dep,
|
||||
dependencies: test_deps,
|
||||
)
|
||||
|
||||
test_capture_cursor = executable('test-capture-cursor', 'test-capture-cursor.c',
|
||||
c_args: test_cflags,
|
||||
dependencies: libsysprof_capture_dep,
|
||||
dependencies: test_deps,
|
||||
)
|
||||
|
||||
test('test-capture', test_capture, env: test_env)
|
||||
@ -26,24 +30,29 @@ test('test-capture-cursor', test_capture_cursor, env: test_env)
|
||||
# Use ./tests/test-kallsyms /proc/kallsyms to test (as user or root)
|
||||
test_kallsyms = executable('test-kallsyms', 'test-kallsyms.c',
|
||||
c_args: test_cflags,
|
||||
dependencies: libsysprof_dep,
|
||||
dependencies: test_deps,
|
||||
)
|
||||
|
||||
if get_option('enable_gtk')
|
||||
|
||||
test_ui_deps = [
|
||||
libsysprof_dep,
|
||||
libsysprof_ui_dep,
|
||||
]
|
||||
|
||||
test_model_filter = executable('test-model-filter', 'test-model-filter.c',
|
||||
c_args: test_cflags,
|
||||
dependencies: libsysprof_ui_dep,
|
||||
dependencies: test_ui_deps,
|
||||
)
|
||||
|
||||
test_process_model = executable('test-process-model', 'test-process-model.c',
|
||||
c_args: test_cflags,
|
||||
dependencies: libsysprof_ui_dep,
|
||||
dependencies: test_ui_deps,
|
||||
)
|
||||
|
||||
test_zoom = executable('test-zoom', 'test-zoom.c',
|
||||
c_args: test_cflags,
|
||||
dependencies: libsysprof_ui_dep,
|
||||
dependencies: test_ui_deps,
|
||||
)
|
||||
|
||||
test('test-model-filter', test_model_filter, env: test_env)
|
||||
|
||||
@ -1,20 +1,24 @@
|
||||
tools_deps = [
|
||||
libshared_dep,
|
||||
libsysprof_capture_dep,
|
||||
]
|
||||
|
||||
sysprof_cli = executable('sysprof-cli', 'sysprof-cli.c',
|
||||
dependencies: libsysprof_dep,
|
||||
install_dir: get_option('bindir'),
|
||||
install: true,
|
||||
)
|
||||
if host_machine.system() == 'linux'
|
||||
sysprof_cli = executable('sysprof-cli', 'sysprof-cli.c',
|
||||
dependencies: tools_deps + [libsysprof_dep],
|
||||
install_dir: get_option('bindir'),
|
||||
install: true,
|
||||
)
|
||||
endif
|
||||
|
||||
sysprof_cat = executable('sysprof-cat', 'sysprof-cat.c',
|
||||
dependencies: libsysprof_capture_dep,
|
||||
dependencies: tools_deps,
|
||||
install_dir: get_option('bindir'),
|
||||
install: true,
|
||||
pie: true,
|
||||
)
|
||||
|
||||
sysprof_dump = executable('sysprof-dump', 'sysprof-dump.c',
|
||||
dependencies: libsysprof_capture_dep,
|
||||
dependencies: tools_deps,
|
||||
install_dir: get_option('bindir'),
|
||||
install: true,
|
||||
pie: true,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user