libsysprof: cleanup whitespace in headers

This commit is contained in:
Christian Hergert
2019-05-08 17:33:23 -07:00
parent 88a689ade1
commit 543bf87b81
29 changed files with 175 additions and 399 deletions

View File

@ -22,6 +22,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
G_GNUC_INTERNAL
gchar *sysprof_cplus_demangle (const gchar *name); gchar *sysprof_cplus_demangle (const gchar *name);
G_END_DECLS G_END_DECLS

View File

@ -15,6 +15,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <glib.h> #include <glib.h>
typedef struct ElfSym ElfSym; typedef struct ElfSym ElfSym;
@ -54,3 +55,4 @@ gulong elf_parser_get_sym_address (ElfParser *parser,
gboolean elf_parser_owns_symbol (ElfParser *parser, gboolean elf_parser_owns_symbol (ElfParser *parser,
const ElfSym *sym); const ElfSym *sym);
char *elf_demangle (const char *name); char *elf_demangle (const char *name);

View File

@ -48,7 +48,6 @@ libsysprof_private_sources = [
'binfile.c', 'binfile.c',
'demangle.cpp', 'demangle.cpp',
'elfparser.c', 'elfparser.c',
'sysprof-source-util.c',
'sysprof-line-reader.c', 'sysprof-line-reader.c',
] ]

View File

@ -24,9 +24,8 @@
# error "Only <sysprof.h> can be included directly." # error "Only <sysprof.h> can be included directly."
#endif #endif
#include "sysprof-version-macros.h"
#include "sysprof-symbol-resolver.h" #include "sysprof-symbol-resolver.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -30,8 +30,10 @@ G_BEGIN_DECLS
#define SYSPROF_TYPE_GJS_SOURCE (sysprof_gjs_source_get_type()) #define SYSPROF_TYPE_GJS_SOURCE (sysprof_gjs_source_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SysprofGjsSource, sysprof_gjs_source, SYSPROF, GJS_SOURCE, GObject) G_DECLARE_FINAL_TYPE (SysprofGjsSource, sysprof_gjs_source, SYSPROF, GJS_SOURCE, GObject)
SYSPROF_AVAILABLE_IN_ALL
SysprofSource *sysprof_gjs_source_new (void); SysprofSource *sysprof_gjs_source_new (void);
G_END_DECLS G_END_DECLS

View File

@ -24,8 +24,6 @@
# error "Only <sysprof.h> can be included directly." # error "Only <sysprof.h> can be included directly."
#endif #endif
#include "sysprof-version-macros.h"
#include "sysprof-source.h" #include "sysprof-source.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -32,6 +32,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (SysprofJitmapSymbolResolver, sysprof_jitmap_symbol_resolver, SYSPROF, JITMAP_SYMBOL_RESOLVER, GObject) G_DECLARE_FINAL_TYPE (SysprofJitmapSymbolResolver, sysprof_jitmap_symbol_resolver, SYSPROF, JITMAP_SYMBOL_RESOLVER, GObject)
SYSPROF_AVAILABLE_IN_ALL
SysprofSymbolResolver *sysprof_jitmap_symbol_resolver_new (void); SysprofSymbolResolver *sysprof_jitmap_symbol_resolver_new (void);
G_END_DECLS G_END_DECLS

View File

@ -32,6 +32,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (SysprofKernelSymbolResolver, sysprof_kernel_symbol_resolver, SYSPROF, KERNEL_SYMBOL_RESOLVER, GObject) G_DECLARE_FINAL_TYPE (SysprofKernelSymbolResolver, sysprof_kernel_symbol_resolver, SYSPROF, KERNEL_SYMBOL_RESOLVER, GObject)
SYSPROF_AVAILABLE_IN_ALL
SysprofSymbolResolver *sysprof_kernel_symbol_resolver_new (void); SysprofSymbolResolver *sysprof_kernel_symbol_resolver_new (void);
G_END_DECLS G_END_DECLS

View File

@ -34,6 +34,7 @@ typedef struct
const gchar *name; const gchar *name;
} SysprofKernelSymbol; } SysprofKernelSymbol;
SYSPROF_AVAILABLE_IN_ALL
const SysprofKernelSymbol *sysprof_kernel_symbol_from_address (SysprofCaptureAddress address); const SysprofKernelSymbol *sysprof_kernel_symbol_from_address (SysprofCaptureAddress address);
G_END_DECLS G_END_DECLS

View File

@ -25,7 +25,6 @@
#endif #endif
#include "sysprof-profiler.h" #include "sysprof-profiler.h"
#include "sysprof-version-macros.h" #include "sysprof-version-macros.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -24,8 +24,6 @@
# error "Only <sysprof.h> can be included directly." # error "Only <sysprof.h> can be included directly."
#endif #endif
#include <glib.h>
#include "sysprof-capture-types.h" #include "sysprof-capture-types.h"
G_BEGIN_DECLS G_BEGIN_DECLS
@ -41,11 +39,14 @@ typedef struct
const gchar *filename; const gchar *filename;
} SysprofMap; } SysprofMap;
SYSPROF_AVAILABLE_IN_ALL
SysprofMapLookaside *sysprof_map_lookaside_new (void); SysprofMapLookaside *sysprof_map_lookaside_new (void);
void sysprof_map_lookaside_insert (SysprofMapLookaside *self, void sysprof_map_lookaside_insert (SysprofMapLookaside *self,
const SysprofMap *map); const SysprofMap *map);
SYSPROF_AVAILABLE_IN_ALL
const SysprofMap *sysprof_map_lookaside_lookup (SysprofMapLookaside *self, const SysprofMap *sysprof_map_lookaside_lookup (SysprofMapLookaside *self,
SysprofCaptureAddress address); SysprofCaptureAddress address);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_map_lookaside_free (SysprofMapLookaside *self); void sysprof_map_lookaside_free (SysprofMapLookaside *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofMapLookaside, sysprof_map_lookaside_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofMapLookaside, sysprof_map_lookaside_free)

View File

@ -24,9 +24,8 @@
# error "Only <sysprof.h> can be included directly." # error "Only <sysprof.h> can be included directly."
#endif #endif
#include "sysprof-version-macros.h"
#include "sysprof-source.h" #include "sysprof-source.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -130,7 +130,6 @@ void sysprof_perf_counter_authorize_async (GCancellable *cancellabl
gpointer user_data); gpointer user_data);
gboolean sysprof_perf_counter_authorize_finish (GAsyncResult *result, gboolean sysprof_perf_counter_authorize_finish (GAsyncResult *result,
GError **error); GError **error);
GType sysprof_perf_counter_get_type (void); GType sysprof_perf_counter_get_type (void);
SysprofPerfCounter *sysprof_perf_counter_new (GMainContext *context); SysprofPerfCounter *sysprof_perf_counter_new (GMainContext *context);
void sysprof_perf_counter_set_callback (SysprofPerfCounter *self, void sysprof_perf_counter_set_callback (SysprofPerfCounter *self,

View File

@ -24,9 +24,8 @@
# error "Only <sysprof.h> can be included directly." # error "Only <sysprof.h> can be included directly."
#endif #endif
#include "sysprof-version-macros.h"
#include "sysprof-source.h" #include "sysprof-source.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -26,9 +26,8 @@
#include <gio/gio.h> #include <gio/gio.h>
#include "sysprof-version-macros.h"
#include "sysprof-capture-reader.h" #include "sysprof-capture-reader.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -1,34 +0,0 @@
/* sysprof-source-util-private.h
*
* Copyright 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 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 <glib.h>
G_BEGIN_DECLS
gboolean sysprof_host_file_get_contents (const gchar *host_path,
gchar **contents,
gsize *len,
GError **error);
gchar **sysprof_host_list_directories (const gchar *directory,
GError **error);
G_END_DECLS

View File

@ -1,205 +0,0 @@
/* sysprof-source-util.c
*
* Copyright 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 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 <gio/gio.h>
#include <string.h>
#include "sysprof-source-util-private.h"
gboolean
sysprof_host_file_get_contents (const gchar *host_path,
gchar **contents,
gsize *len,
GError **error)
{
g_autofree gchar *alt_path = NULL;
g_return_val_if_fail (host_path != NULL, FALSE);
if (!g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS))
return g_file_get_contents (host_path, contents, len, error);
if (contents != NULL)
*contents = NULL;
if (len != NULL)
*len = 0;
alt_path = g_build_filename ("/var/run/host", host_path, NULL);
if (g_file_test (alt_path, G_FILE_TEST_EXISTS))
return g_file_get_contents (alt_path, contents, len, error);
/*
* Fallback to try to get it with "cat" on the host since we
* may not have access (like for /proc) from /var/run/host.
*/
{
g_autoptr(GSubprocessLauncher) launcher = NULL;
g_autoptr(GSubprocess) subprocess = NULL;
g_autoptr(GBytes) stdout_buf = NULL;
launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE |
G_SUBPROCESS_FLAGS_STDERR_SILENCE);
subprocess = g_subprocess_launcher_spawn (launcher, error,
"flatpak-spawn",
"--clear-env",
"--host",
"cat",
host_path,
NULL);
if (subprocess == NULL)
return FALSE;
if (!g_subprocess_communicate (subprocess, NULL, NULL, &stdout_buf, NULL, error))
return FALSE;
if (len != NULL)
*len = g_bytes_get_size (stdout_buf);
if (contents != NULL)
{
const guint8 *data;
gsize n;
/* g_file_get_contents() gurantees a trailing null byte */
data = g_bytes_get_data (stdout_buf, &n);
*contents = g_malloc (n + 1);
memcpy (*contents, data, n);
(*contents)[n] = '\0';
}
}
return TRUE;
}
gchar **
sysprof_host_list_directories (const gchar *directory,
GError **error)
{
g_autofree gchar *alt_path = NULL;
g_return_val_if_fail (directory != NULL, NULL);
if (g_file_test ("/.flatpak-info", G_FILE_TEST_IS_REGULAR))
{
g_autoptr(GSubprocessLauncher) launcher = NULL;
g_autoptr(GSubprocess) subprocess = NULL;
g_autofree gchar *stdout_buf = NULL;
g_auto(GStrv) lines = NULL;
gsize len;
guint j = 0;
alt_path = g_build_filename ("/var/run/host", directory, NULL);
if (g_file_test (alt_path, G_FILE_TEST_IS_DIR))
{
directory = alt_path;
goto try_native;
}
launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE |
G_SUBPROCESS_FLAGS_STDERR_SILENCE);
subprocess = g_subprocess_launcher_spawn (launcher, error,
"flatpak-spawn",
"--clear-env",
"--host",
"ls",
"-1",
"-U",
"--file-type",
directory,
NULL);
if (subprocess == NULL)
return NULL;
if (!g_subprocess_communicate_utf8 (subprocess, NULL, NULL, &stdout_buf, NULL, error))
return NULL;
lines = g_strsplit (stdout_buf, "\n", 0);
len = g_strv_length (lines);
for (gsize i = 0; i < len; i++)
{
gsize llen = strlen (lines[i]);
if (llen == 0 || lines[i][llen-1] != '/')
{
/* Remove this entry, we'll compress the list later */
g_free (lines[i]);
lines[i] = NULL;
}
else
{
/* trim trailing / */
lines[i][llen-1] = 0;
}
}
/* Compress the list by removing NULL links */
for (gsize i = 0; i < len; i++)
{
if (lines[i] == NULL)
{
if (j <= i)
j = i + 1;
for (; j < len; j++)
{
if (lines[j] != NULL)
{
lines[i] = g_steal_pointer (&lines[j]);
break;
}
}
}
}
return g_steal_pointer (&lines);
}
try_native:
{
g_autoptr(GDir) dir = g_dir_open (directory, 0, error);
g_autoptr(GPtrArray) dirs = g_ptr_array_new_with_free_func (g_free);
const gchar *name;
if (dir == NULL)
return NULL;
while ((name = g_dir_read_name (dir)))
{
g_autofree gchar *path = g_build_filename (directory, name, NULL);
if (g_file_test (path, G_FILE_TEST_IS_DIR))
g_ptr_array_add (dirs, g_steal_pointer (&path));
}
g_ptr_array_add (dirs, NULL);
return (gchar **)g_ptr_array_free (g_steal_pointer (&dirs), FALSE);
}
}

View File

@ -32,6 +32,7 @@ G_BEGIN_DECLS
#define SYSPROF_TYPE_SOURCE (sysprof_source_get_type()) #define SYSPROF_TYPE_SOURCE (sysprof_source_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_INTERFACE (SysprofSource, sysprof_source, SYSPROF, SOURCE, GObject) G_DECLARE_INTERFACE (SysprofSource, sysprof_source, SYSPROF, SOURCE, GObject)
struct _SysprofSourceInterface struct _SysprofSourceInterface
@ -120,17 +121,26 @@ struct _SysprofSourceInterface
void (*stop) (SysprofSource *self); void (*stop) (SysprofSource *self);
}; };
SYSPROF_AVAILABLE_IN_ALL
void sysprof_source_add_pid (SysprofSource *self, void sysprof_source_add_pid (SysprofSource *self,
GPid pid); GPid pid);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_source_emit_ready (SysprofSource *self); void sysprof_source_emit_ready (SysprofSource *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_source_emit_finished (SysprofSource *self); void sysprof_source_emit_finished (SysprofSource *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_source_emit_failed (SysprofSource *self, void sysprof_source_emit_failed (SysprofSource *self,
const GError *error); const GError *error);
SYSPROF_AVAILABLE_IN_ALL
gboolean sysprof_source_get_is_ready (SysprofSource *self); gboolean sysprof_source_get_is_ready (SysprofSource *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_source_prepare (SysprofSource *self); void sysprof_source_prepare (SysprofSource *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_source_set_writer (SysprofSource *self, void sysprof_source_set_writer (SysprofSource *self,
SysprofCaptureWriter *writer); SysprofCaptureWriter *writer);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_source_start (SysprofSource *self); void sysprof_source_start (SysprofSource *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_source_stop (SysprofSource *self); void sysprof_source_stop (SysprofSource *self);
G_END_DECLS G_END_DECLS

View File

@ -28,11 +28,13 @@
#include "sysprof-address.h" #include "sysprof-address.h"
#include "sysprof-capture-reader.h" #include "sysprof-capture-reader.h"
#include "sysprof-version-macros.h"
G_BEGIN_DECLS G_BEGIN_DECLS
#define SYSPROF_TYPE_SYMBOL_RESOLVER (sysprof_symbol_resolver_get_type()) #define SYSPROF_TYPE_SYMBOL_RESOLVER (sysprof_symbol_resolver_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_INTERFACE (SysprofSymbolResolver, sysprof_symbol_resolver, SYSPROF, SYMBOL_RESOLVER, GObject) G_DECLARE_INTERFACE (SysprofSymbolResolver, sysprof_symbol_resolver, SYSPROF, SYMBOL_RESOLVER, GObject)
struct _SysprofSymbolResolverInterface struct _SysprofSymbolResolverInterface
@ -54,13 +56,16 @@ struct _SysprofSymbolResolverInterface
GQuark *tag); GQuark *tag);
}; };
SYSPROF_AVAILABLE_IN_ALL
void sysprof_symbol_resolver_load (SysprofSymbolResolver *self, void sysprof_symbol_resolver_load (SysprofSymbolResolver *self,
SysprofCaptureReader *reader); SysprofCaptureReader *reader);
SYSPROF_AVAILABLE_IN_ALL
gchar *sysprof_symbol_resolver_resolve (SysprofSymbolResolver *self, gchar *sysprof_symbol_resolver_resolve (SysprofSymbolResolver *self,
guint64 time, guint64 time,
GPid pid, GPid pid,
SysprofCaptureAddress address, SysprofCaptureAddress address,
GQuark *tag); GQuark *tag);
SYSPROF_AVAILABLE_IN_ALL
gchar *sysprof_symbol_resolver_resolve_with_context (SysprofSymbolResolver *self, gchar *sysprof_symbol_resolver_resolve_with_context (SysprofSymbolResolver *self,
guint64 time, guint64 time,
GPid pid, GPid pid,