This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Bit-fields question
- From: "Salman Khilji" <salmankhilji at hotmail dot com>
- To: gdb at sources dot redhat dot com
- Date: Fri, 22 Feb 2002 00:38:27 +0000
- Subject: Bit-fields question
- Bcc:
Suppose I have this statement in the debuggee (target) source code.
*((float*)((void*)(address))) = new_val
<address> is of type long and <new_val> is of type float. This technique is
used in real-time steering of a target application. We can generaralize
this to other data types---we just need to know the address of a symbol and
its type to be able to steer an application at run time. We can then use
TCP/IP to transfer the address to the debuggee's (target's) memory and have
an agent execute the above kind of statement to change the value of a symbol
without having to stop the application.
Now the question is: if you have a structure with bit-fields, how would you
do this? I can't find a portable way of doing this. I have a generic API
that can manipulate bit-fields in an unsigned char array. You just pass int
the bit-position, the bit-size and the value, the API takes care of the
rest. Lets say I have the structure:
struct BITS {
unsigned b1:1;
int b2:4;
};
struct BITS Object;
Now if I do this:
unsigned char * p = (unsigned char*) (&Object);
Then my generic API does not work for p. i.e modifying bits in the
character array does not modify the required bits. This is most certainly
due to byte-swapping and endianness issues.
So if we were to do this for bit-fields, what kind of information would be
necessary to download to the target? I know you would need the address, the
bit-offset and the bit size. But how would the statement (or function) look
like that would perform actually poking into the required address? Any
ideas?? code??
Salman
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.