Angelscript on Raspberry Pi
#61 Members - Reputation: 475
Posted 30 November 2012 - 10:30 AM
What do you mean with "cleaning up the stack"? I guess it means setting the stack pointer to where it was when it entered the function? I was thinking that comparing the sp´s value right after the push with the value right before the pop at the end of the function should give the same result, right? If results match, does it mean the stack is being cleared properly?
I´ve had care to keep and restore the values of the registers I use in the functions, and to only use registers marked as "general purpose" or "scratch", BTW.
#62 Moderators - Reputation: 2309
Posted 30 November 2012 - 10:53 AM
If you backup the registers and stick to general purpose or scratch registers then the problem is most likely to be just the stackpointer.
You mentioned earlier that you access your environment with VPN. If you'd like to give me access to the environment I may be able to do some investigation on my own. I don't promise anything, but I may find a little time to look into this.
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
#63 Members - Reputation: 475
Posted 30 November 2012 - 11:38 AM
Let me know where to send you the information about remote accessing my RPi and any other information you´d think will be useful and then you can log in any time you want - just let me know when you´re using it so I don´t interfere.
#64 Moderators - Reputation: 2309
Posted 30 November 2012 - 12:13 PM
Of course, I'll need to know the directory where you're testing so I can have a look at the code. and do some tests. Also, I'll need to know what compilation flags you use. Or do you simply call make for the gnuc projects?
I assume I'll have access via SSH or Telnet, right?
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
#67 Moderators - Reputation: 2309
Posted 01 December 2012 - 11:33 AM
Try commenting out the #define AS_CALLEE_DESTROY_OBJ_BY_VAL on line 741 in as_config.h.
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
#68 Members - Reputation: 475
Posted 02 December 2012 - 12:13 AM
memcpy (value, &it->second.valueInt, size);
It happens the third time this function is called, when passing "c". I suspect "value" isn´t getting the right, well, value (no pun intended).
#69 Moderators - Reputation: 2309
Posted 02 December 2012 - 09:20 AM
The original as_callfunc_arm.cpp should have been working with this, but depending on the changes you made, you may have accidentally broken it.
You can identify the variable argument type with the following condition:
if( descr->parameterTypes[n].GetTokenType() == ttQuestion )
{
// Treat the variable argument type as two separate args, one pointer and one int
...
}
As both the pointer and the int will go to the generic paramBuffer, it should just be a matter of copying both normally. Remember, even though this type would be identified as taking up 64bits on the stack with GetSizeOnStackDWords() it shouldn't be aligned to a 64bit boundary.
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
#70 Members - Reputation: 475
Posted 03 December 2012 - 12:42 PM
Apparently I was wrong about the point where the failure happens. On one hand I wasn´t checking for the variable argument type, but that wasnñt causing the problem (I´ve added acheck for that nevertheless). The seg fault is caused by this part of the script:
// Test float with the dictionary
" float f = 300; \n"
" dict.set('c', f); \n"
" dict.get('c', f); \n" // Seg fault
" assert(f == 300); \n"The float is being received by the app as a double, BTW. Any ideas?
#71 Moderators - Reputation: 2309
Posted 03 December 2012 - 03:38 PM
That gives me an idea of the problem. When you check if a parameter is a float or double, do you also check to make sure it is not a reference? I.e. !descr->parameterTypes[n].IsReference()?
If the argument is a reference, it should be treated as a integer as it is the address that is being passed to the function, not the float value.
I think this was my mistake, I forgot to tell you about checking for references earlier.
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
#72 Members - Reputation: 475
Posted 03 December 2012 - 09:14 PM
The tests that are still failling are:
TestScriptString
TestRegisterType
TestVector3
TestStdString
Can you see anything in common between these tests?
The TestCompiler is also crashing - what´s more, this one even crashes the app but I have a very good idea of what´s wrong and how ti fix it.
I´ll begin by looking at the TestScriptString. It fails here:
ExecuteString(engine, "print(1.2 + \"a\")");
if( printOutput != "1.2a")
{
printf("Get '%s'\n", printOutput.c_str());
TEST_FAILED;
}
Edited by Tzarls, 03 December 2012 - 09:52 PM.
#73 Moderators - Reputation: 2309
Posted 04 December 2012 - 07:01 AM
The test will call the following registered function:
static CScriptString *AddFloatString(float f, const CScriptString &str)
{
char buf[100];
sprintf(buf, "%g", f);
return new CScriptString(buf + str.buffer);
}
So it should pass the float f in s0, the string pointer str in r0, and then return the new string pointer in r0. Is this what is happening?
The function is registered with asCALL_CDECL_OBJLAST, so perhaps that may be the reason for the failure.
All of the tests that fail actually test a lot of different functionality, so I need to know on which particular test that they fail on. The best would be if you can tell me the line number where the test is reporting that it is failing. Then I can have a look at the code and try to think of what can be wrong.
Regards,
Andreas
Edited by Andreas Jonsson, 04 December 2012 - 07:01 AM.
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
#74 Members - Reputation: 475
Posted 04 December 2012 - 07:33 AM
string@ _string_factory_(const int, const uint8&)
Returns an object, and the calls (ICC_CDECL_OBJLAST)
string@ string::opAdd_r(double) const
This also returns an object. Then it prints:
Get '11.8998a'
Failed on line 254... (which is the last line of the code I copied in my previous post)
#75 Moderators - Reputation: 2309
Posted 04 December 2012 - 08:48 AM
It would appear that armFuncObjLast is not working properly. It's setting the string pointer in the r0 register as it should, but it is not setting s0 with the float value as it should.
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
#77 Moderators - Reputation: 2309
Posted 04 December 2012 - 02:10 PM
It should be a double, and it should be d0. The function that will be called is the AddDoubleString() and not the AddFloatString() as I said before.
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
#78 Members - Reputation: 475
Posted 06 December 2012 - 10:40 AM
armFuncObjLast:
stmfd sp!, {r4-r8, r10, lr}
// Magic begins....
.......
blx r4
fstmiad r10, {d0-d7} // Copy contents of registers d0-d10 to the address stored in r10
add sp, sp, r8 // sp += r8 sets sp to its original value
str sp, [r10, #68] // store final sp value - for checks only, should be taken out in finalcode
ldmfd sp!, {r4-r8, r10, pc}
This doesn´t work for the TestScriptString test. But if I change:
armFuncObjLast:
stmfd sp!, {r4-r8, r10, lr}
To this:
armFuncObjLast:
stmfd sp!, {r4-r8, r10, r11, lr}
(With the corresponding change to the epilog) then the test passes! Is this some kind of alignment problem?
Edited by Tzarls, 06 December 2012 - 10:41 AM.
#79 Moderators - Reputation: 2309
Posted 06 December 2012 - 12:21 PM
Does this change break anything else? Otherwise I'd suggest you leave it like this (just put a comment so we can remember why r11 is being backed up too).
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
#80 Members - Reputation: 475
Posted 06 December 2012 - 02:26 PM
"The ARM-THUMB Procedure Call Standard
The new ATPCS requires that sp always points to 8-byte boundaries. Your assembly language code must preserve 8-byte alignment of the stack at all external interfaces."






