Finding ErrorStack

This forum is meant for questions and discussions about the X# language and tools
leon-ts
Posts: 429
Joined: Fri Feb 03, 2017 1:43 pm

Finding ErrorStack

Post 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
Best regards,
Leonid
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Finding ErrorStack

Post 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?
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
leon-ts
Posts: 429
Joined: Fri Feb 03, 2017 1:43 pm

Finding ErrorStack

Post 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.
Best regards,
Leonid
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Finding ErrorStack

Post 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.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
leon-ts
Posts: 429
Joined: Fri Feb 03, 2017 1:43 pm

Finding ErrorStack

Post 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.
Best regards,
Leonid
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Finding ErrorStack

Post 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? :)
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
leon-ts
Posts: 429
Joined: Fri Feb 03, 2017 1:43 pm

Finding ErrorStack

Post 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
Attachments
ErrorStack.zip
(513 Bytes) Downloaded 27 times
Best regards,
Leonid
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Finding ErrorStack

Post 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!
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
leon-ts
Posts: 429
Joined: Fri Feb 03, 2017 1:43 pm

Finding ErrorStack

Post 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).
Best regards,
Leonid
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Finding ErrorStack

Post 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
ServerMan.png (46.79 KiB) Viewed 305 times
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply