libsysprof-analyze: introduce SysprofDocumentLoader

and thereby make a bunch of the exposed API on SysprofDocument private.
Instead we'll push some of that to the loader but for now the tests can
keep doing what their doing using the private API.

The goal here is to not expose a SysprofDocument pointer until the document
has been loaded and symbolized via the loader API. Then we can lookup
symbols directly from the document w/o intermediary objects.
This commit is contained in:
Christian Hergert
2023-05-12 15:38:16 -07:00
parent 9f6e16e373
commit 3350ad61eb
12 changed files with 543 additions and 49 deletions

View File

@ -2,7 +2,8 @@
#include <fcntl.h>
#include <sysprof-analyze.h>
#include <sysprof-capture.h>
#include "sysprof-document-private.h"
int
main (int argc,
@ -23,7 +24,7 @@ main (int argc,
filename = argv[1];
if (!(document = sysprof_document_new (filename, &error)))
if (!(document = _sysprof_document_new (filename, &error)))
{
g_printerr ("Failed to load %s: %s\n",
filename, error->message);

View File

@ -20,6 +20,8 @@
#include <sysprof-analyze.h>
#include "sysprof-document-private.h"
int
main (int argc,
char *argv[])
@ -35,7 +37,7 @@ main (int argc,
return 1;
}
if (!(document = sysprof_document_new (argv[1], &error)))
if (!(document = _sysprof_document_new (argv[1], &error)))
{
g_printerr ("Failed to open capture: %s\n", error->message);
return 1;

View File

@ -20,6 +20,8 @@
#include <sysprof-analyze.h>
#include "sysprof-document-private.h"
int
main (int argc,
char *argv[])
@ -35,7 +37,7 @@ main (int argc,
return 1;
}
if (!(document = sysprof_document_new (argv[1], &error)))
if (!(document = _sysprof_document_new (argv[1], &error)))
{
g_printerr ("Failed to open capture: %s\n", error->message);
return 1;

View File

@ -20,6 +20,8 @@
#include <sysprof-analyze.h>
#include "sysprof-document-private.h"
int
main (int argc,
char *argv[])
@ -36,7 +38,7 @@ main (int argc,
return 1;
}
if (!(document = sysprof_document_new (argv[1], &error)))
if (!(document = _sysprof_document_new (argv[1], &error)))
{
g_printerr ("Failed to open capture: %s\n", error->message);
return 1;

View File

@ -2,6 +2,8 @@
#include <sysprof-analyze.h>
#include "sysprof-document-private.h"
static GMainLoop *main_loop;
static void
@ -19,7 +21,7 @@ symbolize_cb (GObject *object,
g_assert (SYSPROF_IS_DOCUMENT (document));
g_assert (G_IS_ASYNC_RESULT (result));
if (!(symbols = sysprof_document_symbolize_finish (document, result, &error)))
if (!(symbols = _sysprof_document_symbolize_finish (document, result, &error)))
g_error ("Failed to symbolize: %s", error->message);
traceables = sysprof_document_list_traceables (document);
@ -88,7 +90,7 @@ main (int argc,
filename = argv[1];
if (!(document = sysprof_document_new (filename, &error)))
if (!(document = _sysprof_document_new (filename, &error)))
{
g_printerr ("Failed to load document: %s\n", error->message);
return 1;
@ -97,11 +99,11 @@ main (int argc,
multi = sysprof_multi_symbolizer_new ();
sysprof_multi_symbolizer_add (multi, sysprof_bundled_symbolizer_new ());
sysprof_document_symbolize_async (document,
SYSPROF_SYMBOLIZER (multi),
NULL,
symbolize_cb,
NULL);
_sysprof_document_symbolize_async (document,
SYSPROF_SYMBOLIZER (multi),
NULL,
symbolize_cb,
NULL);
g_main_loop_run (main_loop);