YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Little sq_stackinfos line problem
flipper
#1 Posted : Wednesday, March 28, 2012 6:53:30 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/27/2012(UTC)
Posts: 5

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I don't know how to report line information in a called proxy function so that the line number is always correct.

First of all, is there a const char* sq_file_line_column(HSQUIRRELVM) or so that I could use?

ATM I call sq_stackinfos and have the problem, that si.line is already incremented, although my proxy function did not yet return.

The problem is:

foo(); // in foo(): correct line number = reporting si.line - 1
bar();

foo(); bar(); // in foo(): correct line number = si.line

Also, can I report the column too?

Thanks, kind regards
Markus
cue
#2 Posted : Wednesday, March 28, 2012 6:23:04 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/3/2011(UTC)
Posts: 60
Man

Thanks: 0 times
Was thanked: 4 time(s) in 4 post(s)
I'm afraid I don't understand what exactly is your problem, but as far as I know sq_stackinfos() is the only way to trace down runtime errors (apart from a squirrel debugger of course). Unfortunately I also found that the line number returned in si.line actually references the line after the line that caused the error.
flipper
#3 Posted : Wednesday, March 28, 2012 6:56:29 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/27/2012(UTC)
Posts: 5

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
cue wrote:
I'm afraid I don't understand what exactly is your problem, but as far as I know sq_stackinfos() is the only way to trace down runtime errors (apart from a squirrel debugger of course). Unfortunately I also found that the line number returned in si.line actually references the line after the line that caused the error.


yes, and it seems, si.line icrements in the last statement, before the native closure (if that's the statement) is called.

so with squirrel lines that have multiple statements, always reporting si.line - 1 is wrong except for the last statement.
flipper
#4 Posted : Wednesday, March 28, 2012 9:53:22 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/27/2012(UTC)
Posts: 5

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
well, i've patched my sqdebug.cpp

- si->line = func->GetLine(ci._ip);
+ si->line = func->GetLine(ci._ip - 1);

i guess: at ip - 1 is the call instruction, not the next one (call instruction is over in the callee)

seems to work for the very first statement in a .nut file too
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.091 seconds.