| 1 |
/* test-maps-parser.c |
| 2 |
* |
| 3 |
* Copyright 2023 Christian Hergert <[email protected]> |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
* |
| 18 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "config.h" |
| 22 |
|
| 23 |
#include "sysprof-maps-parser-private.h" |
| 24 |
|
| 25 |
#define ADDR_FORMAT "0x%"G_GINT64_MODIFIER"x" |
| 26 |
|
| 27 |
int |
| 28 |
main (int argc, |
| 29 |
char *argv[]) |
| 30 |
{ |
| 31 |
g_autoptr(GError) error = NULL; |
| 32 |
g_autofree char *contents = NULL; |
| 33 |
SysprofMapsParser parser; |
| 34 |
guint64 begin, end, offset, inode; |
| 35 |
char *file; |
| 36 |
gsize len; |
| 37 |
|
| 38 |
g_assert_cmpint (argc, >, 1); |
| 39 |
g_file_get_contents (argv[1], &contents, &len, &error); |
| 40 |
g_assert_no_error (error); |
| 41 |
|
| 42 |
sysprof_maps_parser_init (&parser, contents, len); |
| 43 |
while (sysprof_maps_parser_next (&parser, &begin, &end, &offset, &inode, &file)) |
| 44 |
{ |
| 45 |
g_print (ADDR_FORMAT" - "ADDR_FORMAT" "ADDR_FORMAT" %"G_GUINT64_FORMAT" %s\n", |
| 46 |
begin, end, offset, inode, file); |
| 47 |
g_free (file); |
| 48 |
} |
| 49 |
|
| 50 |
return 0; |
| 51 |
} |