shared: remove use of libshared

This moves everything into other places and simple includes the
files in the cases that it is necessary. In the future, we can
rewrite sysprofd to use GDBus and add GetProcFile() to allow
for client-side processing of kallsyms.
This commit is contained in:
Christian Hergert
2019-05-08 09:57:30 -07:00
parent 1c6741bdc6
commit 6ba408f073
26 changed files with 33 additions and 122 deletions

View File

@ -1,19 +1,25 @@
libsysprof_capture_headers = [
'sp-address.h',
'sp-clock.h',
'sp-capture-condition.h',
'sp-capture-cursor.h',
'sp-capture-reader.h',
'sp-capture-types.h',
'sp-capture-writer.h',
'sp-platform.h',
'sysprof-capture.h',
'sysprof-version-macros.h',
]
libsysprof_capture_sources = [
'sp-address.c',
'sp-capture-condition.c',
'sp-capture-cursor.c',
'sp-capture-reader.c',
'sp-capture-writer.c',
'sp-capture-util.c',
'sp-capture-writer.c',
'sp-clock.c',
'sp-platform.c',
]
configure_file(
@ -25,7 +31,6 @@ configure_file(
libsysprof_capture_deps = [
dependency('glib-2.0', version: glib_req_version),
libshared_dep,
]
install_headers(libsysprof_capture_headers, subdir: sysprof_header_subdir)

View File

@ -20,7 +20,7 @@
#pragma once
#include <glib.h>
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
@ -39,8 +39,10 @@ typedef enum
SP_ADDRESS_CONTEXT_GUEST_USER,
} SpAddressContext;
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_address_is_context_switch (SpAddress address,
SpAddressContext *context);
SYSPROF_AVAILABLE_IN_ALL
const gchar *sp_address_context_to_string (SpAddressContext context);
static inline gint

View File

@ -23,13 +23,16 @@
#include <glib.h>
#include <time.h>
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
typedef gint SpClock;
typedef gint64 SpTimeStamp;
typedef gint32 SpTimeSpan;
extern SpClock sp_clock;
SYSPROF_AVAILABLE_IN_ALL
SpClock sp_clock;
static inline SpTimeStamp
sp_clock_get_current_time (void)
@ -50,6 +53,7 @@ sp_clock_get_relative_time (SpTimeStamp epoch)
return sp_clock_get_current_time () - epoch;
}
SYSPROF_AVAILABLE_IN_ALL
void sp_clock_init (void);
G_END_DECLS

View File

@ -32,7 +32,6 @@ G_BEGIN_DECLS
# include "sp-capture-reader.h"
# include "sp-capture-writer.h"
# include "sp-clock.h"
# include "sp-error.h"
# include "sysprof-version.h"
# include "sysprof-version-macros.h"

View File

@ -20,10 +20,6 @@
#pragma once
#if !defined (SYSPROF_CAPTURE_INSIDE) && !defined (SYSPROF_CAPTURE_COMPILATION)
# error "Only <sysprof-capture.h> can be included directly."
#endif
#include <glib.h>
#include "sysprof-version.h"

View File

@ -20,10 +20,6 @@
#pragma once
#if !defined(SYSPROF_CAPTURE_INSIDE) && !defined(SYSPROF_CAPTURE_COMPILATION)
# error "Only <sysprof-capture.h> can be included directly."
#endif
/**
* SECTION:sysprof-version
* @short_description: sysprof version checking

View File

@ -6,6 +6,7 @@ libsysprof_public_sources = [
'sp-elf-symbol-resolver.c',
'sp-hostinfo-source.c',
'sp-jitmap-symbol-resolver.c',
'sp-kallsyms.c',
'sp-kernel-symbol.c',
'sp-kernel-symbol-resolver.c',
'sp-local-profiler.c',
@ -27,6 +28,7 @@ libsysprof_public_headers = [
'sp-elf-symbol-resolver.h',
'sp-hostinfo-source.h',
'sp-jitmap-symbol-resolver.h',
'sp-kallsyms.h',
'sp-kernel-symbol.h',
'sp-kernel-symbol-resolver.h',
'sp-local-profiler.h',
@ -48,6 +50,7 @@ libsysprof_private_sources = [
'elfparser.c',
'stackstash.c',
'sp-source-util.c',
'sp-line-reader.c',
]
libsysprof_deps = [

View File

@ -20,19 +20,20 @@
#pragma once
#include <glib.h>
#include "sp-kallsyms.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS
typedef struct _SpKallsyms SpKallsyms;
SYSPROF_AVAILABLE_IN_ALL
SpKallsyms *sp_kallsyms_new (const gchar *path);
SYSPROF_AVAILABLE_IN_ALL
gboolean sp_kallsyms_next (SpKallsyms *self,
const gchar **name,
guint64 *address,
guint8 *type);
SYSPROF_AVAILABLE_IN_ALL
void sp_kallsyms_free (SpKallsyms *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpKallsyms, sp_kallsyms_free)

View File

@ -27,7 +27,6 @@
#include <sysprof-capture.h>
#include "sp-kallsyms.h"
#include "sp-line-reader.h"
#include "sp-kernel-symbol.h"
static GArray *kernel_symbols;

View File

@ -26,9 +26,12 @@ G_BEGIN_DECLS
typedef struct _SpLineReader SpLineReader;
G_GNUC_INTERNAL
SpLineReader *sp_line_reader_new (const gchar *contents,
gssize length);
G_GNUC_INTERNAL
void sp_line_reader_free (SpLineReader *self);
G_GNUC_INTERNAL
const gchar *sp_line_reader_next (SpLineReader *self,
gsize *length);

View File

@ -27,6 +27,7 @@ G_BEGIN_DECLS
# include "sp-callgraph-profile.h"
# include "sp-capture-gobject.h"
# include "sp-local-profiler.h"
# include "sp-kallsyms.h"
# include "sp-profile.h"
# include "sp-profiler.h"
# include "sp-map-lookaside.h"

View File

@ -7,7 +7,6 @@ sysprof_version_conf.set('MINOR_VERSION', sysprof_version[1])
sysprof_version_conf.set('MICRO_VERSION', sysprof_version[2])
sysprof_version_conf.set('VERSION', meson.project_version())
subdir('shared')
subdir('libsysprof-capture')
subdir('sysprofd')
subdir('libsysprof')

View File

@ -1,31 +0,0 @@
shared_sources = [
'sp-address.c',
'sp-clock.c',
'sp-error.c',
'sp-line-reader.c',
'sp-platform.c',
'sp-kallsyms.c',
]
shared_public_headers = [
'sp-address.h',
'sp-clock.h',
'sp-error.h',
'sp-platform.h',
'sp-kallsyms.h',
]
install_headers(shared_public_headers, subdir: sysprof_header_subdir)
libshared_deps = [
dependency('glib-2.0'),
]
libshared = static_library('shared', shared_sources,
dependencies: libshared_deps,
)
libshared_dep = declare_dependency(
link_whole: libshared,
include_directories: include_directories('.'),
)

View File

@ -1,32 +0,0 @@
/* sp-error.c
*
* 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
* 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, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "sp-error.h"
GQuark
sp_error_quark (void)
{
static GQuark quark;
if (G_UNLIKELY (!quark))
quark = g_quark_from_static_string ("sp-error-quark");
return quark;
}

View File

@ -1,31 +0,0 @@
/* sp-error.h
*
* Copyright 2016-2019 Christian Hergert <chergert@redhat.com>
*
* This file is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This file 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 Lesser 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
#define SP_ERROR (sp_error_quark())
GQuark sp_error_quark (void);
G_END_DECLS

View File

@ -14,7 +14,6 @@ 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,

View File

@ -4,6 +4,7 @@ sysprofd_sources = [
'sysprofd.c',
'sd-bus-helper.c',
'sd-bus-helper.h',
'../libsysprof/sp-kallsyms.c',
]
pkglibexecdir = join_paths(get_option('prefix'), get_option('libexecdir'))
@ -11,14 +12,14 @@ pkglibexecdir = join_paths(get_option('prefix'), get_option('libexecdir'))
sysprofd_deps = [
dependency('libsystemd', version: '>=222'),
dependency('glib-2.0', version: glib_req_version),
libshared_dep,
]
sysprofd = executable('sysprofd', sysprofd_sources,
dependencies: sysprofd_deps,
install: true,
install_dir: pkglibexecdir,
pie: true,
dependencies: sysprofd_deps,
install: true,
install_dir: pkglibexecdir,
pie: true,
include_directories: [include_directories('.'), '../libsysprof'],
)
sysprofdconf = configuration_data()

View File

@ -1,8 +1,6 @@
#include "../shared/sp-address.h"
#include "../shared/sp-kallsyms.h"
#include <glib.h>
#include <stdlib.h>
#include <sysprof.h>
int
main (gint argc,

View File

@ -1,5 +1,4 @@
tools_deps = [
libshared_dep,
libsysprof_capture_dep,
]