aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2020-09-17 23:33:42 +0100
committerPedro Alves <pedro@palves.net>2020-09-18 00:07:22 +0100
commita83cdcb636a661fe0070160d58b69a27be9ae079 (patch)
tree2ed94b376e721e836946f828e62372c9d20d58f3 /gdb
parentd4bcee5cccce0ef4acb6f7cb571f439bba07df7f (diff)
downloadgdb-a83cdcb636a661fe0070160d58b69a27be9ae079.zip
gdb-a83cdcb636a661fe0070160d58b69a27be9ae079.tar.gz
gdb-a83cdcb636a661fe0070160d58b69a27be9ae079.tar.bz2
gdb.python/py-nested-maps.exp C++ify
This adjusts gdb.python/py-nested-maps.c to make it buildable as C++ program. key_t is renamed because of: src/gdb/testsuite/gdb.python/py-nested-maps.c:23:8: error: definition of type 'key_t' conflicts with typedef of the same name struct key_t ^ /usr/include/x86_64-linux-gnu/sys/types.h:121:17: note: 'key_t' declared here typedef __key_t key_t; ^ gdb/testsuite/ChangeLog: * gdb.python/py-nested-maps.c (struct key_t): Rename to... (struct my_key_t): ... this. Adjust all references. (struct value_t): Rename to ... (struct my_value_t): ... this. Adjust all references. (create_map, add_map_element, create_map_map) (add_map_map_element): Add casts.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.python/py-nested-maps.c44
2 files changed, 31 insertions, 22 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a5a35af..211132a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,14 @@
2020-09-17 Pedro Alves <pedro@palves.net>
+ * gdb.python/py-nested-maps.c (struct key_t): Rename to...
+ (struct my_key_t): ... this. Adjust all references.
+ (struct value_t): Rename to ...
+ (struct my_value_t): ... this. Adjust all references.
+ (create_map, add_map_element, create_map_map)
+ (add_map_map_element): Add casts.
+
+2020-09-17 Pedro Alves <pedro@palves.net>
+
* gdb.python/py-framefilter-mi.c (funca): Add casts.
* gdb.python/py-framefilter.c.c (funca, func2): Add casts.
diff --git a/gdb/testsuite/gdb.python/py-nested-maps.c b/gdb/testsuite/gdb.python/py-nested-maps.c
index 860b473..46c2089 100644
--- a/gdb/testsuite/gdb.python/py-nested-maps.c
+++ b/gdb/testsuite/gdb.python/py-nested-maps.c
@@ -20,13 +20,13 @@
#define FIXED_MAP_SIZE 10
-struct key_t
+struct my_key_t
{
int a;
int b;
};
-struct value_t
+struct my_value_t
{
int x;
int y;
@@ -37,8 +37,8 @@ struct map_t
{
const char *name;
int length;
- struct key_t *keys;
- struct value_t *values;
+ struct my_key_t *keys;
+ struct my_value_t *values;
/* This field is used only by the pretty printer. */
int show_header;
@@ -56,7 +56,7 @@ struct map_map_t
struct map_t *
create_map (const char *name)
{
- struct map_t *m = malloc (sizeof (struct map_t));
+ struct map_t *m = (struct map_t *) malloc (sizeof (struct map_t));
m->name = strdup (name);
m->length = 0;
m->keys = NULL;
@@ -66,12 +66,12 @@ create_map (const char *name)
}
void
-add_map_element (struct map_t *m, struct key_t k, struct value_t v)
+add_map_element (struct map_t *m, struct my_key_t k, struct my_value_t v)
{
if (m->length == 0)
{
- m->keys = malloc (sizeof (struct key_t) * FIXED_MAP_SIZE);
- m->values = malloc (sizeof (struct value_t) * FIXED_MAP_SIZE);
+ m->keys = (struct my_key_t *) malloc (sizeof (struct my_key_t) * FIXED_MAP_SIZE);
+ m->values = (struct my_value_t *) malloc (sizeof (struct my_value_t) * FIXED_MAP_SIZE);
}
m->keys[m->length] = k;
@@ -82,7 +82,7 @@ add_map_element (struct map_t *m, struct key_t k, struct value_t v)
struct map_map_t *
create_map_map (void)
{
- struct map_map_t *mm = malloc (sizeof (struct map_map_t));
+ struct map_map_t *mm = (struct map_map_t *) malloc (sizeof (struct map_map_t));
mm->length = 0;
mm->values = NULL;
mm->show_header = 0;
@@ -93,7 +93,7 @@ void
add_map_map_element (struct map_map_t *mm, struct map_t *map)
{
if (mm->length == 0)
- mm->values = malloc (sizeof (struct map_t *) * FIXED_MAP_SIZE);
+ mm->values = (struct map_t **) malloc (sizeof (struct map_t *) * FIXED_MAP_SIZE);
mm->values[mm->length] = map;
mm->length++;
@@ -103,18 +103,18 @@ int
main (void)
{
struct map_t *m1 = create_map ("m1");
- struct key_t k1 = {3, 4};
- struct key_t k2 = {4, 5};
- struct key_t k3 = {5, 6};
- struct key_t k4 = {6, 7};
- struct key_t k5 = {7, 8};
- struct key_t k6 = {8, 9};
- struct value_t v1 = {0, 1, 2};
- struct value_t v2 = {3, 4, 5};
- struct value_t v3 = {6, 7, 8};
- struct value_t v4 = {9, 0, 1};
- struct value_t v5 = {2, 3, 4};
- struct value_t v6 = {5, 6, 7};
+ struct my_key_t k1 = {3, 4};
+ struct my_key_t k2 = {4, 5};
+ struct my_key_t k3 = {5, 6};
+ struct my_key_t k4 = {6, 7};
+ struct my_key_t k5 = {7, 8};
+ struct my_key_t k6 = {8, 9};
+ struct my_value_t v1 = {0, 1, 2};
+ struct my_value_t v2 = {3, 4, 5};
+ struct my_value_t v3 = {6, 7, 8};
+ struct my_value_t v4 = {9, 0, 1};
+ struct my_value_t v5 = {2, 3, 4};
+ struct my_value_t v6 = {5, 6, 7};
add_map_element (m1, k1, v1);
add_map_element (m1, k2, v2);
add_map_element (m1, k3, v3);