rizin/test/db/cmd/cmd_idp
NOT XVilka 92972bcfb2
librz/arch/pdb: wire LF_BITFIELD members to the bitfield width (#6452)
Follow-up to the C bitfield support added in #6439 (#1240, #314): the PDB
type parser dropped struct/union bitfield members because an LF_BITFIELD
member type resolved to NULL in pdb_type_parse(), so "tc"/"ts"/"tp" on a
PDB-loaded type lost every bitfield field.

member_parse() now detects a TpiKind_BITFIELD field type, resolves the
member to the bitfield's underlying integer (base_type) and reports the
bit width (length) via an out-parameter. class_member_parse() and
union_member_parse() store it in RzTypeStructMember.size /
RzTypeUnionMember.size (the bitfield width in bits, 0 if not a bitfield),
matching the convention used by the C and DWARF member paths.

Update the PDB type expectations that previously asserted bitfield_typedef
had no members: db/cmd/cmd_idp (idpij) and db/tools/rz_bin (rz-bin -Pj)
now expect the three resolved "unsigned char" members of minimal.pdb.

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2026-06-07 13:58:54 +08:00

191 lines
3.9 KiB
Text

NAME=idp flags
FILE=bins/pdb/SimplePDB.exe
CMDS=<<EOF
idp bins/pdb/SimplePDB.pdb
fi 1 @ 0x00401000
fi 1 @ 0x00401010
EOF
EXPECT=<<EOF
0x00401000 4096 section..text
0x00401000 0 pdb.SimplePDB.void___cdecl_SomeCoolFunction_void
0x00401010 0 pdb.SimplePDB._main
EOF
RUN
NAME=idp bin state bug (#9441)
FILE=bins/pdb/SimplePDB.exe
CMDS=<<EOF
e asm.bits
idpi bins/pdb/SimplePDB.pdb~SomeCoolFunction
e asm.bits
EOF
EXPECT=<<EOF
32
0x00401000 4366 .text void __cdecl SomeCoolFunction(void)
32
EOF
RUN
NAME=idpij
FILE==
CMDS=idpij bins/pdb/minimal.pdb~{}
EXPECT=<<EOF
[
{
"modules": [
{
"module_name": "* Linker Generated Manifest RES *",
"object_file_name": ""
},
{
"module_name": "C:\\Users\\emuresan\\source\\repos\\minimal\\Release\\main.obj",
"object_file_name": "C:\\Users\\emuresan\\source\\repos\\minimal\\Release\\main.obj"
},
{
"module_name": "* Linker *",
"object_file_name": ""
}
]
},
{
"types": [
{
"type": "structure",
"name": "struct_typedef",
"size": 7,
"members": [
{
"member_type": "char",
"member_name": "a",
"offset": 0
},
{
"member_type": "int16_t",
"member_name": "b",
"offset": 1
},
{
"member_type": "int32_t",
"member_name": "c",
"offset": 3
}
]
},
{
"type": "union",
"name": "type_0x1004",
"size": 4,
"members": [
{
"member_type": "char [4]",
"member_name": "a",
"offset": 0
},
{
"member_type": "int32_t",
"member_name": "b",
"offset": 0
}
]
},
{
"type": "structure",
"name": "unnamed_member_types_typedef",
"size": 8,
"members": [
{
"member_type": "union type_0x1004",
"member_name": "a",
"offset": 0
},
{
"member_type": "int32_t",
"member_name": "b",
"offset": 4
}
]
},
{
"type": "structure",
"name": "bitfield_typedef",
"size": 1,
"members": [
{
"member_type": "unsigned char",
"member_name": "a",
"offset": 0
},
{
"member_type": "unsigned char",
"member_name": "b",
"offset": 0
},
{
"member_type": "unsigned char",
"member_name": "c",
"offset": 0
}
]
},
{
"type": "union",
"name": "union_typedef",
"size": 4,
"members": [
{
"member_type": "char",
"member_name": "a",
"offset": 0
},
{
"member_type": "int16_t",
"member_name": "b",
"offset": 0
},
{
"member_type": "int32_t",
"member_name": "c",
"offset": 0
}
]
}
]
},
{
"gvars": [
{
"address": 12292,
"symtype": 4366,
"section_name": ".data",
"gdata_name": "_uninitialized_global"
},
{
"address": 12288,
"symtype": 4366,
"section_name": ".data",
"gdata_name": "_initialized_global"
},
{
"address": 4096,
"symtype": 4366,
"section_name": ".text",
"gdata_name": "_function"
},
{
"address": 4182,
"symtype": 4366,
"section_name": ".text",
"gdata_name": "_mainCRTStartup"
},
{
"address": 4120,
"symtype": 4366,
"section_name": ".text",
"gdata_name": "_main"
}
]
}
]
EOF
RUN