Bug 389027 - Expression evaluator reporting wrong values for bitfields
Summary: Expression evaluator reporting wrong values for bitfields
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: 1.1   Edit
Hardware: Power PC Linux
: P3 normal (vote)
Target Milestone: 1.1   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-07 04:25 EDT by Laura Le Padellec CLA
Modified: 2013-06-05 04:40 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laura Le Padellec CLA 2012-09-07 04:25:19 EDT
The TCF agent expression evaluator is reporting the wrong values for bitfields. The following C code is used:

struct g_struct {
        int a_int;
        short a_short;
        long a_long;
        char *a_string;
        unsigned a_bit:1;
        unsigned a_nibble:4;
        unsigned some_bits:9;
        unsigned many_bits:30;
        float a_float;
        struct g_struct_2 *a_struct;
} g_struct = {
        G_STRUCT_A_INT,
        G_STRUCT_A_SHORT,
        G_STRUCT_A_LONG,
        G_STRUCT_A_STRING,
        G_STRUCT_A_BIT,
        G_STRUCT_A_NIBBLE,
        G_STRUCT_SOME_BITS,
        G_STRUCT_MANY_BITS,
        G_STRUCT_A_FLOAT,
        &g_struct_2
};

Where G_STRUCT_XXX is declared in a separate header file as:
#define G_STRUCT_A_BIT              1
#define G_STRUCT_A_NIBBLE           3
#define G_STRUCT_SOME_BITS        129
#define G_STRUCT_MANY_BITS  987654321

The following calls are made to the TCF agent:
    expect_value(debugger, cpu, frame, "g_struct.a_bit", iv.G_STRUCT_A_BIT)
    expect_value(debugger, cpu, frame, "g_struct.a_nibble",
                 iv.G_STRUCT_A_NIBBLE)
    expect_value(debugger, cpu, frame, "g_struct.some_bits",
                 iv.G_STRUCT_SOME_BITS)
    expect_value(debugger, cpu, frame, "g_struct.many_bits",
                 iv.G_STRUCT_MANY_BITS)

We would expect the value for g_struct.a_bit to be "1" however the value reported is : 2583953408
Comment 1 Eugene Tarassov CLA 2012-09-08 16:19:37 EDT
I have committed a fix.
Thanks!