Commit 4304aee8 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Fixed floating point data printing and made basic types reading more

robust.
parent e7b84a9b
...@@ -340,9 +340,10 @@ DEBUG_InitTypes(void) ...@@ -340,9 +340,10 @@ DEBUG_InitTypes(void)
} }
long long int long long int
DEBUG_GetExprValue(const DBG_VALUE *_value, char ** format) DEBUG_GetExprValue(const DBG_VALUE* _value, char** format)
{ {
unsigned int rtn; long long int rtn;
unsigned int rtn2;
struct datatype * type2 = NULL; struct datatype * type2 = NULL;
struct en_values * e; struct en_values * e;
char * def_format = "0x%x"; char * def_format = "0x%x";
...@@ -350,18 +351,21 @@ DEBUG_GetExprValue(const DBG_VALUE *_value, char ** format) ...@@ -350,18 +351,21 @@ DEBUG_GetExprValue(const DBG_VALUE *_value, char ** format)
assert(_value->cookie == DV_TARGET || _value->cookie == DV_HOST); assert(_value->cookie == DV_TARGET || _value->cookie == DV_HOST);
rtn = 0; rtn = 0; rtn2 = 0;
/* FIXME? I don't quite get this... /* FIXME? I don't quite get this...
* if this is wrong, value.addr shall be linearized * if this is wrong, value.addr shall be linearized
*/ */
value.addr.seg = 0; value.addr.seg = 0;
assert(value.type != NULL); assert(value.type != NULL);
switch(value.type->type) switch (value.type->type) {
{
case DT_BASIC: case DT_BASIC:
rtn = 0; if (value.type->un.basic.basic_size > sizeof(rtn)) {
DEBUG_Printf(DBG_CHN_ERR, "Size too large (%d)\n",
value.type->un.basic.basic_size);
return 0;
}
/* FIXME: following code implies i386 byte ordering */ /* FIXME: following code implies i386 byte ordering */
if (_value->cookie == DV_TARGET) { if (_value->cookie == DV_TARGET) {
if (!DEBUG_READ_MEM_VERBOSE((void*)value.addr.off, &rtn, if (!DEBUG_READ_MEM_VERBOSE((void*)value.addr.off, &rtn,
...@@ -371,86 +375,75 @@ DEBUG_GetExprValue(const DBG_VALUE *_value, char ** format) ...@@ -371,86 +375,75 @@ DEBUG_GetExprValue(const DBG_VALUE *_value, char ** format)
memcpy(&rtn, (void*)value.addr.off, value.type->un.basic.basic_size); memcpy(&rtn, (void*)value.addr.off, value.type->un.basic.basic_size);
} }
if( (value.type->un.basic.b_signed) if ( (value.type->un.basic.b_signed)
&& ((value.type->un.basic.basic_size & 3) != 0) && ((value.type->un.basic.basic_size & 3) != 0)
&& ((rtn >> (value.type->un.basic.basic_size * 8 - 1)) != 0) ) && ((rtn >> (value.type->un.basic.basic_size * 8 - 1)) != 0)) {
{
rtn = rtn | ((-1) << (value.type->un.basic.basic_size * 8)); rtn = rtn | ((-1) << (value.type->un.basic.basic_size * 8));
} }
if( value.type->un.basic.output_format != NULL ) if (value.type->un.basic.output_format != NULL) {
{
def_format = value.type->un.basic.output_format; def_format = value.type->un.basic.output_format;
} }
/* /*
* Check for single character prints that are out of range. * Check for single character prints that are out of range.
*/ */
if( value.type->un.basic.basic_size == 1 if ( value.type->un.basic.basic_size == 1
&& strcmp(def_format, "'%c'") == 0 && strcmp(def_format, "'%c'") == 0
&& ((rtn < 0x20) || (rtn > 0x80)) ) && ((rtn < 0x20) || (rtn > 0x80))) {
{
def_format = "%d"; def_format = "%d";
} }
break; break;
case DT_POINTER: case DT_POINTER:
if (_value->cookie == DV_TARGET) { if (_value->cookie == DV_TARGET) {
if (!DEBUG_READ_MEM_VERBOSE((void*)value.addr.off, &rtn, sizeof(void*))) if (!DEBUG_READ_MEM_VERBOSE((void*)value.addr.off, &rtn2, sizeof(void*)))
return 0; return 0;
} else { } else {
rtn = *(unsigned int*)(value.addr.off); rtn2 = *(unsigned int*)(value.addr.off);
} }
type2 = value.type->un.pointer.pointsto; type2 = value.type->un.pointer.pointsto;
if (!type2) if (!type2) {
{
def_format = "Internal symbol error: unable to access memory location 0x%08x"; def_format = "Internal symbol error: unable to access memory location 0x%08x";
rtn = 0; rtn = 0;
break; break;
} }
if( type2->type == DT_BASIC && type2->un.basic.basic_size == 1 ) if (type2->type == DT_BASIC && type2->un.basic.basic_size == 1) {
{ if (_value->cookie == DV_TARGET) {
if ( _value->cookie == DV_TARGET ) {
char ch; char ch;
def_format = "\"%S\""; def_format = "\"%S\"";
if (!DEBUG_READ_MEM_VERBOSE((void*)rtn, &ch, 1)) /* FIXME: assuming little endian */
if (!DEBUG_READ_MEM_VERBOSE((void*)rtn2, &ch, 1))
return 0; return 0;
} else { } else {
def_format = "\"%s\""; def_format = "\"%s\"";
} }
} } else {
else
{
def_format = "0x%8.8x"; def_format = "0x%8.8x";
} }
rtn = rtn2;
break; break;
case DT_ARRAY: case DT_ARRAY:
case DT_STRUCT: case DT_STRUCT:
assert(_value->cookie == DV_TARGET); assert(_value->cookie == DV_TARGET);
if (!DEBUG_READ_MEM_VERBOSE((void*)value.addr.off, &rtn, sizeof(rtn))) if (!DEBUG_READ_MEM_VERBOSE((void*)value.addr.off, &rtn2, sizeof(rtn2)))
return 0; return 0;
rtn = rtn2;
def_format = "0x%8.8x"; def_format = "0x%8.8x";
break; break;
case DT_ENUM: case DT_ENUM:
assert(_value->cookie == DV_TARGET); assert(_value->cookie == DV_TARGET);
if (!DEBUG_READ_MEM_VERBOSE((void*)value.addr.off, &rtn, sizeof(rtn))) if (!DEBUG_READ_MEM_VERBOSE((void*)value.addr.off, &rtn2, sizeof(rtn2)))
return 0; return 0;
for(e = value.type->un.enumeration.members; e; e = e->next ) rtn = rtn2;
{ def_format = "%d";
if( e->value == rtn ) for (e = value.type->un.enumeration.members; e; e = e->next) {
{ if (e->value == rtn) {
break; rtn = (int)e->name;
}
}
if( e != NULL )
{
rtn = (int) e->name;
def_format = "%s"; def_format = "%s";
break;
} }
else
{
def_format = "%d";
} }
break; break;
default: default:
...@@ -459,8 +452,7 @@ DEBUG_GetExprValue(const DBG_VALUE *_value, char ** format) ...@@ -459,8 +452,7 @@ DEBUG_GetExprValue(const DBG_VALUE *_value, char ** format)
} }
if( format != NULL ) if (format != NULL) {
{
*format = def_format; *format = def_format;
} }
return rtn; return rtn;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment