Fixed bitfield extraction.

This commit is contained in:
Eric Pouech 2005-10-03 11:04:13 +00:00 committed by Alexandre Julliard
parent e577a2a391
commit 4cc0bf2848
1 changed files with 12 additions and 10 deletions

View File

@ -150,18 +150,21 @@ static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue,
types_get_info(type, TI_GET_TYPE, &lvalue->type.id); types_get_info(type, TI_GET_TYPE, &lvalue->type.id);
lvalue->type.module = type->module; lvalue->type.module = type->module;
types_get_info(type, TI_GET_OFFSET, &offset); if (!types_get_info(type, TI_GET_OFFSET, &offset)) return FALSE;
lvalue->addr.Offset += offset;
if (types_get_info(type, TI_GET_BITPOSITION, &bitoffset)) if (types_get_info(type, TI_GET_BITPOSITION, &bitoffset))
{ {
if (!types_get_info(type, TI_GET_LENGTH, &length) || types_get_info(type, TI_GET_LENGTH, &length);
length > sizeof(*tmpbuf)) /* FIXME: this test isn't sufficient, depending on start of bitfield
return FALSE; * (ie a 32 bit field can spread across 5 bytes)
*/
if (length > 8 * sizeof(*tmpbuf)) return FALSE;
lvalue->addr.Offset += bitoffset >> 3;
/* /*
* Bitfield operation. We have to extract the field and store * Bitfield operation. We have to extract the field and store
* it in a temporary buffer so that we get it all right. * it in a temporary buffer so that we get it all right.
*/ */
lvalue->addr.Offset += offset;
if (!memory_read_value(lvalue, sizeof(*tmpbuf), tmpbuf)) return FALSE; if (!memory_read_value(lvalue, sizeof(*tmpbuf), tmpbuf)) return FALSE;
mask = 0xffffffff << length; mask = 0xffffffff << length;
*tmpbuf >>= bitoffset & 7; *tmpbuf >>= bitoffset & 7;
@ -180,14 +183,13 @@ static BOOL types_get_udt_element_lvalue(struct dbg_lvalue* lvalue,
{ {
*tmpbuf |= mask; *tmpbuf |= mask;
} }
return TRUE;
} }
if (types_get_info(type, TI_GET_OFFSET, &offset)) else
{ {
lvalue->addr.Offset += offset; if (!memory_read_value(lvalue, sizeof(*tmpbuf), tmpbuf)) return FALSE;
return TRUE;
} }
return FALSE; return TRUE;
} }
/****************************************************************** /******************************************************************