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 Expression e = exp.op.exp2;
403 while((e.type == bracketsExp || e.type == extensionExpressionExp || e.type == extensionCompoundExp) && e.list)
405 if(e.type == bracketsExp || e.type == extensionExpressionExp || e.type == extensionCompoundExp)
407 if(e.type == extensionCompoundExp)
408 e = ((Statement)e.compound.compound.statements->last).expressions->last;
413 if(exp.op.op == TokenType::sizeOf && e && e.expType)
415 if(e.type == stringExp && e.string)
417 char * string = e.string;
418 int len = strlen(string);
419 char * tmp = new char[len-2+1];
420 len = UnescapeString(tmp, string + 1, len - 2);
422 FreeExpContents(exp);
423 exp.type = constantExp;
424 exp.constant = PrintUInt(len + 1);
428 Type type = e.expType;
430 FreeExpContents(exp);
431 exp.type = constantExp;
432 exp.constant = PrintUInt(ComputeTypeSize(type));
439 DebugComputeExpression(exp.op.exp2);
440 if(ExpressionIsError(exp.op.exp2))
441 expError = exp.op.exp2;
448 DebugComputeExpression(exp.op.exp1);
449 if(ExpressionIsError(exp.op.exp1))
450 expError = exp.op.exp1;
455 if(ExpressionIsError(exp.op.exp2))
456 expError = exp.op.exp2;
461 op1 = GetOperand(exp1);
462 if(op1.type) op1.type.refCount++;
463 op2 = GetOperand(exp2);
464 if(op2.type) op2.type.refCount++;
471 if(ExpressionIsError(exp.op.exp2))
472 expError = exp.op.exp2;
476 if(exp.op.op == '&' || exp.op.op == '*')
478 Expression prev = exp1.prev, next = exp1.next;
480 ExpressionType evalError = dummyExp;
481 char * evaluation = null;
487 //sprintf(temp, "%u", exp1.address);
488 temp = PrintHexUInt64(exp1.address);
489 expNew = ParseExpressionString(temp);
491 //expNew.address = exp1.address;
492 expNew.expType = exp.expType;
494 expNew.destType = exp.expType;
495 expNew.destType.refCount++;
497 FreeType(exp.destType);
498 FreeExpContents(exp);
499 ProcessExpressionType(expNew);
500 DebugComputeExpression(expNew);
503 expNew.isConstant = true;
510 else if(exp.op.op == '*')
515 FreeExpContents(exp1);
516 exp1.type = dereferenceErrorExp;
524 if(exp1.expType.kind == structType)
525 address = exp1.address;
527 GetUInt64(exp1, &address);
528 size = ComputeTypeSize(exp.expType); //exp.expType.arrayType.size;
529 format = GetGdbFormatChar(exp.expType);
532 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
538 expNew = ParseExpressionString(evaluation);
539 expNew.address = address;
540 expNew.hasAddress = true;
542 expNew.destType = exp.expType;
543 FreeType(exp.destType);
544 FreeExpContents(exp);
545 ProcessExpressionType(expNew);
546 DebugComputeExpression(expNew);
549 expNew.isConstant = true;
555 // Unhandled code path, evaluation is null
556 FreeExpContents(exp);
557 exp.type = unknownErrorExp;
562 FreeExpContents(exp1);
563 exp1.type = evalError;
564 exp1.constant = PrintHexUInt64(address);
569 FreeExpContents(exp1);
570 exp1.type = evalError;
578 FreeExpContents(exp1);
579 exp1.type = unknownErrorExp; // Not supported yet, generate error to fallback to GDB printout
586 op1 = GetOperand(exp1);
587 if(op1.type) op1.type.refCount++;
592 CarryExpressionError(exp, expError);
593 else if(exp.type == opExp)
595 // TODO: check condition
596 if((exp.op.op == '+' || exp.op.op == '-') && op1.type && op2.type &&
597 (op1.type.kind == arrayType || op1.type.kind == pointerType) && op2.type.kind == intType)
599 // TODO: Do pointer operations
600 if(exp1.expType && exp1.expType.type)
602 if(exp1.type == stringExp)
604 uint64 offset = (exp.op.op == '+') ? op2.i64 : -op2.i64;
605 String newString = null;
608 int len = strlen(exp1.string) - 2;
609 char * tmp = OffsetEscapedString(exp1.string + 1, len, (int)offset);
612 len -= tmp - (exp1.string + 1);
613 newString = new char[2 + len];
615 memcpy(newString + 1, tmp, len);
616 newString[1 + len] = '\"';
617 newString[1 + len + 1] = 0;
620 FreeExpContents(exp);
623 exp.type = stringExp;
624 exp.string = newString;
627 exp.type = dereferenceErrorExp;
631 uint size = ComputeTypeSize(exp1.expType.type);
634 op1.ui64 /= exp1.expType.type.size;
635 CallOperator(exp, exp1, exp2, op1, op2);
636 if(exp.type == constantExp)
638 exp.address = _strtoui64(exp.constant, null, 0);
640 if(op1.type.kind == arrayType)
641 exp.hasAddress = true;
649 if((exp1 && exp1.type == stringExp) || (exp2 && exp2.type == stringExp))
651 FreeExpContents(exp);
652 exp.type = unknownErrorExp; // We should have an invalid operands error
655 CallOperator(exp, exp1, exp2, op1, op2);
657 if(op1.type) FreeType(op1.type);
658 if(op2.type) FreeType(op2.type);
659 exp.isConstant = true;
667 // e = (*exp.list).first, n = e ? e.next : null;
669 // e = n, n = n?(n.next) : null)
671 for(e = exp.list->first; e; e = n)
676 OldList * list = exp.list;
677 DebugComputeExpression(e);
678 //if(ExpressionIsError(e)) //.type == ExpSymbolError
679 // CarryExpressionError(exp, e);
680 //FreeExpContents(exp);
681 FreeType(exp.expType);
682 FreeType(exp.destType);
699 exp.isConstant = true;
701 DebugComputeExpression(exp.index.exp);
702 if(ExpressionIsError(exp.index.exp)) //.type == ExpSymbolError
703 CarryExpressionError(exp, exp.index.exp);
706 Expression prev = exp.prev, next = exp.next;
707 char * evaluation = null;
708 ExpressionType evalError = dummyExp;
710 if(!exp.index.exp.isConstant)
711 exp.isConstant = false;
714 // 4 == size = ComputeTypeSize(exp.expType);
715 // 0 == size = ComputeTypeSize(exp.expType.arrayType);
716 // 4 == size = ComputeTypeSize(exp.index.exp.expType);
717 // 0 == size = ComputeTypeSize(exp.index.exp.expType.arrayType);
719 size = ComputeTypeSize(exp.expType);
720 if(exp.expType && exp.expType.type && exp.expType.kind == arrayType)
721 // For multilevels arrays
724 format = GetGdbFormatChar(exp.expType);
726 for(e = exp.index.index->first; e; e = e.next)
728 DebugComputeExpression(e);
729 if(ExpressionIsError(e)) //.type == ExpSymbolError
731 CarryExpressionError(exp, e);
736 // Check if this type is int
739 exp.isConstant = false;
741 if(!ExpressionIsError(exp))
743 // Is this necessary here? pass15 had done this already...
744 if(exp.expType) FreeType(exp.expType);
745 exp.expType = Dereference(exp.index.exp.expType);
750 FreeExpContents(exp);
751 exp.type = dereferenceErrorExp;
753 else if(exp.index.index && exp.index.index->last && ((Expression)exp.index.index->last) && ((Expression)exp.index.index->last).expType)
755 Type type = ((Expression)exp.index.index->last).expType;
756 if(type.kind == intType || type.kind == charType || type.kind == shortType || type.kind == int64Type || type.kind == intPtrType ||
757 type.kind == intSizeType || type.kind == longType || type.kind == _BoolType || type.kind == enumType ||
758 (type.kind == classType && type._class && type._class.registered &&
759 type._class.registered.type == enumClass))
761 uint64 address = 0, offset = 0;
762 Expression expNew, last = (Expression)exp.index.index->last;
763 //GetUInt(exp.index.exp, &address);
765 // TOFIX: Check if it has address: TESTING
766 if(exp.index.exp.hasAddress && (exp.index.exp.expType.kind == arrayType))
767 address = exp.index.exp.address;
768 else if(exp.index.exp.type == constantExp)
769 GetUInt64(exp.index.exp, &address);
771 GetUInt64(last, &offset);
772 //size = ComputeTypeSize(exp.expType.arrayType); //exp.expType.arrayType.size;
773 address += offset * size;
774 if(exp.index.exp.type == stringExp)
776 String string = exp.index.exp.string;
782 int len = string ? strlen(string) : 0;
783 tmp = new char[len-2+1];
784 len = UnescapeString(tmp, string + 1, len - 2);
785 if(len >= 0 && offset <= len)
787 ch = offset < len ? tmp[offset] : 0;
792 FreeExpContents(exp);
795 exp.type = constantExp;
796 exp.constant = PrintChar(ch);
799 exp.type = dereferenceErrorExp;
801 else if(exp.expType.kind == arrayType)
803 FreeExpContents(exp);
804 exp.type = constantExp;
805 exp.isConstant = true;
806 exp.constant = PrintHexUInt64(address);
807 exp.address = address;
808 exp.hasAddress = true;
812 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
818 expNew = ParseExpressionString(evaluation);
820 expNew.destType = exp.expType;
821 FreeType(exp.destType);
822 FreeExpContents(exp);
823 ProcessExpressionType(expNew);
824 DebugComputeExpression(expNew);
826 // TOFIX: Only for Array Types
827 expNew.address = address;
829 expNew.hasAddress = true;
832 expNew.isConstant = true;
838 // Unhandled code path, evaluation is null
839 FreeExpContents(exp);
840 exp.type = unknownErrorExp;
845 FreeExpContents(exp);
846 exp.type = evalError;
847 exp.constant = PrintHexUInt64(address);
851 FreeExpContents(exp);
852 exp.type = evalError;
864 Expression memberExp = exp.member.exp;
865 Identifier memberID = exp.member.member;
867 Property prop = null;
868 DataMember member = null;
869 Class convertTo = null;
870 uint offset = 0; // THIS WASN'T INITIALIZED... IS IT ALWAYS SET?
872 Type type; // = memberExp.expType;
873 DebugComputeExpression(memberExp);
874 type = memberExp.expType;
875 if(ExpressionIsError(memberExp))
876 CarryExpressionError(exp, memberExp);
879 // _class = (memberID && memberID.classSym) ? memberID.classSym.registered : ((type.kind == classType && type._class) ? type._class.registered : null);
880 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);
883 char string[256] = "";
885 PrintTypeNoConst(type, string, false, true);
886 classSym = FindClass(string);
887 _class = classSym ? classSym.registered : null;
890 if(memberID && _class)
893 prop = eClass_FindProperty(_class, memberID.string);
895 member = eClass_FindDataMember(_class, memberID.string);
897 // member = eClass_FindDataMember(_class, memberID.string);
898 member = eClass_FindDataMemberAndOffset(_class, memberID.string, &offset, _class.module.application, null, null);
900 prop = eClass_FindProperty(_class, memberID.string, _class.module.application);
902 if(!prop && !member && _class && memberID)
904 Symbol classSym = FindClass(memberID.string);
906 _class = classSym ? classSym.registered : null;
908 prop = eClass_FindProperty(_class, convertTo.name, _class.module.application);
911 //DebugComputeExpression(memberExp);
912 if(ExpressionIsError(memberExp))
913 CarryExpressionError(exp, memberExp);
920 Type type = prop.dataType;
921 // TODO: Assuming same base type for units...
922 if(_class.type == unitClass)
924 if(type.kind == classType)
926 Class _class = type._class.registered;
927 if(_class.type == unitClass)
930 _class.dataType = ProcessTypeString(_class.dataTypeString, false);
931 type = _class.dataType;
939 float (*Get)(float) = (void *)prop.Get;
940 GetFloat(memberExp, &value);
941 exp.constant = PrintFloat(Get ? Get(value) : value);
942 exp.type = constantExp;
948 double (*Get)(double);
949 GetDouble(memberExp, &value);
952 Get = (void *)prop.Set;
954 Get = (void *)prop.Get;
955 exp.constant = PrintDouble(Get ? Get(value) : value);
956 exp.type = constantExp;
965 Expression value = memberExp;
966 Type type = prop.dataType;
967 if(_class.type == structClass)
973 Class propertyClass = type._class.registered;
974 if(propertyClass.type == structClass && value.type == instanceExp)
976 void (*Set)(void *, void *) = (void *)prop.Set;
977 exp.instance = Instantiation
979 data = new0 byte[_class.structSize];
980 _class = MkSpecifierName/*MkClassName*/(_class.name);
982 exp.type = instanceExp;
984 Set(exp.instance.data, value.instance.data);
985 PopulateInstance(exp.instance);
992 void (*Set)(void *, int) = (void *)prop.Set;
994 exp.instance = Instantiation
996 data = new0 byte[_class.structSize];
997 _class = MkSpecifierName/*MkClassName*/(_class.name);
1000 exp.type = instanceExp;
1002 GetInt(value, &intValue);
1004 Set(exp.instance.data, intValue);
1005 PopulateInstance(exp.instance);
1011 void (*Set)(void *, int64) = (void *)prop.Set;
1013 exp.instance = Instantiation
1015 data = new0 byte[_class.structSize];
1016 _class = MkSpecifierName/*MkClassName*/(_class.name);
1019 exp.type = instanceExp;
1021 GetInt64(value, &intValue);
1023 Set(exp.instance.data, intValue);
1024 PopulateInstance(exp.instance);
1030 void (*Set)(void *, double) = (void *)prop.Set;
1032 exp.instance = Instantiation
1034 data = new0 byte[_class.structSize];
1035 _class = MkSpecifierName/*MkClassName*/(_class.name);
1038 exp.type = instanceExp;
1040 GetDouble(value, &doubleValue);
1042 Set(exp.instance.data, doubleValue);
1043 PopulateInstance(exp.instance);
1048 else if(_class.type == bitClass)
1054 Class propertyClass = type._class.registered;
1055 if(propertyClass.type == structClass && value.instance.data)
1057 unsigned int (*Set)(void *) = (void *)prop.Set;
1058 unsigned int bits = Set(value.instance.data);
1059 exp.constant = PrintHexUInt(bits);
1060 exp.type = constantExp;
1063 else if(_class.type == bitClass)
1066 unsigned int (*Set)(unsigned int) = (void *)prop.Set;
1069 GetUInt(memberExp, &value);
1071 exp.constant = PrintHexUInt(bits);
1072 exp.type = constantExp;
1080 if(_class.type == bitClass)
1083 GetUInt(memberExp, &value);
1089 Class _class = type._class.registered;
1090 if(_class.type == structClass)
1092 void (*Get)(unsigned int, void *) = (void *)prop.Get;
1094 exp.instance = Instantiation
1096 data = new0 byte[_class.structSize];
1097 _class = MkSpecifierName/*MkClassName*/(_class.name);
1100 //exp.instance.fullSet = true;
1101 exp.type = instanceExp;
1102 Get(value, exp.instance.data);
1103 PopulateInstance(exp.instance);
1105 else if(_class.type == bitClass)
1107 unsigned int (*Get)(unsigned int) = (void *)prop.Get;
1108 uint64 bits = Get(value);
1109 exp.constant = PrintHexUInt64(bits);
1110 exp.type = constantExp;
1116 else if(_class.type == structClass)
1118 char * value = (memberExp.type == instanceExp ) ? memberExp.instance.data : null;
1123 Class _class = type._class.registered;
1124 if(_class.type == structClass && value)
1126 void (*Get)(void *, void *) = (void *)prop.Get;
1128 exp.instance = Instantiation
1130 data = new0 byte[_class.structSize];
1131 _class = MkSpecifierName/*MkClassName*/(_class.name);
1134 //exp.instance.fullSet = true;
1135 exp.type = instanceExp;
1136 Get(value, exp.instance.data);
1137 PopulateInstance(exp.instance);
1145 char * value = memberExp.instance.data;
1150 Class _class = type._class.registered;
1151 if(_class.type == normalClass)
1153 void *(*Get)(void *) = (void *)prop.Get;
1155 exp.instance = Instantiation
1157 data = Get(value, exp.instance.data); ?????
1158 _class = MkSpecifierName(_class.name); //MkClassName(_class.name);
1161 exp.type = instanceExp;
1173 exp.isConstant = false;
1178 if(memberExp.hasAddress || memberExp.type == constantExp)
1179 //if(memberExp.expType && memberExp.expType.kind == intType) // && !exp.index.exp.expType.isSigned
1181 if(_class.type == bitClass)
1183 if(memberExp.type == constantExp)
1185 // Unfinished business...
1186 BitMember bitMember = (BitMember)member;
1188 GetUInt64(memberExp, &bits);
1189 bits &= bitMember.mask;
1190 bits >>= bitMember.pos;
1192 FreeExpression(exp.member.exp);
1193 FreeIdentifier(exp.member.member);
1195 exp.constant = PrintUInt64(bits);
1197 exp.isConstant = true;
1198 exp.type = constantExp;
1199 exp.hasAddress = false;
1204 char * evaluation = null;
1205 ExpressionType evalError = dummyExp;
1207 Expression prev = exp.prev, next = exp.next;
1211 TypeKind kind = dummyType;
1212 Type dataType = member.dataType;
1215 dataType = member.dataType = ProcessTypeString(member.dataTypeString, false);
1217 if(dataType.kind == classType && dataType._class.registered &&
1218 (dataType._class.registered.type == enumClass || dataType._class.registered.type == bitClass || dataType._class.registered.type == unitClass))
1220 if(dataType._class.registered.dataTypeString)
1221 dataType._class.registered.dataType = ProcessTypeString(dataType._class.registered.dataTypeString, false);
1222 dataType = dataType._class.registered.dataType;
1224 dataType = ProcessTypeString("int", false);
1227 size = ComputeTypeSize(member.dataType);
1229 format = GetGdbFormatChar(dataType);
1230 //if(memberExp.address)
1232 //GetInt(memberExp, &address);
1233 //offset = member.offset;
1235 // TESTING NOHEAD HERE?
1236 if(_class.type == normalClass || _class.type == noHeadClass || _class.type == systemClass)
1237 offset += member._class.offset;
1239 // VERIFY THIS: (trying to fix primitive.type)
1240 // if(memberExp.type == constantExp)
1241 if(memberExp.hasAddress && (_class.type != normalClass && _class.type != noHeadClass && _class.type != systemClass))
1242 address = memberExp.address;
1243 else if(memberExp.type == constantExp)
1244 GetUInt64(memberExp, &address);
1248 GetUInt64(memberExp, &address);
1249 //printf("Unhandled !!\n");
1251 //printf("memberExp.hasAddress = %d\n", memberExp.hasAddress);
1252 //printf("memberExp.type = %d\n", memberExp.type);
1253 //printf("_class.name = %s, _class.type = %d\n", _class.name, _class.type);
1258 if((dataType.kind == classType && dataType._class &&
1259 (!dataType._class.registered || dataType._class.registered.type == normalClass || dataType._class.registered.type == noHeadClass || dataType._class.registered.type == systemClass)) ||
1260 (dataType.kind != classType && dataType.kind != arrayType && dataType.kind != structType && dataType.kind != unionType))
1262 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
1263 if(evalError != dummyExp)
1265 exp.type = evalError;
1266 exp.constant = PrintHexUInt64(address);
1270 //printf("evaluation = %s\n", evaluation);
1271 expNew = ParseExpressionString(evaluation);
1273 expNew.destType = exp.expType;
1275 exp.expType.refCount++;
1276 //FreeType(memberExp.destType);
1277 FreeType(exp.expType);
1278 FreeType(exp.destType);
1279 FreeExpContents(exp);
1280 ProcessExpressionType(expNew);
1281 DebugComputeExpression(expNew);
1284 expNew.isConstant = true;
1285 expNew.address = address;
1286 expNew.hasAddress = true;
1291 exp.type = unknownErrorExp;
1295 // TESTING THIS HERE...
1296 exp.type = constantExp;
1297 exp.constant = PrintHexUInt64(address);
1299 exp.address = address;
1300 exp.hasAddress = true;
1301 exp.isConstant = true;
1306 // exp.type = ExpUnknownError;
1308 //FreeExpContents(exp);
1309 //exp.constant = PrintUInt64(value);
1310 //exp.type = constantExp;
1315 if(type && (type.kind == structType || type.kind == unionType))
1318 Type memberType = exp.member.member ? FindMemberAndOffset(type, exp.member.member.string, &offset) : null;
1321 char * evaluation = null;
1322 ExpressionType evalError = dummyExp;
1324 Expression prev = exp.prev, next = exp.next;
1326 int size = memberType.size;
1328 Type dataType = memberType;
1329 TypeKind kind = dummyType;
1331 if(dataType.kind == classType && dataType._class.registered &&
1332 (dataType._class.registered.type == enumClass || dataType._class.registered.type == bitClass || dataType._class.registered.type == unitClass))
1333 dataType = dataType._class.registered.dataType;
1335 format = GetGdbFormatChar(dataType);
1337 if(memberExp.hasAddress)
1338 address = memberExp.address;
1339 else if(memberExp.type == constantExp)
1340 GetUInt64(memberExp, &address);
1344 if((dataType.kind == classType && dataType._class &&
1345 (!dataType._class.registered || dataType._class.registered.type == normalClass || dataType._class.registered.type == noHeadClass || dataType._class.registered.type == systemClass)) ||
1346 (dataType.kind != classType && dataType.kind != arrayType && dataType.kind != structType && dataType.kind != unionType))
1348 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
1349 if(evalError != dummyExp)
1351 exp.type = evalError;
1352 exp.constant = PrintHexUInt64(address);
1356 expNew = ParseExpressionString(evaluation);
1358 expNew.destType = exp.expType;
1360 exp.expType.refCount++;
1361 //FreeType(memberExp.destType);
1362 FreeType(exp.expType);
1363 FreeType(exp.destType);
1364 FreeExpContents(exp);
1365 ProcessExpressionType(expNew);
1366 DebugComputeExpression(expNew);
1369 expNew.isConstant = true;
1370 expNew.address = address;
1371 expNew.hasAddress = true;
1376 exp.type = unknownErrorExp;
1380 FreeExpContents(exp);
1382 // TESTING THIS HERE...
1383 exp.type = constantExp;
1384 exp.constant = PrintHexUInt64(address);
1386 exp.address = address;
1387 exp.hasAddress = true;
1388 exp.isConstant = true;
1392 exp.type = memberSymbolErrorExp;
1395 exp.type = memberSymbolErrorExp;
1399 //if(exp.type != memberExp)
1401 //FreeExpression(memberExp);
1402 //FreeIdentifier(memberID);
1407 exp.type = memberSymbolErrorExp;
1413 Type type = ProcessType(exp.typeName.qualifiers, exp.typeName.declarator);
1414 FreeExpContents(exp);
1415 exp.constant = PrintUInt(ComputeTypeSize(type));
1416 exp.type = constantExp;
1422 Symbol classSym = FindClass(exp._class.name);
1423 if(classSym && classSym.registered)
1425 //exp.constant = PrintUInt(classSym.registered.size);
1426 //exp.type = constantExp;
1428 char className[1024];
1429 sprintf(className, "__ecereClass_%s", classSym.string);
1430 FreeExpContents(exp);
1431 exp.type = pointerExp;
1432 exp.member.exp = MkExpIdentifier(MkIdentifier(className));
1433 exp.member.member = MkIdentifier("size");
1439 DebugComputeExpression(exp.cast.exp);
1441 if(ExpressionIsError(exp.cast.exp)) //.type == ExpSymbolError
1442 CarryExpressionError(exp, exp.cast.exp);
1445 exp.hasAddress = exp.cast.exp.hasAddress;
1446 exp.address = exp.cast.exp.address;
1447 if(exp.cast.exp.type == constantExp && exp.expType)
1449 Type type = exp.expType;
1450 if(type.kind == classType && type._class && type._class.registered)
1452 Class _class = type._class.registered;
1453 if(_class.type == unitClass || _class.type == bitClass || _class.type == enumClass)
1455 if(!_class.dataType)
1456 _class.dataType = ProcessTypeString(_class.dataTypeString, false);
1457 type = _class.dataType;
1467 GetChar(exp.cast.exp, &value);
1468 FreeExpContents(exp);
1469 exp.constant = PrintChar(value);
1470 exp.type = constantExp;
1471 exp.isConstant = true;
1475 unsigned char value;
1476 GetUChar(exp.cast.exp, &value);
1477 FreeExpContents(exp);
1478 exp.constant = PrintUChar(value);
1479 exp.type = constantExp;
1480 exp.isConstant = true;
1487 GetShort(exp.cast.exp, &value);
1488 FreeExpContents(exp);
1489 exp.constant = PrintShort(value);
1490 exp.type = constantExp;
1491 exp.isConstant = true;
1495 unsigned short value;
1496 GetUShort(exp.cast.exp, &value);
1497 FreeExpContents(exp);
1498 exp.constant = PrintUShort(value);
1499 exp.type = constantExp;
1500 exp.isConstant = true;
1507 GetInt(exp.cast.exp, &value);
1508 FreeExpContents(exp);
1509 exp.constant = PrintInt(value);
1510 exp.type = constantExp;
1511 exp.isConstant = true;
1516 GetUInt(exp.cast.exp, &value);
1517 FreeExpContents(exp);
1518 exp.constant = PrintUInt(value);
1519 exp.type = constantExp;
1520 exp.isConstant = true;
1527 GetInt64(exp.cast.exp, &value);
1528 FreeExpContents(exp);
1529 exp.constant = PrintInt64(value);
1530 exp.type = constantExp;
1531 exp.isConstant = true;
1536 GetUInt64(exp.cast.exp, &value);
1537 FreeExpContents(exp);
1538 exp.constant = PrintUInt64(value);
1539 exp.type = constantExp;
1540 exp.isConstant = true;
1547 GetUInt64(exp.cast.exp, &value);
1548 FreeExpContents(exp);
1549 if(type.kind == pointerType || type.kind == classType)
1550 exp.constant = PrintHexUInt64(value);
1552 exp.constant = PrintUInt64(value);
1553 exp.type = constantExp;
1554 exp.isConstant = true;
1560 GetFloat(exp.cast.exp, &value);
1561 FreeExpContents(exp);
1562 exp.constant = PrintFloat(value);
1563 exp.type = constantExp;
1564 exp.isConstant = true;
1570 GetDouble(exp.cast.exp, &value);
1571 FreeExpContents(exp);
1572 exp.constant = PrintDouble(value);
1573 exp.type = constantExp;
1574 exp.isConstant = true;
1586 DebugComputeExpression(exp.cond.cond);
1588 if(ExpressionIsError(exp.cond.cond))
1589 CarryExpressionError(exp, exp.cond.cond);
1590 else if(exp.cond.cond.type == constantExp && exp.cond.cond.constant)
1592 Expression e = null;
1593 if(strtol(exp.cond.cond.constant, null, 0))
1595 for(e = exp.cond.exp ? exp.cond.exp->first : null; e; e = e.next)
1597 DebugComputeExpression(e);
1602 if(ExpressionIsError(e))
1604 CarryExpressionError(exp, e);
1608 exp.cond.exp->Remove(e);
1613 e = exp.cond.elseExp;
1616 DebugComputeExpression(e);
1617 if(ExpressionIsError(e))
1619 CarryExpressionError(exp, e);
1623 exp.cond.elseExp = null;
1628 FreeType(exp.expType);
1629 FreeType(exp.destType);
1632 FreeExpContents(exp);
1636 else if(!ExpressionIsError(exp))
1638 FreeExpContents(exp);
1639 exp.type = unknownErrorExp;
1644 FreeExpContents(exp);
1645 exp.type = unknownErrorExp;
1650 FreeExpContents(exp);
1651 exp.type = unknownErrorExp;