aboutsummaryrefslogtreecommitdiff
path: root/gdb/loongarch-tdep.c
diff options
context:
space:
mode:
authorHui Li <lihui@loongson.cn>2023-02-24 06:47:39 +0800
committerTiezhu Yang <yangtiezhu@loongson.cn>2023-03-02 22:32:20 +0800
commit78c7a5288e2ba8c9fd00ee948d1f20e4decb800c (patch)
tree52c0c53cd4cea741b29becb4b008caa97ba1aaad /gdb/loongarch-tdep.c
parent281309f3c8c692d0246f4437ad3c635fe69dbaf7 (diff)
downloadgdb-78c7a5288e2ba8c9fd00ee948d1f20e4decb800c.zip
gdb-78c7a5288e2ba8c9fd00ee948d1f20e4decb800c.tar.gz
gdb-78c7a5288e2ba8c9fd00ee948d1f20e4decb800c.tar.bz2
gdb: LoongArch: Add support for static data member in struct
As described in C++ reference [1], static data members are not part of objects of a given class type. Modified compute_struct_member () to ignore static data member so that we can get the expected result. loongson@linux:~$ cat test.c #include<stdio.h> struct struct_01 { static unsigned a; float b;}; unsigned struct_01::a = 66; struct struct_01 struct_01_val = { 99.00 }; int check_arg_struct(struct struct_01 arg) { printf("arg.a = %d\n", arg.a); printf("arg.b = %f\n", arg.b); return 0; } int main() { check_arg_struct(struct_01_val); return 0; } loongson@linux:~$ g++ -g test.c -o test++ loongson@linux:~$ gdb test++ Without this patch: ... (gdb) start ... (gdb) p check_arg_struct(struct_01_val) arg.a = 66 arg.b = 0.000000 $1 = 0 With this patch: ... (gdb) start ... (gdb) p check_arg_struct(struct_01_val) arg.a = 66 arg.b = 99.000000 $1 = 0 [1] https://learn.microsoft.com/en-us/cpp/cpp/static-members-cpp?view=msvc-170 Signed-off-by: Hui Li <lihui@loongson.cn> Reviewed-By: Tom Tromey <tom@tromey.com> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Diffstat (limited to 'gdb/loongarch-tdep.c')
-rw-r--r--gdb/loongarch-tdep.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c
index f5ddad0..b380bd7 100644
--- a/gdb/loongarch-tdep.c
+++ b/gdb/loongarch-tdep.c
@@ -520,6 +520,10 @@ compute_struct_member (struct type *type,
{
for (int i = 0; i < type->num_fields (); i++)
{
+ /* Ignore any static fields. */
+ if (field_is_static (&type->field (i)))
+ continue;
+
struct type *field_type = check_typedef (type->field (i).type ());
if (field_type->code () == TYPE_CODE_INT