Skip to content

Commit 640f839

Browse files
committed
Allow empty names for non-struct/union types
In particular, for a typedef to a pointer, the stripped type will have no name (it's a pointer to a type with a name). Allow for that. Followup to 4ba3725
1 parent 4ba3725 commit 640f839

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

server/JsDbg.Gdb/JsDbg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ def FormatType(symbol_type):
119119
# (This is only an issue with clang,
120120
# https://bugs.llvm.org/show_bug.cgi?id=43054)
121121
stripped = symbol_type.strip_typedefs()
122-
if stripped.name:
122+
if stripped.name or (stripped.code != gdb.TYPE_CODE_STRUCT and
123+
stripped.code != gdb.TYPE_CODE_UNION):
123124
t = stripped
124125
else:
125126
t = symbol_type

server/JsDbg.Gdb/testsuite/jsdbg.tests/basic.exp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ expect $gdb_prompt
66
send "run\n"
77
expect $gdb_prompt
88

9+
# Some tests for FormatType
10+
send "python print(JsDbg.FormatType(gdb.lookup_type('IntPointer')))\n"
11+
test "int \\\*" "Test that we strip typedefs from pointer types"
12+
expect $gdb_prompt
13+
14+
# Tests for the IDebugger implementation
915
send "python print(JsDbg.LookupGlobalSymbol('test_program', 'global_var'))\n"
1016
test "{int#$decimal}" "LookupGlobalSymbol"
1117
regexp $decimal $match pointer

server/JsDbg.Gdb/testsuite/test_program.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
int global_var = 42;
22

3+
typedef int* IntPointer;
4+
IntPointer ip;
5+
36
class Base {
47
int base_member_;
58
};

0 commit comments

Comments
 (0)