[sysprof] resolver: extend interface to include address context
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] resolver: extend interface to include address context
- Date: Mon, 29 Jan 2018 06:17:51 +0000 (UTC)
commit df07f6d9152a044977c7c28eb2f9672f53d861fe
Author: Christian Hergert <chergert redhat com>
Date: Sun Jan 28 22:12:27 2018 -0800
resolver: extend interface to include address context
We might need access to the address context when resolving symbols so that
we know if the address range applies to us.
lib/symbols/sp-symbol-resolver.c | 70 +++++++++++++++++++++++++++++++++++++-
lib/symbols/sp-symbol-resolver.h | 41 ++++++++++++++-------
2 files changed, 96 insertions(+), 15 deletions(-)
---
diff --git a/lib/symbols/sp-symbol-resolver.c b/lib/symbols/sp-symbol-resolver.c
index 3dc9605..7847a02 100644
--- a/lib/symbols/sp-symbol-resolver.c
+++ b/lib/symbols/sp-symbol-resolver.c
@@ -20,9 +20,38 @@
G_DEFINE_INTERFACE (SpSymbolResolver, sp_symbol_resolver, G_TYPE_OBJECT)
+static gchar *
+sp_symbol_resolver_real_resolve (SpSymbolResolver *self,
+ guint64 time,
+ GPid pid,
+ SpCaptureAddress address,
+ GQuark *tag)
+{
+ *tag = 0;
+ return NULL;
+}
+
+static gchar *
+sp_symbol_resolver_real_resolve_with_context (SpSymbolResolver *self,
+ guint64 time,
+ GPid pid,
+ SpAddressContext context,
+ SpCaptureAddress address,
+ GQuark *tag)
+{
+ *tag = 0;
+
+ if (SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve)
+ return SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve (self, time, pid, address, tag);
+
+ return NULL;
+}
+
static void
sp_symbol_resolver_default_init (SpSymbolResolverInterface *iface)
{
+ iface->resolve = sp_symbol_resolver_real_resolve;
+ iface->resolve_with_context = sp_symbol_resolver_real_resolve_with_context;
}
void
@@ -68,5 +97,44 @@ sp_symbol_resolver_resolve (SpSymbolResolver *self,
*tag = 0;
- return SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve (self, time, pid, address, tag);
+ if (SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve)
+ return SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve (self, time, pid, address, tag);
+
+ return NULL;
+}
+
+/**
+ * sp_symbol_resolver_resolve_with_context:
+ * @self: A #SpSymbolResolver
+ * @time: The time of the sample
+ * @pid: The process generating the sample
+ * @context: the address context
+ * @address: the sample address
+ * @tag: (out): A tag for the symbol.
+ *
+ * This function is like sp_symbol_resolver_resolve() but allows
+ * access to the address context, which might be necessary to
+ * determine the difference between user space and kernel space
+ * addresses.
+ *
+ * Returns: (nullable) (transfer full): A newly allocated string, or %NULL.
+ */
+gchar *
+sp_symbol_resolver_resolve_with_context (SpSymbolResolver *self,
+ guint64 time,
+ GPid pid,
+ SpAddressContext context,
+ SpCaptureAddress address,
+ GQuark *tag)
+{
+ GQuark dummy;
+
+ g_return_val_if_fail (SP_IS_SYMBOL_RESOLVER (self), NULL);
+
+ if (tag == NULL)
+ tag = &dummy;
+
+ *tag = 0;
+
+ return SP_SYMBOL_RESOLVER_GET_IFACE (self)->resolve_with_context (self, time, pid, context, address, tag);
}
diff --git a/lib/symbols/sp-symbol-resolver.h b/lib/symbols/sp-symbol-resolver.h
index 4ee5ae1..a347685 100644
--- a/lib/symbols/sp-symbol-resolver.h
+++ b/lib/symbols/sp-symbol-resolver.h
@@ -21,6 +21,7 @@
#include <glib-object.h>
+#include "sp-address.h"
#include "capture/sp-capture-reader.h"
G_BEGIN_DECLS
@@ -33,22 +34,34 @@ struct _SpSymbolResolverInterface
{
GTypeInterface parent_interface;
- void (*load) (SpSymbolResolver *self,
- SpCaptureReader *reader);
- gchar *(*resolve) (SpSymbolResolver *self,
- guint64 time,
- GPid pid,
- SpCaptureAddress address,
- GQuark *tag);
+ void (*load) (SpSymbolResolver *self,
+ SpCaptureReader *reader);
+ gchar *(*resolve) (SpSymbolResolver *self,
+ guint64 time,
+ GPid pid,
+ SpCaptureAddress address,
+ GQuark *tag);
+ gchar *(*resolve_with_context) (SpSymbolResolver *self,
+ guint64 time,
+ GPid pid,
+ SpAddressContext context,
+ SpCaptureAddress address,
+ GQuark *tag);
};
-void sp_symbol_resolver_load (SpSymbolResolver *self,
- SpCaptureReader *reader);
-gchar *sp_symbol_resolver_resolve (SpSymbolResolver *self,
- guint64 time,
- GPid pid,
- SpCaptureAddress address,
- GQuark *tag);
+void sp_symbol_resolver_load (SpSymbolResolver *self,
+ SpCaptureReader *reader);
+gchar *sp_symbol_resolver_resolve (SpSymbolResolver *self,
+ guint64 time,
+ GPid pid,
+ SpCaptureAddress address,
+ GQuark *tag);
+gchar *sp_symbol_resolver_resolve_with_context (SpSymbolResolver *self,
+ guint64 time,
+ GPid pid,
+ SpAddressContext context,
+ SpCaptureAddress address,
+ GQuark *tag);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]