libsysprof-capture: Add SysprofCaptureJitmapIter to replace GHashTable

Change `sysprof_capture_reader_read_jitmap()` to return a `const
SysprofCaptureJitmap *` (like the other `read` functions), and add a new
`SysprofCaptureJitmapIter` type to allow easy iteration over the jitmap.

This allows a use of `GHashTable` to be removed from the API. It breaks
the libsysprof-capture API and ABI.

All the callers iterate over the jitmap rather than looking up elements
by key. If that functionality is needed in future, additional API can be
added to allow it on `SysprofCaptureJitmap`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
This commit is contained in:
Philip Withnall
2020-07-02 12:43:15 +01:00
parent 75b69d0a89
commit 6a45f020f7
6 changed files with 99 additions and 39 deletions

View File

@ -115,18 +115,18 @@ main (gint argc,
case SYSPROF_CAPTURE_FRAME_JITMAP:
{
g_autoptr(GHashTable) ret = sysprof_capture_reader_read_jitmap (reader);
GHashTableIter iter;
const SysprofCaptureJitmap *jitmap = sysprof_capture_reader_read_jitmap (reader);
SysprofCaptureJitmapIter iter;
SysprofCaptureAddress addr;
const gchar *str;
if (ret == NULL)
if (jitmap == NULL)
return EXIT_FAILURE;
g_print ("JITMAP:\n");
g_hash_table_iter_init (&iter, ret);
while (g_hash_table_iter_next (&iter, (gpointer *)&addr, (gpointer *)&str))
sysprof_capture_jitmap_iter_init (&iter, jitmap);
while (sysprof_capture_jitmap_iter_next (&iter, &addr, &str))
g_print (" " SYSPROF_CAPTURE_ADDRESS_FORMAT " : %s\n", addr, str);
break;