libsysprof-analyze: add SysprofDocumentJitmap

This adds a specific frame type for the Jitmap frames in the capture files.
You can iterate them without having to bswap as well, which is why this
does not use the SysprofCaptureJitmapIter (which does require bswap'd
frames).
This commit is contained in:
Christian Hergert
2023-05-22 12:18:57 -07:00
parent c7f025d4d3
commit d28080b9ad
9 changed files with 304 additions and 0 deletions

View File

@ -15,6 +15,7 @@ libsysprof_analyze_testsuite = {
'test-capture-model' : {'skip': true},
'test-elf-loader' : {'skip': true},
'test-list-files' : {'skip': true},
'test-list-jitmap' : {'skip': true},
'test-print-file' : {'skip': true},
'test-list-processes' : {'skip': true},
'test-list-address-layout' : {'skip': true},

View File

@ -81,6 +81,9 @@ main (int argc,
sysprof_document_mmap_get_end_address (SYSPROF_DOCUMENT_MMAP (frame)),
sysprof_document_mmap_get_file_offset (SYSPROF_DOCUMENT_MMAP (frame)),
sysprof_document_mmap_get_file (SYSPROF_DOCUMENT_MMAP (frame)));
else if (SYSPROF_IS_DOCUMENT_JITMAP (frame))
g_print (" n_jitmaps=%u",
sysprof_document_jitmap_get_size (SYSPROF_DOCUMENT_JITMAP (frame)));
else if (SYSPROF_IS_DOCUMENT_ALLOCATION (frame))
{
if (sysprof_document_allocation_is_free (SYSPROF_DOCUMENT_ALLOCATION (frame)))

View File

@ -0,0 +1,74 @@
/* test-list-jitmap.c
*
* Copyright 2023 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 <sysprof-analyze.h>
#include "sysprof-document-private.h"
int
main (int argc,
char *argv[])
{
g_autoptr(SysprofDocumentLoader) loader = NULL;
g_autoptr(SysprofDocument) document = NULL;
g_autoptr(GError) error = NULL;
guint n_items;
if (argc < 2)
{
g_printerr ("usage: %s CAPTURE_FILE\n", argv[0]);
return 1;
}
loader = sysprof_document_loader_new (argv[1]);
sysprof_document_loader_set_symbolizer (loader, sysprof_no_symbolizer_get ());
if (!(document = sysprof_document_loader_load (loader, NULL, &error)))
{
g_printerr ("Failed to open capture: %s\n", error->message);
return 1;
}
n_items = g_list_model_get_n_items (G_LIST_MODEL (document));
for (guint i = 0; i < n_items; i++)
{
g_autoptr(SysprofDocumentFrame) frame = g_list_model_get_item ((GListModel *)document, i);
if (SYSPROF_IS_DOCUMENT_JITMAP (frame))
{
SysprofDocumentJitmap *jitmap = SYSPROF_DOCUMENT_JITMAP (frame);
guint size = sysprof_document_jitmap_get_size (jitmap);
for (guint j = 0; j < size; j++)
{
SysprofAddress address;
const char *name;
if (!(name = sysprof_document_jitmap_get_mapping (jitmap, j, &address)))
break;
g_print ("0x%"G_GINT64_MODIFIER"x: %s\n", address, name);
}
}
}
return 0;
}