3 static void CarryExpressionError(Expression exp, Expression expError)
7 // This function assumes that expError is contained within exp,
8 // and therefore these types will be freed when freeing the old contents
9 // of the expression we're carying into.
11 if(expError.destType) expError.destType.refCount++;
12 if(expError.expType) expError.expType.refCount++;
16 // -- Careful: this could be problematic as FreeExpContents will free the contents of expError
17 // Nulling things that may be freed now, but this is all overly messy/complex
21 expError.identifier = null;
24 expError.constant = null;
26 case memberSymbolErrorExp:
27 expError.member.exp = null;
28 expError.member.member = null;
33 Identifier identifier = expError.identifier;
34 expError.identifier = null;
36 exp.identifier = identifier;
37 exp.type = expError.type;
39 if(exp.expType) FreeType(exp.expType);
40 if(exp.destType) FreeType(exp.destType);
42 *exp = *temp; //*expError;
44 // memset(expError, 0, sizeof(class Expression));
47 static char GetGdbFormatChar(Type type)
49 // x : Regard the bits of the value as an integer, and print the integer in hexadecimal.
50 // d : Print as integer in signed decimal.
51 // u : Print as integer in unsigned decimal.
52 // o : Print as integer in octal.
53 // t : Print as integer in binary. The letter `t' stands for "two". (4)
54 // a : Print as an address, both absolute in hexadecimal and as an offset from the nearest preceding symbol. You can use this format used to discover where (in what function) an unknown address is located:
55 // c : Regard as an integer and print it as a character constant. This prints both the numerical value and its character representation. The character representation is replaced with the octal escape `\nnn' for characters outside the 7-bit ASCII range.
56 // f : Regard the bits of the value as a floating point number and print using typical floating point syntax.
86 // case TypeTypedObject, TypeAnyObject, TypeClassPointer:
96 /*static */bool ExpressionIsError(Expression exp)
98 return (exp.type == dereferenceErrorExp || exp.type == symbolErrorExp ||
99 exp.type == memberSymbolErrorExp || exp.type == memoryErrorExp || exp.type == unknownErrorExp ||
100 exp.type == noDebuggerErrorExp);
103 void DebugComputeExpression(Expression exp)
106 char expString[1024] = "";
109 PrintExpression(exp, expString);
110 // printf("%s (exp.type = %s)\n", expString, exp.type.OnGetString(temp, null, null));
116 Expression prev = exp.prev, next = exp.next;
117 char * evaluation = null;
118 ExpressionType evalError = dummyExp;
120 TypeKind kind = dummyType;
121 Type dataType = exp.expType;
126 bool isPointer = false;
128 if(dataType && dataType.kind == classType && dataType._class.registered)
130 Class _class = dataType._class.registered;
131 if(_class.type == bitClass || _class.type == unitClass || _class.type == enumClass)
134 _class.dataType = ProcessTypeString(_class.dataTypeString, false);
135 dataType = _class.dataType;
137 else if(_class.type == normalClass || _class.type == noHeadClass || _class.type == systemClass) // Added systemClass here for Instance
142 else if(dataType && dataType.kind == classType && !dataType._class.registered)
145 kind = dataType.kind;
147 exp.type = symbolErrorExp;
151 case intPtrType: case intSizeType: case _BoolType:
152 case charType: case shortType: case intType: case int64Type: case longType: case floatType: case doubleType:
158 sprintf(temp, "&%s", exp.identifier.string);
161 if(exp.byReference && dataType._class && dataType._class.registered && dataType._class.registered.type == structClass)
162 // if(!dataType._class || !dataType._class.registered || dataType._class.registered.type != structClass || exp.byReference)
163 strcpy(temp, exp.identifier.string);
165 sprintf(temp, "&%s", exp.identifier.string);
171 // case TypeTypedObject, TypeAnyObject, TypeClassPointer:
177 evaluation = Debugger::EvaluateExpression(temp, &evalError);
180 address = _strtoui64(evaluation, null, 0);
191 if(evalError == dummyExp)
197 evaluation = Debugger::EvaluateExpression(exp.identifier.string, &evalError);
202 temp = strstr(evaluation, " '");
203 //len = strlen(temp);
207 for(c = 0; c < len; c++)
209 eString_TrimRSpaces(evaluation, evaluation);
225 evaluation = Debugger::EvaluateExpression(exp.identifier.string, &evalError);
228 if(kind == pointerType)
231 value = _strtoui64(evaluation, null, 0);
233 evaluation = PrintHexUInt64(value);
243 //evaluation = Debugger::EvaluateExpression(exp.identifier.string, &evalError);
244 size = ComputeTypeSize(exp.expType); //exp.expType.arrayType.size;
245 format = GetGdbFormatChar(exp.expType);
246 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
248 StripQuotes(evaluation, evaluation);
254 //evaluation = Debugger::EvaluateExpression(exp.identifier.string, &evalError);
259 // for classType --> if(_class.type == structClass) ?
261 //sprintf(temp, "&%s", exp.identifier.string);
262 //evaluation = Debugger::EvaluateExpression(temp, &evalError);
268 // case TypeTypedObject, TypeAnyObject, TypeClassPointer:
271 evaluation = Debugger::EvaluateExpression(exp.identifier.string, &evalError);
280 //expNew = ParseExpressionString(evaluation);
281 expNew = MkExpConstant(evaluation);
282 //printf("Evaluation = %s\n", evaluation);
284 expNew.destType = exp.expType;
286 // WHY EXACTLY MUST WE PROCESS THIS EXPRESSION TYPE AGAIN ? ADDED THIS FOR 0x00000000
287 if(exp.expType && (exp.expType.kind == pointerType || exp.expType.kind == classType) && expNew.destType)
289 expNew.expType = expNew.destType;
290 expNew.destType.refCount++;
293 ProcessExpressionType(expNew);
294 FreeType(exp.destType);
295 FreeExpContents(exp);
297 DebugComputeExpression(expNew);
300 expNew.isConstant = true;
301 expNew.address = address;
302 expNew.hasAddress = hasAddress;
308 // Unhandled code path, evaluation is null
309 FreeExpContents(exp);
310 exp.type = unknownErrorExp;
314 // Keep the identifier
315 exp.type = evalError;
318 FreeExpContents(exp);
319 exp.type = evalError;
326 ComputeInstantiation(exp);
335 Expression expError = null;
336 Expression exp1, exp2 = null;
337 Operand op1 = { 0 }, op2 = { 0 };
340 if(exp.op.op == '&' || exp.op.op == '*')
342 if(!exp.op.exp1 && exp.op.exp2)
344 if(exp.op.exp2.type == identifierExp)
346 Expression prev = exp.prev, next = exp.next;
347 char * evaluation = null;
348 ExpressionType evalError = dummyExp;
351 sprintf(temp, "%c%s", exp.op.op, exp.op.exp2.identifier.string);
352 evaluation = Debugger::EvaluateExpression(temp, &evalError);
353 if(evalError != dummyExp)
355 exp.type = evalError;
356 exp.constant = CopyString("");
360 expNew = ParseExpressionString(evaluation);
362 expNew.destType = exp.expType;
363 FreeType(exp.destType);
364 FreeExpContents(exp);
365 ProcessExpressionType(expNew);
366 DebugComputeExpression(expNew);
369 expNew.isConstant = true;
374 exp.type = ExpUnknownError;
384 DebugComputeExpression(exp.op.exp2);
385 size = ComputeTypeSize(exp.op.exp2.expType);
386 format = GetGdbFormatChar(exp.op.exp2.expType);
387 GetInt(exp.op.exp2, &address);
388 //sprintf(temp, "%c%s", exp.op.op, exp.op.exp2.constant);
389 evaluation = Debug_ReadMemory(address, size, format, &evalError);
392 evalError = ExpUnknownError;
398 // We don't care about operations with only exp2 (INC_OP, DEC_OP...)
401 DebugComputeExpression(exp.op.exp2);
402 if(ExpressionIsError(exp.op.exp2))
403 expError = exp.op.exp2;
409 DebugComputeExpression(exp.op.exp1);
410 if(ExpressionIsError(exp.op.exp1))
411 expError = exp.op.exp1;
416 if(ExpressionIsError(exp.op.exp2))
417 expError = exp.op.exp2;
422 op1 = GetOperand(exp1);
423 if(op1.type) op1.type.refCount++;
424 op2 = GetOperand(exp2);
425 if(op2.type) op2.type.refCount++;
432 if(ExpressionIsError(exp.op.exp2))
433 expError = exp.op.exp2;
437 if(exp.op.op == '&' || exp.op.op == '*')
439 Expression prev = exp1.prev, next = exp1.next;
441 ExpressionType evalError = dummyExp;
442 char * evaluation = null;
448 //sprintf(temp, "%u", exp1.address);
449 temp = PrintHexUInt64(exp1.address);
450 expNew = ParseExpressionString(temp);
452 //expNew.address = exp1.address;
453 expNew.expType = exp.expType;
455 expNew.destType = exp.expType;
456 expNew.destType.refCount++;
458 FreeType(exp.destType);
459 FreeExpContents(exp);
460 ProcessExpressionType(expNew);
461 DebugComputeExpression(expNew);
464 expNew.isConstant = true;
471 else if(exp.op.op == '*')
476 FreeExpContents(exp1);
477 exp1.type = dereferenceErrorExp;
485 if(exp1.expType.kind == structType)
486 address = exp1.address;
488 GetUInt64(exp1, &address);
489 size = ComputeTypeSize(exp.expType); //exp.expType.arrayType.size;
490 format = GetGdbFormatChar(exp.expType);
493 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
499 expNew = ParseExpressionString(evaluation);
500 expNew.address = address;
501 expNew.hasAddress = true;
503 expNew.destType = exp.expType;
504 FreeType(exp.destType);
505 FreeExpContents(exp);
506 ProcessExpressionType(expNew);
507 DebugComputeExpression(expNew);
510 expNew.isConstant = true;
516 // Unhandled code path, evaluation is null
517 FreeExpContents(exp);
518 exp.type = unknownErrorExp;
523 FreeExpContents(exp1);
524 exp1.type = evalError;
525 exp1.constant = PrintHexUInt64(address);
530 FreeExpContents(exp1);
531 exp1.type = evalError;
539 FreeExpContents(exp1);
540 exp1.type = unknownErrorExp; // Not supported yet, generate error to fallback to GDB printout
547 op1 = GetOperand(exp1);
548 if(op1.type) op1.type.refCount++;
553 CarryExpressionError(exp, expError);
554 else if(exp.type == opExp)
556 // TODO: check condition
557 if((exp.op.op == '+' || exp.op.op == '-') && op1.type && op2.type &&
558 (op1.type.kind == arrayType || op1.type.kind == pointerType) && op2.type.kind == intType)
560 // TODO: Do pointer operations
561 if(exp1.expType && exp1.expType.type)
563 if(exp1.type == stringExp)
565 int len = exp1.string ? strlen(exp1.string)-2 : 0;
566 uint64 offset = (exp.op.op == '+') ? op2.i64 : -op2.i64;
567 String newString = null;
568 if(len >= 0 && offset <= len)
570 newString = new char[3 + len - offset];
572 memcpy(newString + 1, exp1.string + 1 + offset, len - offset);
573 newString[1 + len - offset] = '\"';
574 newString[1 + len - offset + 1] = 0;
576 FreeExpContents(exp);
579 exp.type = stringExp;
580 exp.string = newString;
583 exp.type = dereferenceErrorExp;
587 uint size = ComputeTypeSize(exp1.expType.type);
590 op1.ui64 /= exp1.expType.type.size;
591 CallOperator(exp, exp1, exp2, op1, op2);
592 if(exp.type == constantExp)
594 exp.address = _strtoui64(exp.constant, null, 0);
596 if(op1.type.kind == arrayType)
597 exp.hasAddress = true;
605 if((exp1 && exp1.type == stringExp) || (exp2 && exp2.type == stringExp))
607 FreeExpContents(exp);
608 exp.type = unknownErrorExp; // We should have an invalid operands error
611 CallOperator(exp, exp1, exp2, op1, op2);
613 if(op1.type) FreeType(op1.type);
614 if(op2.type) FreeType(op2.type);
615 exp.isConstant = true;
623 // e = (*exp.list).first, n = e ? e.next : null;
625 // e = n, n = n?(n.next) : null)
627 for(e = exp.list->first; e; e = n)
632 OldList * list = exp.list;
633 DebugComputeExpression(e);
634 //if(ExpressionIsError(e)) //.type == ExpSymbolError
635 // CarryExpressionError(exp, e);
636 //FreeExpContents(exp);
637 FreeType(exp.expType);
638 FreeType(exp.destType);
655 exp.isConstant = true;
657 DebugComputeExpression(exp.index.exp);
658 if(ExpressionIsError(exp.index.exp)) //.type == ExpSymbolError
659 CarryExpressionError(exp, exp.index.exp);
662 Expression prev = exp.prev, next = exp.next;
663 char * evaluation = null;
664 ExpressionType evalError = dummyExp;
666 if(!exp.index.exp.isConstant)
667 exp.isConstant = false;
670 // 4 == size = ComputeTypeSize(exp.expType);
671 // 0 == size = ComputeTypeSize(exp.expType.arrayType);
672 // 4 == size = ComputeTypeSize(exp.index.exp.expType);
673 // 0 == size = ComputeTypeSize(exp.index.exp.expType.arrayType);
675 size = ComputeTypeSize(exp.expType);
676 if(exp.expType && exp.expType.type && exp.expType.kind == arrayType)
677 // For multilevels arrays
680 format = GetGdbFormatChar(exp.expType);
682 for(e = exp.index.index->first; e; e = e.next)
684 DebugComputeExpression(e);
685 if(ExpressionIsError(e)) //.type == ExpSymbolError
687 CarryExpressionError(exp, e);
692 // Check if this type is int
695 exp.isConstant = false;
697 if(!ExpressionIsError(exp))
699 // Is this necessary here? pass15 had done this already...
700 if(exp.expType) FreeType(exp.expType);
701 exp.expType = Dereference(exp.index.exp.expType);
706 FreeExpContents(exp);
707 exp.type = dereferenceErrorExp;
709 else if(exp.index.index && exp.index.index->last && ((Expression)exp.index.index->last) && ((Expression)exp.index.index->last).expType)
711 Type type = ((Expression)exp.index.index->last).expType;
712 if(type.kind == intType || type.kind == charType || type.kind == shortType || type.kind == int64Type || type.kind == intPtrType ||
713 type.kind == intSizeType || type.kind == longType || type.kind == _BoolType || type.kind == enumType ||
714 (type.kind == classType && type._class && type._class.registered &&
715 type._class.registered.type == enumClass))
717 uint64 address = 0, offset = 0;
718 Expression expNew, last = (Expression)exp.index.index->last;
719 //GetUInt(exp.index.exp, &address);
721 // TOFIX: Check if it has address: TESTING
722 if(exp.index.exp.hasAddress && (exp.index.exp.expType.kind == arrayType))
723 address = exp.index.exp.address;
724 else if(exp.index.exp.type == constantExp)
725 GetUInt64(exp.index.exp, &address);
727 GetUInt64(last, &offset);
728 //size = ComputeTypeSize(exp.expType.arrayType); //exp.expType.arrayType.size;
729 address += offset * size;
730 if(exp.index.exp.type == stringExp)
732 String string = exp.index.exp.string;
733 int len = string ? strlen(string)-2 : 0;
736 if(len >= 0 && offset <= len)
738 ch = offset < len ? string[1 + offset] : 0;
741 FreeExpContents(exp);
744 exp.type = constantExp;
745 exp.constant = PrintChar(ch);
748 exp.type = dereferenceErrorExp;
750 else if(exp.expType.kind == arrayType)
752 FreeExpContents(exp);
753 exp.type = constantExp;
754 exp.isConstant = true;
755 exp.constant = PrintHexUInt64(address);
756 exp.address = address;
757 exp.hasAddress = true;
761 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
767 expNew = ParseExpressionString(evaluation);
769 expNew.destType = exp.expType;
770 FreeType(exp.destType);
771 FreeExpContents(exp);
772 ProcessExpressionType(expNew);
773 DebugComputeExpression(expNew);
775 // TOFIX: Only for Array Types
776 expNew.address = address;
778 expNew.hasAddress = true;
781 expNew.isConstant = true;
787 // Unhandled code path, evaluation is null
788 FreeExpContents(exp);
789 exp.type = unknownErrorExp;
794 FreeExpContents(exp);
795 exp.type = evalError;
796 exp.constant = PrintHexUInt64(address);
800 FreeExpContents(exp);
801 exp.type = evalError;
813 Expression memberExp = exp.member.exp;
814 Identifier memberID = exp.member.member;
816 Property prop = null;
817 DataMember member = null;
818 Class convertTo = null;
819 uint offset = 0; // THIS WASN'T INITIALIZED... IS IT ALWAYS SET?
821 Type type; // = memberExp.expType;
822 DebugComputeExpression(memberExp);
823 type = memberExp.expType;
824 if(ExpressionIsError(memberExp))
825 CarryExpressionError(exp, memberExp);
828 // _class = (memberID && memberID.classSym) ? memberID.classSym.registered : ((type.kind == classType && type._class) ? type._class.registered : null);
829 Class _class = (exp.member.member && exp.member.member.classSym) ? exp.member.member.classSym.registered : (((type.kind == classType || type.kind == subClassType) && type._class) ? type._class.registered : null);
832 char string[256] = "";
834 PrintTypeNoConst(type, string, false, true);
835 classSym = FindClass(string);
836 _class = classSym ? classSym.registered : null;
839 if(memberID && _class)
842 prop = eClass_FindProperty(_class, memberID.string);
844 member = eClass_FindDataMember(_class, memberID.string);
846 // member = eClass_FindDataMember(_class, memberID.string);
847 member = eClass_FindDataMemberAndOffset(_class, memberID.string, &offset, _class.module.application, null, null);
849 prop = eClass_FindProperty(_class, memberID.string, _class.module.application);
851 if(!prop && !member && _class && memberID)
853 Symbol classSym = FindClass(memberID.string);
855 _class = classSym ? classSym.registered : null;
857 prop = eClass_FindProperty(_class, convertTo.name, _class.module.application);
860 //DebugComputeExpression(memberExp);
861 if(ExpressionIsError(memberExp))
862 CarryExpressionError(exp, memberExp);
869 Type type = prop.dataType;
870 // TODO: Assuming same base type for units...
871 if(_class.type == unitClass)
873 if(type.kind == classType)
875 Class _class = type._class.registered;
876 if(_class.type == unitClass)
879 _class.dataType = ProcessTypeString(_class.dataTypeString, false);
880 type = _class.dataType;
888 float (*Get)(float) = (void *)prop.Get;
889 GetFloat(memberExp, &value);
890 exp.constant = PrintFloat(Get ? Get(value) : value);
891 exp.type = constantExp;
897 double (*Get)(double);
898 GetDouble(memberExp, &value);
901 Get = (void *)prop.Set;
903 Get = (void *)prop.Get;
904 exp.constant = PrintDouble(Get ? Get(value) : value);
905 exp.type = constantExp;
914 Expression value = memberExp;
915 Type type = prop.dataType;
916 if(_class.type == structClass)
922 Class propertyClass = type._class.registered;
923 if(propertyClass.type == structClass && value.type == instanceExp)
925 void (*Set)(void *, void *) = (void *)prop.Set;
926 exp.instance = Instantiation
928 data = new0 byte[_class.structSize];
929 _class = MkSpecifierName/*MkClassName*/(_class.name);
931 exp.type = instanceExp;
933 Set(exp.instance.data, value.instance.data);
934 PopulateInstance(exp.instance);
941 void (*Set)(void *, int) = (void *)prop.Set;
943 exp.instance = Instantiation
945 data = new0 byte[_class.structSize];
946 _class = MkSpecifierName/*MkClassName*/(_class.name);
949 exp.type = instanceExp;
951 GetInt(value, &intValue);
953 Set(exp.instance.data, intValue);
954 PopulateInstance(exp.instance);
960 void (*Set)(void *, int64) = (void *)prop.Set;
962 exp.instance = Instantiation
964 data = new0 byte[_class.structSize];
965 _class = MkSpecifierName/*MkClassName*/(_class.name);
968 exp.type = instanceExp;
970 GetInt64(value, &intValue);
972 Set(exp.instance.data, intValue);
973 PopulateInstance(exp.instance);
979 void (*Set)(void *, double) = (void *)prop.Set;
981 exp.instance = Instantiation
983 data = new0 byte[_class.structSize];
984 _class = MkSpecifierName/*MkClassName*/(_class.name);
987 exp.type = instanceExp;
989 GetDouble(value, &doubleValue);
991 Set(exp.instance.data, doubleValue);
992 PopulateInstance(exp.instance);
997 else if(_class.type == bitClass)
1003 Class propertyClass = type._class.registered;
1004 if(propertyClass.type == structClass && value.instance.data)
1006 unsigned int (*Set)(void *) = (void *)prop.Set;
1007 unsigned int bits = Set(value.instance.data);
1008 exp.constant = PrintHexUInt(bits);
1009 exp.type = constantExp;
1012 else if(_class.type == bitClass)
1015 unsigned int (*Set)(unsigned int) = (void *)prop.Set;
1018 GetUInt(memberExp, &value);
1020 exp.constant = PrintHexUInt(bits);
1021 exp.type = constantExp;
1029 if(_class.type == bitClass)
1032 GetUInt(memberExp, &value);
1038 Class _class = type._class.registered;
1039 if(_class.type == structClass)
1041 void (*Get)(unsigned int, void *) = (void *)prop.Get;
1043 exp.instance = Instantiation
1045 data = new0 byte[_class.structSize];
1046 _class = MkSpecifierName/*MkClassName*/(_class.name);
1049 //exp.instance.fullSet = true;
1050 exp.type = instanceExp;
1051 Get(value, exp.instance.data);
1052 PopulateInstance(exp.instance);
1054 else if(_class.type == bitClass)
1056 unsigned int (*Get)(unsigned int) = (void *)prop.Get;
1057 uint64 bits = Get(value);
1058 exp.constant = PrintHexUInt64(bits);
1059 exp.type = constantExp;
1065 else if(_class.type == structClass)
1067 char * value = (memberExp.type == instanceExp ) ? memberExp.instance.data : null;
1072 Class _class = type._class.registered;
1073 if(_class.type == structClass && value)
1075 void (*Get)(void *, void *) = (void *)prop.Get;
1077 exp.instance = Instantiation
1079 data = new0 byte[_class.structSize];
1080 _class = MkSpecifierName/*MkClassName*/(_class.name);
1083 //exp.instance.fullSet = true;
1084 exp.type = instanceExp;
1085 Get(value, exp.instance.data);
1086 PopulateInstance(exp.instance);
1094 char * value = memberExp.instance.data;
1099 Class _class = type._class.registered;
1100 if(_class.type == normalClass)
1102 void *(*Get)(void *) = (void *)prop.Get;
1104 exp.instance = Instantiation
1106 data = Get(value, exp.instance.data); ?????
1107 _class = MkSpecifierName(_class.name); //MkClassName(_class.name);
1110 exp.type = instanceExp;
1122 exp.isConstant = false;
1127 if(memberExp.hasAddress || memberExp.type == constantExp)
1128 //if(memberExp.expType && memberExp.expType.kind == intType) // && !exp.index.exp.expType.isSigned
1130 if(_class.type == bitClass)
1132 if(memberExp.type == constantExp)
1134 // Unfinished business...
1135 BitMember bitMember = (BitMember)member;
1137 GetUInt64(memberExp, &bits);
1138 bits &= bitMember.mask;
1139 bits >>= bitMember.pos;
1141 FreeExpression(exp.member.exp);
1142 FreeIdentifier(exp.member.member);
1144 exp.constant = PrintUInt64(bits);
1146 exp.isConstant = true;
1147 exp.type = constantExp;
1148 exp.hasAddress = false;
1153 char * evaluation = null;
1154 ExpressionType evalError = dummyExp;
1156 Expression prev = exp.prev, next = exp.next;
1160 TypeKind kind = dummyType;
1161 Type dataType = member.dataType;
1164 dataType = member.dataType = ProcessTypeString(member.dataTypeString, false);
1166 if(dataType.kind == classType && dataType._class.registered &&
1167 (dataType._class.registered.type == enumClass || dataType._class.registered.type == bitClass || dataType._class.registered.type == unitClass))
1169 if(dataType._class.registered.dataTypeString)
1170 dataType._class.registered.dataType = ProcessTypeString(dataType._class.registered.dataTypeString, false);
1171 dataType = dataType._class.registered.dataType;
1173 dataType = ProcessTypeString("int", false);
1176 size = ComputeTypeSize(member.dataType);
1178 format = GetGdbFormatChar(dataType);
1179 //if(memberExp.address)
1181 //GetInt(memberExp, &address);
1182 //offset = member.offset;
1184 // TESTING NOHEAD HERE?
1185 if(_class.type == normalClass || _class.type == noHeadClass || _class.type == systemClass)
1186 offset += member._class.offset;
1188 // VERIFY THIS: (trying to fix primitive.type)
1189 // if(memberExp.type == constantExp)
1190 if(memberExp.hasAddress && (_class.type != normalClass && _class.type != noHeadClass && _class.type != systemClass))
1191 address = memberExp.address;
1192 else if(memberExp.type == constantExp)
1193 GetUInt64(memberExp, &address);
1197 GetUInt64(memberExp, &address);
1198 //printf("Unhandled !!\n");
1200 //printf("memberExp.hasAddress = %d\n", memberExp.hasAddress);
1201 //printf("memberExp.type = %d\n", memberExp.type);
1202 //printf("_class.name = %s, _class.type = %d\n", _class.name, _class.type);
1207 if((dataType.kind == classType && dataType._class &&
1208 (!dataType._class.registered || dataType._class.registered.type == normalClass || dataType._class.registered.type == noHeadClass || dataType._class.registered.type == systemClass)) ||
1209 (dataType.kind != classType && dataType.kind != arrayType && dataType.kind != structType && dataType.kind != unionType))
1211 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
1212 if(evalError != dummyExp)
1214 exp.type = evalError;
1215 exp.constant = PrintHexUInt64(address);
1219 //printf("evaluation = %s\n", evaluation);
1220 expNew = ParseExpressionString(evaluation);
1222 expNew.destType = exp.expType;
1224 exp.expType.refCount++;
1225 //FreeType(memberExp.destType);
1226 FreeType(exp.expType);
1227 FreeType(exp.destType);
1228 FreeExpContents(exp);
1229 ProcessExpressionType(expNew);
1230 DebugComputeExpression(expNew);
1233 expNew.isConstant = true;
1234 expNew.address = address;
1235 expNew.hasAddress = true;
1240 exp.type = unknownErrorExp;
1244 // TESTING THIS HERE...
1245 exp.type = constantExp;
1246 exp.constant = PrintHexUInt64(address);
1248 exp.address = address;
1249 exp.hasAddress = true;
1250 exp.isConstant = true;
1255 // exp.type = ExpUnknownError;
1257 //FreeExpContents(exp);
1258 //exp.constant = PrintUInt64(value);
1259 //exp.type = constantExp;
1264 if(type && (type.kind == structType || type.kind == unionType))
1267 Type memberType = exp.member.member ? FindMemberAndOffset(type, exp.member.member.string, &offset) : null;
1270 char * evaluation = null;
1271 ExpressionType evalError = dummyExp;
1273 Expression prev = exp.prev, next = exp.next;
1275 int size = memberType.size;
1277 Type dataType = memberType;
1278 TypeKind kind = dummyType;
1280 if(dataType.kind == classType && dataType._class.registered &&
1281 (dataType._class.registered.type == enumClass || dataType._class.registered.type == bitClass || dataType._class.registered.type == unitClass))
1282 dataType = dataType._class.registered.dataType;
1284 format = GetGdbFormatChar(dataType);
1286 if(memberExp.hasAddress)
1287 address = memberExp.address;
1288 else if(memberExp.type == constantExp)
1289 GetUInt64(memberExp, &address);
1293 if((dataType.kind == classType && dataType._class &&
1294 (!dataType._class.registered || dataType._class.registered.type == normalClass || dataType._class.registered.type == noHeadClass || dataType._class.registered.type == systemClass)) ||
1295 (dataType.kind != classType && dataType.kind != arrayType && dataType.kind != structType && dataType.kind != unionType))
1297 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
1298 if(evalError != dummyExp)
1300 exp.type = evalError;
1301 exp.constant = PrintHexUInt64(address);
1305 expNew = ParseExpressionString(evaluation);
1307 expNew.destType = exp.expType;
1309 exp.expType.refCount++;
1310 //FreeType(memberExp.destType);
1311 FreeType(exp.expType);
1312 FreeType(exp.destType);
1313 FreeExpContents(exp);
1314 ProcessExpressionType(expNew);
1315 DebugComputeExpression(expNew);
1318 expNew.isConstant = true;
1319 expNew.address = address;
1320 expNew.hasAddress = true;
1325 exp.type = unknownErrorExp;
1329 FreeExpContents(exp);
1331 // TESTING THIS HERE...
1332 exp.type = constantExp;
1333 exp.constant = PrintHexUInt64(address);
1335 exp.address = address;
1336 exp.hasAddress = true;
1337 exp.isConstant = true;
1341 exp.type = memberSymbolErrorExp;
1344 exp.type = memberSymbolErrorExp;
1348 //if(exp.type != memberExp)
1350 //FreeExpression(memberExp);
1351 //FreeIdentifier(memberID);
1356 exp.type = memberSymbolErrorExp;
1362 Type type = ProcessType(exp.typeName.qualifiers, exp.typeName.declarator);
1363 FreeExpContents(exp);
1364 exp.constant = PrintUInt(ComputeTypeSize(type));
1365 exp.type = constantExp;
1371 Symbol classSym = FindClass(exp._class.name);
1372 if(classSym && classSym.registered)
1374 //exp.constant = PrintUInt(classSym.registered.size);
1375 //exp.type = constantExp;
1377 char className[1024];
1378 sprintf(className, "__ecereClass_%s", classSym.string);
1379 FreeExpContents(exp);
1380 exp.type = pointerExp;
1381 exp.member.exp = MkExpIdentifier(MkIdentifier(className));
1382 exp.member.member = MkIdentifier("size");
1388 DebugComputeExpression(exp.cast.exp);
1390 if(ExpressionIsError(exp.cast.exp)) //.type == ExpSymbolError
1391 CarryExpressionError(exp, exp.cast.exp);
1394 exp.hasAddress = exp.cast.exp.hasAddress;
1395 exp.address = exp.cast.exp.address;
1396 if(exp.cast.exp.type == constantExp && exp.expType)
1398 Type type = exp.expType;
1399 if(type.kind == classType && type._class && type._class.registered)
1401 Class _class = type._class.registered;
1402 if(_class.type == unitClass || _class.type == bitClass || _class.type == enumClass)
1404 if(!_class.dataType)
1405 _class.dataType = ProcessTypeString(_class.dataTypeString, false);
1406 type = _class.dataType;
1416 GetChar(exp.cast.exp, &value);
1417 FreeExpContents(exp);
1418 exp.constant = PrintChar(value);
1419 exp.type = constantExp;
1420 exp.isConstant = true;
1424 unsigned char value;
1425 GetUChar(exp.cast.exp, &value);
1426 FreeExpContents(exp);
1427 exp.constant = PrintUChar(value);
1428 exp.type = constantExp;
1429 exp.isConstant = true;
1436 GetShort(exp.cast.exp, &value);
1437 FreeExpContents(exp);
1438 exp.constant = PrintShort(value);
1439 exp.type = constantExp;
1440 exp.isConstant = true;
1444 unsigned short value;
1445 GetUShort(exp.cast.exp, &value);
1446 FreeExpContents(exp);
1447 exp.constant = PrintUShort(value);
1448 exp.type = constantExp;
1449 exp.isConstant = true;
1456 GetInt(exp.cast.exp, &value);
1457 FreeExpContents(exp);
1458 exp.constant = PrintInt(value);
1459 exp.type = constantExp;
1460 exp.isConstant = true;
1465 GetUInt(exp.cast.exp, &value);
1466 FreeExpContents(exp);
1467 exp.constant = PrintUInt(value);
1468 exp.type = constantExp;
1469 exp.isConstant = true;
1476 GetInt64(exp.cast.exp, &value);
1477 FreeExpContents(exp);
1478 exp.constant = PrintInt64(value);
1479 exp.type = constantExp;
1480 exp.isConstant = true;
1485 GetUInt64(exp.cast.exp, &value);
1486 FreeExpContents(exp);
1487 exp.constant = PrintUInt64(value);
1488 exp.type = constantExp;
1489 exp.isConstant = true;
1496 GetUInt64(exp.cast.exp, &value);
1497 FreeExpContents(exp);
1498 if(type.kind == pointerType || type.kind == classType)
1499 exp.constant = PrintHexUInt64(value);
1501 exp.constant = PrintUInt64(value);
1502 exp.type = constantExp;
1503 exp.isConstant = true;
1509 GetFloat(exp.cast.exp, &value);
1510 FreeExpContents(exp);
1511 exp.constant = PrintFloat(value);
1512 exp.type = constantExp;
1513 exp.isConstant = true;
1519 GetDouble(exp.cast.exp, &value);
1520 FreeExpContents(exp);
1521 exp.constant = PrintDouble(value);
1522 exp.type = constantExp;
1523 exp.isConstant = true;
1535 DebugComputeExpression(exp.cond.cond);
1537 if(ExpressionIsError(exp.cond.cond))
1538 CarryExpressionError(exp, exp.cond.cond);
1539 else if(exp.cond.cond.type == constantExp && exp.cond.cond.constant)
1541 Expression e = null;
1542 if(strtol(exp.cond.cond.constant, null, 0))
1544 for(e = exp.cond.exp ? exp.cond.exp->first : null; e; e = e.next)
1546 DebugComputeExpression(e);
1551 if(ExpressionIsError(e))
1553 CarryExpressionError(exp, e);
1557 exp.cond.exp->Remove(e);
1562 e = exp.cond.elseExp;
1565 DebugComputeExpression(e);
1566 if(ExpressionIsError(e))
1568 CarryExpressionError(exp, e);
1572 exp.cond.elseExp = null;
1577 FreeType(exp.expType);
1578 FreeType(exp.destType);
1581 FreeExpContents(exp);
1585 else if(!ExpressionIsError(exp))
1587 FreeExpContents(exp);
1588 exp.type = unknownErrorExp;
1593 FreeExpContents(exp);
1594 exp.type = unknownErrorExp;
1599 FreeExpContents(exp);
1600 exp.type = unknownErrorExp;