Page 1 of 4
Finding ErrorStack
Posted: Wed Apr 15, 2020 11:42 am
by leon-ts
Hi devteam!
When compiling the transported VO code, it generated an error "The name 'ErrorStack' does not exist in the current context". XSharp does not support this functionality or is it necessary to configure something?
P.S. From my point of view, this function is easily reproduced in NET using System.Diagnostics.StackTrace.
Best regards,
Leonid
Finding ErrorStack
Posted: Wed Apr 15, 2020 2:07 pm
by Chris
Hi Leonid,
This is not a documented function in VO, so probably it was just overlooked. Maybe Robert is aware of it (especially since he was the person maintaining VO for some years), but for me it's the first time I hear about it. What does it do exactly?
Finding ErrorStack
Posted: Wed Apr 15, 2020 2:15 pm
by leon-ts
Hi Chris,
The ErrorStack() function returns the current call stack, which appears as "CallStack: ..." in error messages in VO.
For example:
MYFUNC (Line:50)
MYCLASS:MYMETHOD (Line:100)
START (Line:5)
My colleagues and I quite often use it to find problems.
Finding ErrorStack
Posted: Wed Apr 15, 2020 2:21 pm
by Chris
Hi Leonid,
OK, thanks, I will add it for the next build. In the meantime of course you can also implement it yourself in your code, or I can send you the code.
Edit: Line information will not be the same as in VO though, it cannot point to the _entity_ line number. Instead you will get a file line number.
Finding ErrorStack
Posted: Wed Apr 15, 2020 2:27 pm
by leon-ts
Thanks Chris,
I already wrote for myself (it is quite simple in implementation), but when it appears as part of XSharp, I will delete my implementation.
Finding ErrorStack
Posted: Wed Apr 15, 2020 2:41 pm
by Chris
Hi Leonid,
Oh, in this case, why don't you save us the time to implement it and just post the source code of your implementation here?
Finding ErrorStack
Posted: Wed Apr 15, 2020 2:53 pm
by leon-ts
With pleasure! I tried to make the return result exactly the same as it was in VO. The code may not comply with the writing rules for NET or something else is missing, but you can fix it as you wish.
Best regards,
Leonid
Finding ErrorStack
Posted: Wed Apr 15, 2020 3:01 pm
by Chris
Hi Leonid,
The code looks fine to me, thanks a lot for sending! It only needs a couple small adjustments, the nActivation param is typed as a DWORD in VO and also in the result you need to omit the call to the function itself, try this in VO and X# to compare the results:
Code: Select all
FUNCTION Start() AS INT
FUNCTION1()
RETURN 0
FUNCTION FUNCTION1() AS VOID
Func2()
FUNCTION Func2() AS VOID
? ErrorStack()
? ErrorStack(0)
? ErrorStack(1)
? ErrorStack(2)
but the adjustments needed are very minor, thanks again!
Finding ErrorStack
Posted: Wed Apr 15, 2020 3:10 pm
by leon-ts
I did dwActivation as a DWORD at first, but the XSharp compiler threw a cast error (StackFrame:FrameCount declared as INT). I did not do type casting, but simply did nActivation as INT (without control over negative values).
Finding ErrorStack
Posted: Wed Apr 15, 2020 4:02 pm
by wriedmann
Hi All,
please note that line numbers will only show up if you deliver a current pdb file with your binaries.
I'm doing that all the time:
- ServerMan.png (46.79 KiB) Viewed 683 times
Wolfgang