Skip to content

Commit

Permalink
Fix format generation out of types (#3974)
Browse files Browse the repository at this point in the history
  • Loading branch information
XVilka committed Nov 14, 2023
1 parent 271836a commit 221f4da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions librz/type/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -2977,6 +2977,13 @@ static void type_to_format(const RzTypeDB *typedb, RzStrBuf *buf, RzType *type)
rz_strbuf_append(buf, "?");
} else if (type->identifier.kind == RZ_TYPE_IDENTIFIER_KIND_ENUM) {
rz_strbuf_append(buf, "E");
} else {
RzBaseType *btyp = rz_type_get_base_type(typedb, type);
if (btyp) {
RzStrBuf *fields = rz_strbuf_new("");
base_type_to_format_no_unfold(typedb, btyp, type->identifier.name, buf, fields);
rz_strbuf_free(fields);
}
}
}
} else if (type->kind == RZ_TYPE_KIND_ARRAY) {
Expand Down
7 changes: 7 additions & 0 deletions test/db/cmd/types
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,17 @@ CMDS=<<EOF
td "struct test_struct{int x;int y;};"
ts test_struct
tsd test_struct
td "typedef uint16_t word;"
td "typedef uint32_t dword;"
td "struct test_struct2{word a; word b[5]; word c; word d[10]; dword e;};"
ts test_struct2
tsd test_struct2
EOF
EXPECT=<<EOF
pf dd x y
struct test_struct { int x; int y; };
pf w[5]ww[10]wd a (word)b c (word)d e
struct test_struct2 { word a; word b[5]; word c; word d[10]; dword e; };
EOF
RUN

Expand Down

0 comments on commit 221f4da

Please sign in to comment.