From 543bf87b81c914719d136e8f426c95206542e733 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 8 May 2019 17:33:23 -0700 Subject: [PATCH] libsysprof: cleanup whitespace in headers --- src/libsysprof/binfile.h | 4 +- src/libsysprof/demangle.h | 1 + src/libsysprof/elfparser.h | 34 +-- src/libsysprof/meson.build | 1 - src/libsysprof/sysprof-callgraph-profile.h | 6 +- src/libsysprof/sysprof-elf-symbol-resolver.h | 3 +- src/libsysprof/sysprof-gjs-source.h | 2 + src/libsysprof/sysprof-hostinfo-source.h | 2 - .../sysprof-jitmap-symbol-resolver.h | 1 + src/libsysprof/sysprof-kallsyms.h | 12 +- .../sysprof-kernel-symbol-resolver.h | 1 + src/libsysprof/sysprof-kernel-symbol.h | 1 + src/libsysprof/sysprof-line-reader.h | 10 +- src/libsysprof/sysprof-local-profiler.h | 1 - src/libsysprof/sysprof-map-lookaside.h | 13 +- src/libsysprof/sysprof-memory-source.h | 3 +- src/libsysprof/sysprof-perf-counter.h | 55 +++-- src/libsysprof/sysprof-perf-source.h | 7 +- src/libsysprof/sysprof-proc-source.h | 4 +- src/libsysprof/sysprof-process-model-item.h | 16 +- src/libsysprof/sysprof-process-model.h | 4 +- src/libsysprof/sysprof-profile.h | 21 +- src/libsysprof/sysprof-profiler.h | 64 +++--- src/libsysprof/sysprof-selection.h | 26 +-- src/libsysprof/sysprof-source-util-private.h | 34 --- src/libsysprof/sysprof-source-util.c | 205 ------------------ src/libsysprof/sysprof-source.h | 16 +- src/libsysprof/sysprof-symbol-dirs.h | 2 +- src/libsysprof/sysprof-symbol-resolver.h | 25 ++- 29 files changed, 175 insertions(+), 399 deletions(-) delete mode 100644 src/libsysprof/sysprof-source-util-private.h delete mode 100644 src/libsysprof/sysprof-source-util.c diff --git a/src/libsysprof/binfile.h b/src/libsysprof/binfile.h index 42a78476..3776958a 100644 --- a/src/libsysprof/binfile.h +++ b/src/libsysprof/binfile.h @@ -32,13 +32,13 @@ typedef struct bin_symbol_t bin_symbol_t; /* Binary File */ -bin_file_t * bin_file_new (const char *filename); +bin_file_t *bin_file_new (const char *filename); void bin_file_free (bin_file_t *bin_file); const bin_symbol_t *bin_file_lookup_symbol (bin_file_t *bin_file, gulong address); gboolean bin_file_check_inode (bin_file_t *bin_file, ino_t inode); -const char * bin_symbol_get_name (bin_file_t *bin_file, +const char *bin_symbol_get_name (bin_file_t *bin_file, const bin_symbol_t *symbol); gulong bin_symbol_get_address (bin_file_t *bin_file, const bin_symbol_t *symbol); diff --git a/src/libsysprof/demangle.h b/src/libsysprof/demangle.h index 7a005863..26d28fdc 100644 --- a/src/libsysprof/demangle.h +++ b/src/libsysprof/demangle.h @@ -22,6 +22,7 @@ G_BEGIN_DECLS +G_GNUC_INTERNAL gchar *sysprof_cplus_demangle (const gchar *name); G_END_DECLS diff --git a/src/libsysprof/elfparser.h b/src/libsysprof/elfparser.h index 17986e7f..b22cc38e 100644 --- a/src/libsysprof/elfparser.h +++ b/src/libsysprof/elfparser.h @@ -15,18 +15,19 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include typedef struct ElfSym ElfSym; typedef struct ElfParser ElfParser; -ElfParser * elf_parser_new_from_data (const guchar *data, - gsize length); -ElfParser * elf_parser_new (const char *filename, - GError **err); +ElfParser *elf_parser_new_from_data (const guchar *data, + gsize length); +ElfParser *elf_parser_new (const char *filename, + GError **err); void elf_parser_free (ElfParser *parser); -const char * elf_parser_get_debug_link (ElfParser *parser, - guint32 *crc32); +const char *elf_parser_get_debug_link (ElfParser *parser, + guint32 *crc32); const gchar *elf_parser_get_build_id (ElfParser *parser); const guchar *elf_parser_get_eh_frame (ElfParser *parser); const guchar *elf_parser_get_debug_frame (ElfParser *parser); @@ -44,13 +45,14 @@ gulong elf_parser_get_text_offset (ElfParser *parser); * of the file would have been mapped, so a - (m - o) is the position * in the file of a. */ -const ElfSym *elf_parser_lookup_symbol (ElfParser *parser, - gulong address); -guint32 elf_parser_get_crc32 (ElfParser *parser); -const char * elf_parser_get_sym_name (ElfParser *parser, - const ElfSym *sym); -gulong elf_parser_get_sym_address (ElfParser *parser, - const ElfSym *sym); -gboolean elf_parser_owns_symbol (ElfParser *parser, - const ElfSym *sym); -char * elf_demangle (const char *name); +const ElfSym *elf_parser_lookup_symbol (ElfParser *parser, + gulong address); +guint32 elf_parser_get_crc32 (ElfParser *parser); +const char *elf_parser_get_sym_name (ElfParser *parser, + const ElfSym *sym); +gulong elf_parser_get_sym_address (ElfParser *parser, + const ElfSym *sym); +gboolean elf_parser_owns_symbol (ElfParser *parser, + const ElfSym *sym); +char *elf_demangle (const char *name); + diff --git a/src/libsysprof/meson.build b/src/libsysprof/meson.build index 5ffcbee0..740f89c4 100644 --- a/src/libsysprof/meson.build +++ b/src/libsysprof/meson.build @@ -48,7 +48,6 @@ libsysprof_private_sources = [ 'binfile.c', 'demangle.cpp', 'elfparser.c', - 'sysprof-source-util.c', 'sysprof-line-reader.c', ] diff --git a/src/libsysprof/sysprof-callgraph-profile.h b/src/libsysprof/sysprof-callgraph-profile.h index 1d8a2a97..0674eff8 100644 --- a/src/libsysprof/sysprof-callgraph-profile.h +++ b/src/libsysprof/sysprof-callgraph-profile.h @@ -41,9 +41,9 @@ SysprofProfile *sysprof_callgraph_profile_new (void); SYSPROF_AVAILABLE_IN_ALL SysprofProfile *sysprof_callgraph_profile_new_with_selection (SysprofSelection *selection); SYSPROF_AVAILABLE_IN_ALL -gpointer sysprof_callgraph_profile_get_stash (SysprofCallgraphProfile *self); +gpointer sysprof_callgraph_profile_get_stash (SysprofCallgraphProfile *self); SYSPROF_AVAILABLE_IN_ALL -GQuark sysprof_callgraph_profile_get_tag (SysprofCallgraphProfile *self, - const gchar *symbol); +GQuark sysprof_callgraph_profile_get_tag (SysprofCallgraphProfile *self, + const gchar *symbol); G_END_DECLS diff --git a/src/libsysprof/sysprof-elf-symbol-resolver.h b/src/libsysprof/sysprof-elf-symbol-resolver.h index 3a108f67..ba3c55d1 100644 --- a/src/libsysprof/sysprof-elf-symbol-resolver.h +++ b/src/libsysprof/sysprof-elf-symbol-resolver.h @@ -24,9 +24,8 @@ # error "Only can be included directly." #endif -#include "sysprof-version-macros.h" - #include "sysprof-symbol-resolver.h" +#include "sysprof-version-macros.h" G_BEGIN_DECLS diff --git a/src/libsysprof/sysprof-gjs-source.h b/src/libsysprof/sysprof-gjs-source.h index 1f12a6fe..741407aa 100644 --- a/src/libsysprof/sysprof-gjs-source.h +++ b/src/libsysprof/sysprof-gjs-source.h @@ -30,8 +30,10 @@ G_BEGIN_DECLS #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) +SYSPROF_AVAILABLE_IN_ALL SysprofSource *sysprof_gjs_source_new (void); G_END_DECLS diff --git a/src/libsysprof/sysprof-hostinfo-source.h b/src/libsysprof/sysprof-hostinfo-source.h index ebfd987d..09d21d61 100644 --- a/src/libsysprof/sysprof-hostinfo-source.h +++ b/src/libsysprof/sysprof-hostinfo-source.h @@ -24,8 +24,6 @@ # error "Only can be included directly." #endif -#include "sysprof-version-macros.h" - #include "sysprof-source.h" G_BEGIN_DECLS diff --git a/src/libsysprof/sysprof-jitmap-symbol-resolver.h b/src/libsysprof/sysprof-jitmap-symbol-resolver.h index 355c4398..0d366194 100644 --- a/src/libsysprof/sysprof-jitmap-symbol-resolver.h +++ b/src/libsysprof/sysprof-jitmap-symbol-resolver.h @@ -32,6 +32,7 @@ G_BEGIN_DECLS 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); G_END_DECLS diff --git a/src/libsysprof/sysprof-kallsyms.h b/src/libsysprof/sysprof-kallsyms.h index 2a7bb5e2..5a57c2d5 100644 --- a/src/libsysprof/sysprof-kallsyms.h +++ b/src/libsysprof/sysprof-kallsyms.h @@ -31,14 +31,14 @@ G_BEGIN_DECLS typedef struct _SysprofKallsyms SysprofKallsyms; SYSPROF_AVAILABLE_IN_ALL -SysprofKallsyms *sysprof_kallsyms_new (const gchar *path); +SysprofKallsyms *sysprof_kallsyms_new (const gchar *path); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_kallsyms_next (SysprofKallsyms *self, - const gchar **name, - guint64 *address, - guint8 *type); +gboolean sysprof_kallsyms_next (SysprofKallsyms *self, + const gchar **name, + guint64 *address, + guint8 *type); SYSPROF_AVAILABLE_IN_ALL -void sysprof_kallsyms_free (SysprofKallsyms *self); +void sysprof_kallsyms_free (SysprofKallsyms *self); G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofKallsyms, sysprof_kallsyms_free) diff --git a/src/libsysprof/sysprof-kernel-symbol-resolver.h b/src/libsysprof/sysprof-kernel-symbol-resolver.h index df4fd485..563e26f0 100644 --- a/src/libsysprof/sysprof-kernel-symbol-resolver.h +++ b/src/libsysprof/sysprof-kernel-symbol-resolver.h @@ -32,6 +32,7 @@ G_BEGIN_DECLS 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); G_END_DECLS diff --git a/src/libsysprof/sysprof-kernel-symbol.h b/src/libsysprof/sysprof-kernel-symbol.h index 6856e909..af9e7ca1 100644 --- a/src/libsysprof/sysprof-kernel-symbol.h +++ b/src/libsysprof/sysprof-kernel-symbol.h @@ -34,6 +34,7 @@ typedef struct const gchar *name; } SysprofKernelSymbol; +SYSPROF_AVAILABLE_IN_ALL const SysprofKernelSymbol *sysprof_kernel_symbol_from_address (SysprofCaptureAddress address); G_END_DECLS diff --git a/src/libsysprof/sysprof-line-reader.h b/src/libsysprof/sysprof-line-reader.h index ab632f93..0bb6b303 100644 --- a/src/libsysprof/sysprof-line-reader.h +++ b/src/libsysprof/sysprof-line-reader.h @@ -27,13 +27,13 @@ G_BEGIN_DECLS typedef struct _SysprofLineReader SysprofLineReader; G_GNUC_INTERNAL -SysprofLineReader *sysprof_line_reader_new (const gchar *contents, - gssize length); +SysprofLineReader *sysprof_line_reader_new (const gchar *contents, + gssize length); G_GNUC_INTERNAL -void sysprof_line_reader_free (SysprofLineReader *self); +void sysprof_line_reader_free (SysprofLineReader *self); G_GNUC_INTERNAL -const gchar *sysprof_line_reader_next (SysprofLineReader *self, - gsize *length); +const gchar *sysprof_line_reader_next (SysprofLineReader *self, + gsize *length); G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofLineReader, sysprof_line_reader_free) diff --git a/src/libsysprof/sysprof-local-profiler.h b/src/libsysprof/sysprof-local-profiler.h index a778423d..3cf61328 100644 --- a/src/libsysprof/sysprof-local-profiler.h +++ b/src/libsysprof/sysprof-local-profiler.h @@ -25,7 +25,6 @@ #endif #include "sysprof-profiler.h" - #include "sysprof-version-macros.h" G_BEGIN_DECLS diff --git a/src/libsysprof/sysprof-map-lookaside.h b/src/libsysprof/sysprof-map-lookaside.h index 0e05a563..a8759285 100644 --- a/src/libsysprof/sysprof-map-lookaside.h +++ b/src/libsysprof/sysprof-map-lookaside.h @@ -24,8 +24,6 @@ # error "Only can be included directly." #endif -#include - #include "sysprof-capture-types.h" G_BEGIN_DECLS @@ -41,12 +39,15 @@ typedef struct const gchar *filename; } SysprofMap; +SYSPROF_AVAILABLE_IN_ALL SysprofMapLookaside *sysprof_map_lookaside_new (void); -void sysprof_map_lookaside_insert (SysprofMapLookaside *self, - const SysprofMap *map); +void sysprof_map_lookaside_insert (SysprofMapLookaside *self, + const SysprofMap *map); +SYSPROF_AVAILABLE_IN_ALL const SysprofMap *sysprof_map_lookaside_lookup (SysprofMapLookaside *self, - SysprofCaptureAddress address); -void sysprof_map_lookaside_free (SysprofMapLookaside *self); + SysprofCaptureAddress address); +SYSPROF_AVAILABLE_IN_ALL +void sysprof_map_lookaside_free (SysprofMapLookaside *self); G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofMapLookaside, sysprof_map_lookaside_free) diff --git a/src/libsysprof/sysprof-memory-source.h b/src/libsysprof/sysprof-memory-source.h index 5c33dbc2..8e70e45a 100644 --- a/src/libsysprof/sysprof-memory-source.h +++ b/src/libsysprof/sysprof-memory-source.h @@ -24,9 +24,8 @@ # error "Only can be included directly." #endif -#include "sysprof-version-macros.h" - #include "sysprof-source.h" +#include "sysprof-version-macros.h" G_BEGIN_DECLS diff --git a/src/libsysprof/sysprof-perf-counter.h b/src/libsysprof/sysprof-perf-counter.h index 88376492..d026308f 100644 --- a/src/libsysprof/sysprof-perf-counter.h +++ b/src/libsysprof/sysprof-perf-counter.h @@ -125,33 +125,32 @@ typedef void (*SysprofPerfCounterCallback) (SysprofPerfCounterEvent *event, guint cpu, gpointer user_data); -void sysprof_perf_counter_authorize_async (GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean sysprof_perf_counter_authorize_finish (GAsyncResult *result, - GError **error); - -GType sysprof_perf_counter_get_type (void); -SysprofPerfCounter *sysprof_perf_counter_new (GMainContext *context); -void sysprof_perf_counter_set_callback (SysprofPerfCounter *self, - SysprofPerfCounterCallback callback, - gpointer callback_data, - GDestroyNotify callback_data_destroy); -void sysprof_perf_counter_add_pid (SysprofPerfCounter *self, - GPid pid); -gint sysprof_perf_counter_open (SysprofPerfCounter *self, - struct perf_event_attr *attr, - GPid pid, - gint cpu, - gint group_fd, - gulong flags); -void sysprof_perf_counter_take_fd (SysprofPerfCounter *self, - int fd); -void sysprof_perf_counter_enable (SysprofPerfCounter *self); -void sysprof_perf_counter_disable (SysprofPerfCounter *self); -void sysprof_perf_counter_close (SysprofPerfCounter *self, - gint fd); -SysprofPerfCounter *sysprof_perf_counter_ref (SysprofPerfCounter *self); -void sysprof_perf_counter_unref (SysprofPerfCounter *self); +void sysprof_perf_counter_authorize_async (GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean sysprof_perf_counter_authorize_finish (GAsyncResult *result, + GError **error); +GType sysprof_perf_counter_get_type (void); +SysprofPerfCounter *sysprof_perf_counter_new (GMainContext *context); +void sysprof_perf_counter_set_callback (SysprofPerfCounter *self, + SysprofPerfCounterCallback callback, + gpointer callback_data, + GDestroyNotify callback_data_destroy); +void sysprof_perf_counter_add_pid (SysprofPerfCounter *self, + GPid pid); +gint sysprof_perf_counter_open (SysprofPerfCounter *self, + struct perf_event_attr *attr, + GPid pid, + gint cpu, + gint group_fd, + gulong flags); +void sysprof_perf_counter_take_fd (SysprofPerfCounter *self, + int fd); +void sysprof_perf_counter_enable (SysprofPerfCounter *self); +void sysprof_perf_counter_disable (SysprofPerfCounter *self); +void sysprof_perf_counter_close (SysprofPerfCounter *self, + gint fd); +SysprofPerfCounter *sysprof_perf_counter_ref (SysprofPerfCounter *self); +void sysprof_perf_counter_unref (SysprofPerfCounter *self); G_END_DECLS diff --git a/src/libsysprof/sysprof-perf-source.h b/src/libsysprof/sysprof-perf-source.h index a69f6317..c6fec8f5 100644 --- a/src/libsysprof/sysprof-perf-source.h +++ b/src/libsysprof/sysprof-perf-source.h @@ -24,9 +24,8 @@ # error "Only can be included directly." #endif -#include "sysprof-version-macros.h" - #include "sysprof-source.h" +#include "sysprof-version-macros.h" G_BEGIN_DECLS @@ -38,7 +37,7 @@ G_DECLARE_FINAL_TYPE (SysprofPerfSource, sysprof_perf_source, SYSPROF, PERF_SOUR SYSPROF_AVAILABLE_IN_ALL SysprofSource *sysprof_perf_source_new (void); SYSPROF_AVAILABLE_IN_ALL -void sysprof_perf_source_set_target_pid (SysprofPerfSource *self, - GPid pid); +void sysprof_perf_source_set_target_pid (SysprofPerfSource *self, + GPid pid); G_END_DECLS diff --git a/src/libsysprof/sysprof-proc-source.h b/src/libsysprof/sysprof-proc-source.h index 743cf27f..693769cb 100644 --- a/src/libsysprof/sysprof-proc-source.h +++ b/src/libsysprof/sysprof-proc-source.h @@ -38,7 +38,7 @@ G_DECLARE_FINAL_TYPE (SysprofProcSource, sysprof_proc_source, SYSPROF, PROC_SOUR SYSPROF_AVAILABLE_IN_ALL SysprofSource *sysprof_proc_source_new (void); SYSPROF_AVAILABLE_IN_ALL -gchar *sysprof_proc_source_get_command_line (GPid pid, - gboolean *is_kernel); +gchar *sysprof_proc_source_get_command_line (GPid pid, + gboolean *is_kernel); G_END_DECLS diff --git a/src/libsysprof/sysprof-process-model-item.h b/src/libsysprof/sysprof-process-model-item.h index 0e8a0960..5a175ae1 100644 --- a/src/libsysprof/sysprof-process-model-item.h +++ b/src/libsysprof/sysprof-process-model-item.h @@ -36,19 +36,19 @@ SYSPROF_AVAILABLE_IN_ALL G_DECLARE_FINAL_TYPE (SysprofProcessModelItem, sysprof_process_model_item, SYSPROF, PROCESS_MODEL_ITEM, GObject) SYSPROF_AVAILABLE_IN_ALL -SysprofProcessModelItem *sysprof_process_model_item_new (GPid pid); +SysprofProcessModelItem *sysprof_process_model_item_new (GPid pid); SYSPROF_AVAILABLE_IN_ALL -guint sysprof_process_model_item_hash (SysprofProcessModelItem *self); +guint sysprof_process_model_item_hash (SysprofProcessModelItem *self); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_process_model_item_equal (SysprofProcessModelItem *self, - SysprofProcessModelItem *other); +gboolean sysprof_process_model_item_equal (SysprofProcessModelItem *self, + SysprofProcessModelItem *other); SYSPROF_AVAILABLE_IN_ALL -GPid sysprof_process_model_item_get_pid (SysprofProcessModelItem *self); +GPid sysprof_process_model_item_get_pid (SysprofProcessModelItem *self); SYSPROF_AVAILABLE_IN_ALL -const gchar *sysprof_process_model_item_get_command_line (SysprofProcessModelItem *self); +const gchar *sysprof_process_model_item_get_command_line (SysprofProcessModelItem *self); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_process_model_item_is_kernel (SysprofProcessModelItem *self); +gboolean sysprof_process_model_item_is_kernel (SysprofProcessModelItem *self); SYSPROF_AVAILABLE_IN_ALL -const gchar * const *sysprof_process_model_item_get_argv (SysprofProcessModelItem *self); +const gchar * const *sysprof_process_model_item_get_argv (SysprofProcessModelItem *self); G_END_DECLS diff --git a/src/libsysprof/sysprof-process-model.h b/src/libsysprof/sysprof-process-model.h index 040e3a19..2084e601 100644 --- a/src/libsysprof/sysprof-process-model.h +++ b/src/libsysprof/sysprof-process-model.h @@ -38,8 +38,8 @@ G_DECLARE_FINAL_TYPE (SysprofProcessModel, sysprof_process_model, SYSPROF, PROCE SYSPROF_AVAILABLE_IN_ALL SysprofProcessModel *sysprof_process_model_new (void); SYSPROF_AVAILABLE_IN_ALL -void sysprof_process_model_reload (SysprofProcessModel *self); +void sysprof_process_model_reload (SysprofProcessModel *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_process_model_queue_reload (SysprofProcessModel *self); +void sysprof_process_model_queue_reload (SysprofProcessModel *self); G_END_DECLS diff --git a/src/libsysprof/sysprof-profile.h b/src/libsysprof/sysprof-profile.h index a924d82e..34b1006a 100644 --- a/src/libsysprof/sysprof-profile.h +++ b/src/libsysprof/sysprof-profile.h @@ -26,9 +26,8 @@ #include -#include "sysprof-version-macros.h" - #include "sysprof-capture-reader.h" +#include "sysprof-version-macros.h" G_BEGIN_DECLS @@ -53,16 +52,16 @@ struct _SysprofProfileInterface }; SYSPROF_AVAILABLE_IN_ALL -void sysprof_profile_set_reader (SysprofProfile *self, - SysprofCaptureReader *reader); +void sysprof_profile_set_reader (SysprofProfile *self, + SysprofCaptureReader *reader); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profile_generate (SysprofProfile *self, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); +void sysprof_profile_generate (SysprofProfile *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_profile_generate_finish (SysprofProfile *self, - GAsyncResult *result, - GError **error); +gboolean sysprof_profile_generate_finish (SysprofProfile *self, + GAsyncResult *result, + GError **error); G_END_DECLS diff --git a/src/libsysprof/sysprof-profiler.h b/src/libsysprof/sysprof-profiler.h index 42193eb8..df9291e2 100644 --- a/src/libsysprof/sysprof-profiler.h +++ b/src/libsysprof/sysprof-profiler.h @@ -132,57 +132,57 @@ struct _SysprofProfilerInterface }; SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_emit_failed (SysprofProfiler *self, - const GError *error); +void sysprof_profiler_emit_failed (SysprofProfiler *self, + const GError *error); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_emit_stopped (SysprofProfiler *self); +void sysprof_profiler_emit_stopped (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -gdouble sysprof_profiler_get_elapsed (SysprofProfiler *self); +gdouble sysprof_profiler_get_elapsed (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_profiler_get_is_mutable (SysprofProfiler *self); +gboolean sysprof_profiler_get_is_mutable (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_profiler_get_spawn_inherit_environ (SysprofProfiler *self); +gboolean sysprof_profiler_get_spawn_inherit_environ (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_set_spawn_inherit_environ (SysprofProfiler *self, - gboolean spawn_inherit_environ); +void sysprof_profiler_set_spawn_inherit_environ (SysprofProfiler *self, + gboolean spawn_inherit_environ); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_profiler_get_whole_system (SysprofProfiler *self); +gboolean sysprof_profiler_get_whole_system (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_set_whole_system (SysprofProfiler *self, - gboolean whole_system); +void sysprof_profiler_set_whole_system (SysprofProfiler *self, + gboolean whole_system); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_profiler_get_spawn (SysprofProfiler *self); +gboolean sysprof_profiler_get_spawn (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_set_spawn (SysprofProfiler *self, - gboolean spawn); +void sysprof_profiler_set_spawn (SysprofProfiler *self, + gboolean spawn); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_set_spawn_argv (SysprofProfiler *self, - const gchar * const *spawn_argv); +void sysprof_profiler_set_spawn_argv (SysprofProfiler *self, + const gchar * const *spawn_argv); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_set_spawn_env (SysprofProfiler *self, - const gchar * const *spawn_env); +void sysprof_profiler_set_spawn_env (SysprofProfiler *self, + const gchar * const *spawn_env); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_add_source (SysprofProfiler *self, - SysprofSource *source); +void sysprof_profiler_add_source (SysprofProfiler *self, + SysprofSource *source); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_set_writer (SysprofProfiler *self, - SysprofCaptureWriter *writer); +void sysprof_profiler_set_writer (SysprofProfiler *self, + SysprofCaptureWriter *writer); SYSPROF_AVAILABLE_IN_ALL -SysprofCaptureWriter *sysprof_profiler_get_writer (SysprofProfiler *self); +SysprofCaptureWriter *sysprof_profiler_get_writer (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_profiler_get_is_running (SysprofProfiler *self); +gboolean sysprof_profiler_get_is_running (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_start (SysprofProfiler *self); +void sysprof_profiler_start (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_stop (SysprofProfiler *self); +void sysprof_profiler_stop (SysprofProfiler *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_add_pid (SysprofProfiler *self, - GPid pid); +void sysprof_profiler_add_pid (SysprofProfiler *self, + GPid pid); SYSPROF_AVAILABLE_IN_ALL -void sysprof_profiler_remove_pid (SysprofProfiler *self, - GPid pid); +void sysprof_profiler_remove_pid (SysprofProfiler *self, + GPid pid); SYSPROF_AVAILABLE_IN_ALL -const GPid *sysprof_profiler_get_pids (SysprofProfiler *self, - guint *n_pids); +const GPid *sysprof_profiler_get_pids (SysprofProfiler *self, + guint *n_pids); G_END_DECLS diff --git a/src/libsysprof/sysprof-selection.h b/src/libsysprof/sysprof-selection.h index e623ff9b..58e2f58b 100644 --- a/src/libsysprof/sysprof-selection.h +++ b/src/libsysprof/sysprof-selection.h @@ -41,24 +41,24 @@ typedef void (*SysprofSelectionForeachFunc) (SysprofSelection *self, gpointer user_data); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_selection_get_has_selection (SysprofSelection *self); +gboolean sysprof_selection_get_has_selection (SysprofSelection *self); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_selection_contains (SysprofSelection *self, - gint64 time_at); +gboolean sysprof_selection_contains (SysprofSelection *self, + gint64 time_at); SYSPROF_AVAILABLE_IN_ALL -void sysprof_selection_select_range (SysprofSelection *self, - gint64 begin_time, - gint64 end_time); +void sysprof_selection_select_range (SysprofSelection *self, + gint64 begin_time, + gint64 end_time); SYSPROF_AVAILABLE_IN_ALL -void sysprof_selection_unselect_range (SysprofSelection *self, - gint64 begin, - gint64 end); +void sysprof_selection_unselect_range (SysprofSelection *self, + gint64 begin, + gint64 end); SYSPROF_AVAILABLE_IN_ALL -void sysprof_selection_unselect_all (SysprofSelection *self); +void sysprof_selection_unselect_all (SysprofSelection *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_selection_foreach (SysprofSelection *self, - SysprofSelectionForeachFunc foreach_func, - gpointer user_data); +void sysprof_selection_foreach (SysprofSelection *self, + SysprofSelectionForeachFunc foreach_func, + gpointer user_data); SYSPROF_AVAILABLE_IN_ALL SysprofSelection *sysprof_selection_copy (const SysprofSelection *self); diff --git a/src/libsysprof/sysprof-source-util-private.h b/src/libsysprof/sysprof-source-util-private.h deleted file mode 100644 index 01e108eb..00000000 --- a/src/libsysprof/sysprof-source-util-private.h +++ /dev/null @@ -1,34 +0,0 @@ -/* sysprof-source-util-private.h - * - * Copyright 2019 Christian Hergert - * - * 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 . - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#pragma once - -#include - -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 diff --git a/src/libsysprof/sysprof-source-util.c b/src/libsysprof/sysprof-source-util.c deleted file mode 100644 index 4c377589..00000000 --- a/src/libsysprof/sysprof-source-util.c +++ /dev/null @@ -1,205 +0,0 @@ -/* sysprof-source-util.c - * - * Copyright 2019 Christian Hergert - * - * 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 . - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#include "config.h" - -#include -#include - -#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); - } -} diff --git a/src/libsysprof/sysprof-source.h b/src/libsysprof/sysprof-source.h index 82181382..896d2372 100644 --- a/src/libsysprof/sysprof-source.h +++ b/src/libsysprof/sysprof-source.h @@ -32,6 +32,7 @@ G_BEGIN_DECLS #define SYSPROF_TYPE_SOURCE (sysprof_source_get_type()) +SYSPROF_AVAILABLE_IN_ALL G_DECLARE_INTERFACE (SysprofSource, sysprof_source, SYSPROF, SOURCE, GObject) struct _SysprofSourceInterface @@ -120,17 +121,26 @@ struct _SysprofSourceInterface void (*stop) (SysprofSource *self); }; +SYSPROF_AVAILABLE_IN_ALL void sysprof_source_add_pid (SysprofSource *self, - GPid pid); + GPid pid); +SYSPROF_AVAILABLE_IN_ALL void sysprof_source_emit_ready (SysprofSource *self); +SYSPROF_AVAILABLE_IN_ALL void sysprof_source_emit_finished (SysprofSource *self); +SYSPROF_AVAILABLE_IN_ALL 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); +SYSPROF_AVAILABLE_IN_ALL void sysprof_source_prepare (SysprofSource *self); +SYSPROF_AVAILABLE_IN_ALL void sysprof_source_set_writer (SysprofSource *self, - SysprofCaptureWriter *writer); + SysprofCaptureWriter *writer); +SYSPROF_AVAILABLE_IN_ALL void sysprof_source_start (SysprofSource *self); +SYSPROF_AVAILABLE_IN_ALL void sysprof_source_stop (SysprofSource *self); G_END_DECLS diff --git a/src/libsysprof/sysprof-symbol-dirs.h b/src/libsysprof/sysprof-symbol-dirs.h index 01853614..19a5d49e 100644 --- a/src/libsysprof/sysprof-symbol-dirs.h +++ b/src/libsysprof/sysprof-symbol-dirs.h @@ -36,6 +36,6 @@ SYSPROF_AVAILABLE_IN_ALL void sysprof_symbol_dirs_remove (const gchar *dir); SYSPROF_AVAILABLE_IN_ALL gchar **sysprof_symbol_dirs_get_paths (const gchar *dir, - const gchar *name); + const gchar *name); G_END_DECLS diff --git a/src/libsysprof/sysprof-symbol-resolver.h b/src/libsysprof/sysprof-symbol-resolver.h index d63c8367..d9c05a9b 100644 --- a/src/libsysprof/sysprof-symbol-resolver.h +++ b/src/libsysprof/sysprof-symbol-resolver.h @@ -28,11 +28,13 @@ #include "sysprof-address.h" #include "sysprof-capture-reader.h" +#include "sysprof-version-macros.h" G_BEGIN_DECLS #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) struct _SysprofSymbolResolverInterface @@ -54,18 +56,21 @@ struct _SysprofSymbolResolverInterface GQuark *tag); }; +SYSPROF_AVAILABLE_IN_ALL void sysprof_symbol_resolver_load (SysprofSymbolResolver *self, - SysprofCaptureReader *reader); + SysprofCaptureReader *reader); +SYSPROF_AVAILABLE_IN_ALL gchar *sysprof_symbol_resolver_resolve (SysprofSymbolResolver *self, - guint64 time, - GPid pid, - SysprofCaptureAddress address, - GQuark *tag); + guint64 time, + GPid pid, + SysprofCaptureAddress address, + GQuark *tag); +SYSPROF_AVAILABLE_IN_ALL gchar *sysprof_symbol_resolver_resolve_with_context (SysprofSymbolResolver *self, - guint64 time, - GPid pid, - SysprofAddressContext context, - SysprofCaptureAddress address, - GQuark *tag); + guint64 time, + GPid pid, + SysprofAddressContext context, + SysprofCaptureAddress address, + GQuark *tag); G_END_DECLS