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:
Christian Hergert
2019-05-07 22:59:56 -07:00
parent 94ce3dd648
commit 63bcfc2b0e
15 changed files with 103 additions and 48 deletions

View File

@ -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"

View File

@ -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'),
)

View File

@ -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;

View File

@ -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;
}

View File

@ -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