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) || e.type == castExp)
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;
412 else if(e.type == castExp)
415 if(exp.op.op == TokenType::sizeOf && e && e.expType)
417 if(e.type == stringExp && e.string)
419 char * string = e.string;
420 int len = strlen(string);
421 char * tmp = new char[len-2+1];
422 len = UnescapeString(tmp, string + 1, len - 2);
424 FreeExpContents(exp);
425 exp.type = constantExp;
426 exp.constant = PrintUInt(len + 1);
430 Type type = e.expType;
432 FreeExpContents(exp);
433 exp.type = constantExp;
434 exp.constant = PrintUInt(ComputeTypeSize(type));
441 DebugComputeExpression(exp.op.exp2);
442 if(ExpressionIsError(exp.op.exp2))
443 expError = exp.op.exp2;
450 DebugComputeExpression(exp.op.exp1);
451 if(ExpressionIsError(exp.op.exp1))
452 expError = exp.op.exp1;
457 if(ExpressionIsError(exp.op.exp2))
458 expError = exp.op.exp2;
463 op1 = GetOperand(exp1);
464 if(op1.type) op1.type.refCount++;
465 op2 = GetOperand(exp2);
466 if(op2.type) op2.type.refCount++;
473 if(ExpressionIsError(exp.op.exp2))
474 expError = exp.op.exp2;
478 if(exp.op.op == '&' || exp.op.op == '*')
480 Expression prev = exp1.prev, next = exp1.next;
482 ExpressionType evalError = dummyExp;
483 char * evaluation = null;
489 //sprintf(temp, "%u", exp1.address);
490 temp = PrintHexUInt64(exp1.address);
491 expNew = ParseExpressionString(temp);
493 //expNew.address = exp1.address;
494 expNew.expType = exp.expType;
496 expNew.destType = exp.expType;
497 expNew.destType.refCount++;
499 FreeType(exp.destType);
500 FreeExpContents(exp);
501 ProcessExpressionType(expNew);
502 DebugComputeExpression(expNew);
505 expNew.isConstant = true;
512 else if(exp.op.op == '*')
517 FreeExpContents(exp1);
518 exp1.type = dereferenceErrorExp;
526 if(exp1.expType.kind == structType)
527 address = exp1.address;
529 GetUInt64(exp1, &address);
530 size = ComputeTypeSize(exp.expType); //exp.expType.arrayType.size;
531 format = GetGdbFormatChar(exp.expType);
534 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
540 expNew = ParseExpressionString(evaluation);
541 expNew.address = address;
542 expNew.hasAddress = true;
544 expNew.destType = exp.expType;
545 FreeType(exp.destType);
546 FreeExpContents(exp);
547 ProcessExpressionType(expNew);
548 DebugComputeExpression(expNew);
551 expNew.isConstant = true;
557 // Unhandled code path, evaluation is null
558 FreeExpContents(exp);
559 exp.type = unknownErrorExp;
564 FreeExpContents(exp1);
565 exp1.type = evalError;
566 exp1.constant = PrintHexUInt64(address);
571 FreeExpContents(exp1);
572 exp1.type = evalError;
580 FreeExpContents(exp1);
581 exp1.type = unknownErrorExp; // Not supported yet, generate error to fallback to GDB printout
588 op1 = GetOperand(exp1);
589 if(op1.type) op1.type.refCount++;
594 CarryExpressionError(exp, expError);
595 else if(exp.type == opExp)
597 // TODO: check condition
598 if((exp.op.op == '+' || exp.op.op == '-') && op1.type && op2.type &&
599 (op1.type.kind == arrayType || op1.type.kind == pointerType) && op2.type.kind == intType)
601 // TODO: Do pointer operations
602 if(exp1.expType && exp1.expType.type)
604 if(exp1.type == stringExp)
606 uint64 offset = (exp.op.op == '+') ? op2.i64 : -op2.i64;
607 String newString = null;
610 int len = strlen(exp1.string) - 2;
611 char * tmp = OffsetEscapedString(exp1.string + 1, len, (int)offset);
614 len -= tmp - (exp1.string + 1);
615 newString = new char[2 + len];
617 memcpy(newString + 1, tmp, len);
618 newString[1 + len] = '\"';
619 newString[1 + len + 1] = 0;
622 FreeExpContents(exp);
625 exp.type = stringExp;
626 exp.string = newString;
629 exp.type = dereferenceErrorExp;
633 uint size = ComputeTypeSize(exp1.expType.type);
636 op1.ui64 /= exp1.expType.type.size;
637 CallOperator(exp, exp1, exp2, op1, op2);
638 if(exp.type == constantExp)
640 exp.address = _strtoui64(exp.constant, null, 0);
642 if(op1.type.kind == arrayType)
643 exp.hasAddress = true;
651 if((exp1 && exp1.type == stringExp) || (exp2 && exp2.type == stringExp))
653 FreeExpContents(exp);
654 exp.type = unknownErrorExp; // We should have an invalid operands error
657 CallOperator(exp, exp1, exp2, op1, op2);
659 if(op1.type) FreeType(op1.type);
660 if(op2.type) FreeType(op2.type);
661 exp.isConstant = true;
669 // e = (*exp.list).first, n = e ? e.next : null;
671 // e = n, n = n?(n.next) : null)
673 for(e = exp.list->first; e; e = n)
678 OldList * list = exp.list;
679 DebugComputeExpression(e);
680 //if(ExpressionIsError(e)) //.type == ExpSymbolError
681 // CarryExpressionError(exp, e);
682 //FreeExpContents(exp);
683 FreeType(exp.expType);
684 FreeType(exp.destType);
701 exp.isConstant = true;
703 DebugComputeExpression(exp.index.exp);
704 if(ExpressionIsError(exp.index.exp)) //.type == ExpSymbolError
705 CarryExpressionError(exp, exp.index.exp);
708 Expression prev = exp.prev, next = exp.next;
709 char * evaluation = null;
710 ExpressionType evalError = dummyExp;
712 if(!exp.index.exp.isConstant)
713 exp.isConstant = false;
716 // 4 == size = ComputeTypeSize(exp.expType);
717 // 0 == size = ComputeTypeSize(exp.expType.arrayType);
718 // 4 == size = ComputeTypeSize(exp.index.exp.expType);
719 // 0 == size = ComputeTypeSize(exp.index.exp.expType.arrayType);
721 size = ComputeTypeSize(exp.expType);
722 if(exp.expType && exp.expType.type && exp.expType.kind == arrayType)
723 // For multilevels arrays
726 format = GetGdbFormatChar(exp.expType);
728 for(e = exp.index.index->first; e; e = e.next)
730 DebugComputeExpression(e);
731 if(ExpressionIsError(e)) //.type == ExpSymbolError
733 CarryExpressionError(exp, e);
738 // Check if this type is int
741 exp.isConstant = false;
743 if(!ExpressionIsError(exp))
745 // Is this necessary here? pass15 had done this already...
746 if(exp.expType) FreeType(exp.expType);
747 exp.expType = Dereference(exp.index.exp.expType);
752 FreeExpContents(exp);
753 exp.type = dereferenceErrorExp;
755 else if(exp.index.index && exp.index.index->last && ((Expression)exp.index.index->last) && ((Expression)exp.index.index->last).expType)
757 Type type = ((Expression)exp.index.index->last).expType;
758 if(type.kind == intType || type.kind == charType || type.kind == shortType || type.kind == int64Type || type.kind == intPtrType ||
759 type.kind == intSizeType || type.kind == longType || type.kind == _BoolType || type.kind == enumType ||
760 (type.kind == classType && type._class && type._class.registered &&
761 type._class.registered.type == enumClass))
763 uint64 address = 0, offset = 0;
764 Expression expNew, last = (Expression)exp.index.index->last;
765 //GetUInt(exp.index.exp, &address);
767 // TOFIX: Check if it has address: TESTING
768 if(exp.index.exp.hasAddress && (exp.index.exp.expType.kind == arrayType))
769 address = exp.index.exp.address;
770 else if(exp.index.exp.type == constantExp)
771 GetUInt64(exp.index.exp, &address);
773 GetUInt64(last, &offset);
774 //size = ComputeTypeSize(exp.expType.arrayType); //exp.expType.arrayType.size;
775 address += offset * size;
776 if(exp.index.exp.type == stringExp)
778 String string = exp.index.exp.string;
784 int len = string ? strlen(string) : 0;
785 tmp = new char[len-2+1];
786 len = UnescapeString(tmp, string + 1, len - 2);
787 if(len >= 0 && offset <= len)
789 ch = offset < len ? tmp[offset] : 0;
794 FreeExpContents(exp);
797 exp.type = constantExp;
798 exp.constant = PrintChar(ch);
801 exp.type = dereferenceErrorExp;
803 else if(exp.expType.kind == arrayType)
805 FreeExpContents(exp);
806 exp.type = constantExp;
807 exp.isConstant = true;
808 exp.constant = PrintHexUInt64(address);
809 exp.address = address;
810 exp.hasAddress = true;
814 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
820 expNew = ParseExpressionString(evaluation);
822 expNew.destType = exp.expType;
823 FreeType(exp.destType);
824 FreeExpContents(exp);
825 ProcessExpressionType(expNew);
826 DebugComputeExpression(expNew);
828 // TOFIX: Only for Array Types
829 expNew.address = address;
831 expNew.hasAddress = true;
834 expNew.isConstant = true;
840 // Unhandled code path, evaluation is null
841 FreeExpContents(exp);
842 exp.type = unknownErrorExp;
847 FreeExpContents(exp);
848 exp.type = evalError;
849 exp.constant = PrintHexUInt64(address);
853 FreeExpContents(exp);
854 exp.type = evalError;
866 Expression memberExp = exp.member.exp;
867 Identifier memberID = exp.member.member;
869 Property prop = null;
870 DataMember member = null;
871 Class convertTo = null;
872 uint offset = 0; // THIS WASN'T INITIALIZED... IS IT ALWAYS SET?
874 Type type; // = memberExp.expType;
875 DebugComputeExpression(memberExp);
876 type = memberExp.expType;
877 if(ExpressionIsError(memberExp))
878 CarryExpressionError(exp, memberExp);
881 // _class = (memberID && memberID.classSym) ? memberID.classSym.registered : ((type.kind == classType && type._class) ? type._class.registered : null);
882 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);
885 char string[256] = "";
887 PrintTypeNoConst(type, string, false, true);
888 classSym = FindClass(string);
889 _class = classSym ? classSym.registered : null;
892 if(memberID && _class)
895 prop = eClass_FindProperty(_class, memberID.string);
897 member = eClass_FindDataMember(_class, memberID.string);
899 // member = eClass_FindDataMember(_class, memberID.string);
900 member = eClass_FindDataMemberAndOffset(_class, memberID.string, &offset, _class.module.application, null, null);
902 prop = eClass_FindProperty(_class, memberID.string, _class.module.application);
904 if(!prop && !member && _class && memberID)
906 Symbol classSym = FindClass(memberID.string);
908 _class = classSym ? classSym.registered : null;
910 prop = eClass_FindProperty(_class, convertTo.name, _class.module.application);
913 //DebugComputeExpression(memberExp);
914 if(ExpressionIsError(memberExp))
915 CarryExpressionError(exp, memberExp);
922 Type type = prop.dataType;
923 // TODO: Assuming same base type for units...
924 if(_class.type == unitClass)
926 if(type.kind == classType)
928 Class _class = type._class.registered;
929 if(_class.type == unitClass)
932 _class.dataType = ProcessTypeString(_class.dataTypeString, false);
933 type = _class.dataType;
941 float (*Get)(float) = (void *)prop.Get;
942 GetFloat(memberExp, &value);
943 exp.constant = PrintFloat(Get ? Get(value) : value);
944 exp.type = constantExp;
950 double (*Get)(double);
951 GetDouble(memberExp, &value);
954 Get = (void *)prop.Set;
956 Get = (void *)prop.Get;
957 exp.constant = PrintDouble(Get ? Get(value) : value);
958 exp.type = constantExp;
967 Expression value = memberExp;
968 Type type = prop.dataType;
969 if(_class.type == structClass)
975 Class propertyClass = type._class.registered;
976 if(propertyClass.type == structClass && value.type == instanceExp)
978 void (*Set)(void *, void *) = (void *)prop.Set;
979 exp.instance = Instantiation
981 data = new0 byte[_class.structSize];
982 _class = MkSpecifierName/*MkClassName*/(_class.name);
984 exp.type = instanceExp;
986 Set(exp.instance.data, value.instance.data);
987 PopulateInstance(exp.instance);
994 void (*Set)(void *, int) = (void *)prop.Set;
996 exp.instance = Instantiation
998 data = new0 byte[_class.structSize];
999 _class = MkSpecifierName/*MkClassName*/(_class.name);
1002 exp.type = instanceExp;
1004 GetInt(value, &intValue);
1006 Set(exp.instance.data, intValue);
1007 PopulateInstance(exp.instance);
1013 void (*Set)(void *, int64) = (void *)prop.Set;
1015 exp.instance = Instantiation
1017 data = new0 byte[_class.structSize];
1018 _class = MkSpecifierName/*MkClassName*/(_class.name);
1021 exp.type = instanceExp;
1023 GetInt64(value, &intValue);
1025 Set(exp.instance.data, intValue);
1026 PopulateInstance(exp.instance);
1032 void (*Set)(void *, double) = (void *)prop.Set;
1034 exp.instance = Instantiation
1036 data = new0 byte[_class.structSize];
1037 _class = MkSpecifierName/*MkClassName*/(_class.name);
1040 exp.type = instanceExp;
1042 GetDouble(value, &doubleValue);
1044 Set(exp.instance.data, doubleValue);
1045 PopulateInstance(exp.instance);
1050 else if(_class.type == bitClass)
1056 Class propertyClass = type._class.registered;
1057 if(propertyClass.type == structClass && value.instance.data)
1059 unsigned int (*Set)(void *) = (void *)prop.Set;
1060 unsigned int bits = Set(value.instance.data);
1061 exp.constant = PrintHexUInt(bits);
1062 exp.type = constantExp;
1065 else if(_class.type == bitClass)
1068 unsigned int (*Set)(unsigned int) = (void *)prop.Set;
1071 GetUInt(memberExp, &value);
1073 exp.constant = PrintHexUInt(bits);
1074 exp.type = constantExp;
1082 if(_class.type == bitClass)
1085 GetUInt(memberExp, &value);
1091 Class _class = type._class.registered;
1092 if(_class.type == structClass)
1094 void (*Get)(unsigned int, void *) = (void *)prop.Get;
1096 exp.instance = Instantiation
1098 data = new0 byte[_class.structSize];
1099 _class = MkSpecifierName/*MkClassName*/(_class.name);
1102 //exp.instance.fullSet = true;
1103 exp.type = instanceExp;
1104 Get(value, exp.instance.data);
1105 PopulateInstance(exp.instance);
1107 else if(_class.type == bitClass)
1109 unsigned int (*Get)(unsigned int) = (void *)prop.Get;
1110 uint64 bits = Get(value);
1111 exp.constant = PrintHexUInt64(bits);
1112 exp.type = constantExp;
1118 else if(_class.type == structClass)
1120 char * value = (memberExp.type == instanceExp ) ? memberExp.instance.data : null;
1125 Class _class = type._class.registered;
1126 if(_class.type == structClass && value)
1128 void (*Get)(void *, void *) = (void *)prop.Get;
1130 exp.instance = Instantiation
1132 data = new0 byte[_class.structSize];
1133 _class = MkSpecifierName/*MkClassName*/(_class.name);
1136 //exp.instance.fullSet = true;
1137 exp.type = instanceExp;
1138 Get(value, exp.instance.data);
1139 PopulateInstance(exp.instance);
1147 char * value = memberExp.instance.data;
1152 Class _class = type._class.registered;
1153 if(_class.type == normalClass)
1155 void *(*Get)(void *) = (void *)prop.Get;
1157 exp.instance = Instantiation
1159 data = Get(value, exp.instance.data); ?????
1160 _class = MkSpecifierName(_class.name); //MkClassName(_class.name);
1163 exp.type = instanceExp;
1175 exp.isConstant = false;
1180 if(memberExp.hasAddress || memberExp.type == constantExp)
1181 //if(memberExp.expType && memberExp.expType.kind == intType) // && !exp.index.exp.expType.isSigned
1183 if(_class.type == bitClass)
1185 if(memberExp.type == constantExp)
1187 // Unfinished business...
1188 BitMember bitMember = (BitMember)member;
1190 GetUInt64(memberExp, &bits);
1191 bits &= bitMember.mask;
1192 bits >>= bitMember.pos;
1194 FreeExpression(exp.member.exp);
1195 FreeIdentifier(exp.member.member);
1197 exp.constant = PrintUInt64(bits);
1199 exp.isConstant = true;
1200 exp.type = constantExp;
1201 exp.hasAddress = false;
1206 char * evaluation = null;
1207 ExpressionType evalError = dummyExp;
1209 Expression prev = exp.prev, next = exp.next;
1213 TypeKind kind = dummyType;
1214 Type dataType = member.dataType;
1217 dataType = member.dataType = ProcessTypeString(member.dataTypeString, false);
1219 if(dataType.kind == classType && dataType._class.registered &&
1220 (dataType._class.registered.type == enumClass || dataType._class.registered.type == bitClass || dataType._class.registered.type == unitClass))
1222 if(dataType._class.registered.dataTypeString)
1223 dataType._class.registered.dataType = ProcessTypeString(dataType._class.registered.dataTypeString, false);
1224 dataType = dataType._class.registered.dataType;
1226 dataType = ProcessTypeString("int", false);
1229 size = ComputeTypeSize(member.dataType);
1231 format = GetGdbFormatChar(dataType);
1232 //if(memberExp.address)
1234 //GetInt(memberExp, &address);
1235 //offset = member.offset;
1237 // TESTING NOHEAD HERE?
1238 if(_class.type == normalClass || _class.type == noHeadClass || _class.type == systemClass)
1239 offset += member._class.offset;
1241 // VERIFY THIS: (trying to fix primitive.type)
1242 // if(memberExp.type == constantExp)
1243 if(memberExp.hasAddress && (_class.type != normalClass && _class.type != noHeadClass && _class.type != systemClass))
1244 address = memberExp.address;
1245 else if(memberExp.type == constantExp)
1246 GetUInt64(memberExp, &address);
1250 GetUInt64(memberExp, &address);
1251 //printf("Unhandled !!\n");
1253 //printf("memberExp.hasAddress = %d\n", memberExp.hasAddress);
1254 //printf("memberExp.type = %d\n", memberExp.type);
1255 //printf("_class.name = %s, _class.type = %d\n", _class.name, _class.type);
1260 if((dataType.kind == classType && dataType._class &&
1261 (!dataType._class.registered || dataType._class.registered.type == normalClass || dataType._class.registered.type == noHeadClass || dataType._class.registered.type == systemClass)) ||
1262 (dataType.kind != classType && dataType.kind != arrayType && dataType.kind != structType && dataType.kind != unionType))
1264 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
1265 if(evalError != dummyExp)
1267 exp.type = evalError;
1268 exp.constant = PrintHexUInt64(address);
1272 //printf("evaluation = %s\n", evaluation);
1273 expNew = ParseExpressionString(evaluation);
1275 expNew.destType = exp.expType;
1277 exp.expType.refCount++;
1278 //FreeType(memberExp.destType);
1279 FreeType(exp.expType);
1280 FreeType(exp.destType);
1281 FreeExpContents(exp);
1282 ProcessExpressionType(expNew);
1283 DebugComputeExpression(expNew);
1286 expNew.isConstant = true;
1287 expNew.address = address;
1288 expNew.hasAddress = true;
1293 exp.type = unknownErrorExp;
1297 // TESTING THIS HERE...
1298 exp.type = constantExp;
1299 exp.constant = PrintHexUInt64(address);
1301 exp.address = address;
1302 exp.hasAddress = true;
1303 exp.isConstant = true;
1308 // exp.type = ExpUnknownError;
1310 //FreeExpContents(exp);
1311 //exp.constant = PrintUInt64(value);
1312 //exp.type = constantExp;
1317 if(type && (type.kind == structType || type.kind == unionType))
1320 Type memberType = exp.member.member ? FindMemberAndOffset(type, exp.member.member.string, &offset) : null;
1323 char * evaluation = null;
1324 ExpressionType evalError = dummyExp;
1326 Expression prev = exp.prev, next = exp.next;
1328 int size = memberType.size;
1330 Type dataType = memberType;
1331 TypeKind kind = dummyType;
1333 if(dataType.kind == classType && dataType._class.registered &&
1334 (dataType._class.registered.type == enumClass || dataType._class.registered.type == bitClass || dataType._class.registered.type == unitClass))
1335 dataType = dataType._class.registered.dataType;
1337 format = GetGdbFormatChar(dataType);
1339 if(memberExp.hasAddress)
1340 address = memberExp.address;
1341 else if(memberExp.type == constantExp)
1342 GetUInt64(memberExp, &address);
1346 if((dataType.kind == classType && dataType._class &&
1347 (!dataType._class.registered || dataType._class.registered.type == normalClass || dataType._class.registered.type == noHeadClass || dataType._class.registered.type == systemClass)) ||
1348 (dataType.kind != classType && dataType.kind != arrayType && dataType.kind != structType && dataType.kind != unionType))
1350 evaluation = Debugger::ReadMemory(address, size, format, &evalError);
1351 if(evalError != dummyExp)
1353 exp.type = evalError;
1354 exp.constant = PrintHexUInt64(address);
1358 expNew = ParseExpressionString(evaluation);
1360 expNew.destType = exp.expType;
1362 exp.expType.refCount++;
1363 //FreeType(memberExp.destType);
1364 FreeType(exp.expType);
1365 FreeType(exp.destType);
1366 FreeExpContents(exp);
1367 ProcessExpressionType(expNew);
1368 DebugComputeExpression(expNew);
1371 expNew.isConstant = true;
1372 expNew.address = address;
1373 expNew.hasAddress = true;
1378 exp.type = unknownErrorExp;
1382 FreeExpContents(exp);
1384 // TESTING THIS HERE...
1385 exp.type = constantExp;
1386 exp.constant = PrintHexUInt64(address);
1388 exp.address = address;
1389 exp.hasAddress = true;
1390 exp.isConstant = true;
1394 exp.type = memberSymbolErrorExp;
1397 exp.type = memberSymbolErrorExp;
1401 //if(exp.type != memberExp)
1403 //FreeExpression(memberExp);
1404 //FreeIdentifier(memberID);
1409 exp.type = memberSymbolErrorExp;
1415 Type type = ProcessType(exp.typeName.qualifiers, exp.typeName.declarator);
1416 FreeExpContents(exp);
1417 exp.constant = PrintUInt(ComputeTypeSize(type));
1418 exp.type = constantExp;
1424 Symbol classSym = FindClass(exp._class.name);
1425 if(classSym && classSym.registered)
1427 //exp.constant = PrintUInt(classSym.registered.size);
1428 //exp.type = constantExp;
1430 char className[1024];
1431 sprintf(className, "__ecereClass_%s", classSym.string);
1432 FreeExpContents(exp);
1433 exp.type = pointerExp;
1434 exp.member.exp = MkExpIdentifier(MkIdentifier(className));
1435 exp.member.member = MkIdentifier("size");
1441 DebugComputeExpression(exp.cast.exp);
1443 if(ExpressionIsError(exp.cast.exp)) //.type == ExpSymbolError
1444 CarryExpressionError(exp, exp.cast.exp);
1447 exp.hasAddress = exp.cast.exp.hasAddress;
1448 exp.address = exp.cast.exp.address;
1449 if(exp.cast.exp.type == constantExp && exp.expType)
1451 Type type = exp.expType;
1452 if(type.kind == classType && type._class && type._class.registered)
1454 Class _class = type._class.registered;
1455 if(_class.type == unitClass || _class.type == bitClass || _class.type == enumClass)
1457 if(!_class.dataType)
1458 _class.dataType = ProcessTypeString(_class.dataTypeString, false);
1459 type = _class.dataType;
1469 GetChar(exp.cast.exp, &value);
1470 FreeExpContents(exp);
1471 exp.constant = PrintChar(value);
1472 exp.type = constantExp;
1473 exp.isConstant = true;
1477 unsigned char value;
1478 GetUChar(exp.cast.exp, &value);
1479 FreeExpContents(exp);
1480 exp.constant = PrintUChar(value);
1481 exp.type = constantExp;
1482 exp.isConstant = true;
1489 GetShort(exp.cast.exp, &value);
1490 FreeExpContents(exp);
1491 exp.constant = PrintShort(value);
1492 exp.type = constantExp;
1493 exp.isConstant = true;
1497 unsigned short value;
1498 GetUShort(exp.cast.exp, &value);
1499 FreeExpContents(exp);
1500 exp.constant = PrintUShort(value);
1501 exp.type = constantExp;
1502 exp.isConstant = true;
1509 GetInt(exp.cast.exp, &value);
1510 FreeExpContents(exp);
1511 exp.constant = PrintInt(value);
1512 exp.type = constantExp;
1513 exp.isConstant = true;
1518 GetUInt(exp.cast.exp, &value);
1519 FreeExpContents(exp);
1520 exp.constant = PrintUInt(value);
1521 exp.type = constantExp;
1522 exp.isConstant = true;
1529 GetInt64(exp.cast.exp, &value);
1530 FreeExpContents(exp);
1531 exp.constant = PrintInt64(value);
1532 exp.type = constantExp;
1533 exp.isConstant = true;
1538 GetUInt64(exp.cast.exp, &value);
1539 FreeExpContents(exp);
1540 exp.constant = PrintUInt64(value);
1541 exp.type = constantExp;
1542 exp.isConstant = true;
1549 GetUInt64(exp.cast.exp, &value);
1550 FreeExpContents(exp);
1551 if(type.kind == pointerType || type.kind == classType)
1552 exp.constant = PrintHexUInt64(value);
1554 exp.constant = PrintUInt64(value);
1555 exp.type = constantExp;
1556 exp.isConstant = true;
1562 GetFloat(exp.cast.exp, &value);
1563 FreeExpContents(exp);
1564 exp.constant = PrintFloat(value);
1565 exp.type = constantExp;
1566 exp.isConstant = true;
1572 GetDouble(exp.cast.exp, &value);
1573 FreeExpContents(exp);
1574 exp.constant = PrintDouble(value);
1575 exp.type = constantExp;
1576 exp.isConstant = true;
1588 DebugComputeExpression(exp.cond.cond);
1590 if(ExpressionIsError(exp.cond.cond))
1591 CarryExpressionError(exp, exp.cond.cond);
1592 else if(exp.cond.cond.type == constantExp && exp.cond.cond.constant)
1594 Expression e = null;
1595 if(strtol(exp.cond.cond.constant, null, 0))
1597 for(e = exp.cond.exp ? exp.cond.exp->first : null; e; e = e.next)
1599 DebugComputeExpression(e);
1604 if(ExpressionIsError(e))
1606 CarryExpressionError(exp, e);
1610 exp.cond.exp->Remove(e);
1615 e = exp.cond.elseExp;
1618 DebugComputeExpression(e);
1619 if(ExpressionIsError(e))
1621 CarryExpressionError(exp, e);
1625 exp.cond.elseExp = null;
1630 FreeType(exp.expType);
1631 FreeType(exp.destType);
1634 FreeExpContents(exp);
1638 else if(!ExpressionIsError(exp))
1640 FreeExpContents(exp);
1641 exp.type = unknownErrorExp;
1646 FreeExpContents(exp);
1647 exp.type = unknownErrorExp;
1652 FreeExpContents(exp);
1653 exp.type = unknownErrorExp;