Skip to content

Cvdump: Handle LF_BITFIELD #299

@disinvite

Description

@disinvite

When parsing cvdump output, we do not parse bitfield leaves at all. This creates a broken link in the fieldlist structure and so loading a datatype that contains a bitfield (at any level) will raise an exception.

We could treat the bitfield as raw data but we have to determine the memory footprint. If any compilers would allow you to mix bitfields and regular struct members then this will be tricky. (Need to check on this.)

Real world example from CARM95:

typedef struct tCar_controls { // size: 0x4
    int joystick_acc : 8;
    int joystick_dec : 8;
    unsigned int left : 1;        // 0x10000   bit 17
    unsigned int right : 1;       // 0x20000   bit 18
    unsigned int acc : 1;         // 0x40000   bit 19
    unsigned int dec : 1;         // 0x80000   bit 20
    unsigned int brake : 1;       // 0x100000   bit 21
    unsigned int up : 1;          // 0x200000   bit 22
    unsigned int down : 1;        // 0x400000   bit 23
    unsigned int holdw : 1;       // 0x800000   bit 24
    unsigned int backwards : 1;   // 0x1000000   bit 25
    unsigned int change_up : 1;   // 0x2000000   bit 26
    unsigned int change_down : 1; // 0x4000000   bit 27
    unsigned int horn : 1;        // 0x8000000   bit 28
} tCar_controls;
0x16cb : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 8, starting position = 0, Type = T_INT4(0074)

0x16cc : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 8, starting position = 8, Type = T_INT4(0074)

0x16cd : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 16, Type = T_UINT4(0075)

0x16ce : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 17, Type = T_UINT4(0075)

0x16cf : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 18, Type = T_UINT4(0075)

0x16d0 : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 19, Type = T_UINT4(0075)

0x16d1 : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 20, Type = T_UINT4(0075)

0x16d2 : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 21, Type = T_UINT4(0075)

0x16d3 : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 22, Type = T_UINT4(0075)

0x16d4 : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 23, Type = T_UINT4(0075)

0x16d5 : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 24, Type = T_UINT4(0075)

0x16d6 : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 25, Type = T_UINT4(0075)

0x16d7 : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 26, Type = T_UINT4(0075)

0x16d8 : Length = 10, Leaf = 0x1205 LF_BITFIELD
	bits = 1, starting position = 27, Type = T_UINT4(0075)

0x16d9 : Length = 258, Leaf = 0x1203 LF_FIELDLIST
	list[0] = LF_MEMBER, public, type = 0x16CB, offset = 0
		member name = 'joystick_acc'
	list[1] = LF_MEMBER, public, type = 0x16CC, offset = 0
		member name = 'joystick_dec'
	list[2] = LF_MEMBER, public, type = 0x16CD, offset = 0
		member name = 'left'
	list[3] = LF_MEMBER, public, type = 0x16CE, offset = 0
		member name = 'right'
	list[4] = LF_MEMBER, public, type = 0x16CF, offset = 0
		member name = 'acc'
	list[5] = LF_MEMBER, public, type = 0x16D0, offset = 0
		member name = 'dec'
	list[6] = LF_MEMBER, public, type = 0x16D1, offset = 0
		member name = 'brake'
	list[7] = LF_MEMBER, public, type = 0x16D2, offset = 0
		member name = 'up'
	list[8] = LF_MEMBER, public, type = 0x16D3, offset = 0
		member name = 'down'
	list[9] = LF_MEMBER, public, type = 0x16D4, offset = 0
		member name = 'holdw'
	list[10] = LF_MEMBER, public, type = 0x16D5, offset = 0
		member name = 'backwards'
	list[11] = LF_MEMBER, public, type = 0x16D6, offset = 0
		member name = 'change_up'
	list[12] = LF_MEMBER, public, type = 0x16D7, offset = 0
		member name = 'change_down'
	list[13] = LF_MEMBER, public, type = 0x16D8, offset = 0
		member name = 'horn'

0x16da : Length = 34, Leaf = 0x1505 LF_STRUCTURE
	# members = 14,  field list type 0x16d9, 
	Derivation list type 0x0000, VT shape type 0x0000
	Size = 4, class name = tCar_controls, UDT(0x000016da)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions