mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: add listmodel of embedded files
This also indexes the first position of a file by filename so that we can skip items in the capture file. Generally, embedded files are a single frame so that will only be one frame to look at. But even when it is a few frames, they are generally sequential so this vastly reduces how many frames we'll need to look at for files.
This commit is contained in:
@ -13,6 +13,7 @@ libsysprof_analyze_testsuite_c_args = [
|
||||
|
||||
libsysprof_analyze_testsuite = {
|
||||
'test-capture-model' : {'skip': true},
|
||||
'test-list-files' : {'skip': true},
|
||||
'test-symbolize' : {'skip': true},
|
||||
}
|
||||
|
||||
|
||||
55
src/libsysprof-analyze/tests/test-list-files.c
Normal file
55
src/libsysprof-analyze/tests/test-list-files.c
Normal file
@ -0,0 +1,55 @@
|
||||
/* test-list-files.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>
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
g_autoptr(SysprofDocument) document = NULL;
|
||||
g_autoptr(GListModel) files = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
guint n_items;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
g_printerr ("usage: %s CAPTURE_FILE\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(document = sysprof_document_new (argv[1], &error)))
|
||||
{
|
||||
g_printerr ("Failed to open capture: %s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
files = sysprof_document_list_files (document);
|
||||
n_items = g_list_model_get_n_items (files);
|
||||
|
||||
for (guint i = 0; i < n_items; i++)
|
||||
{
|
||||
g_autoptr(SysprofDocumentFile) file = g_list_model_get_item (files, i);
|
||||
|
||||
g_print ("%s\n", sysprof_document_file_get_path (file));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user