Page 1 of 1

Debugging tips?

Posted: Wed Jun 05, 2013 10:59 am
by Janschenkel
Hi guys,

While working on the filter enhancements, I ran into problems where the IDE decided to not start completely - I guess because it uses the 'filter' command extensively and I screwed the pooch :-(
So I decided to test my work by adding a 'tinker' command and putting the code into it. I followed the recipe for the 'map' command and the script editor does recognize the 'tinker' command as a built-in thing, but fails to parse things. So obviously I made a mistake in my code.
Now I'd like to debug to see where I went wrong.

I'm using the latest Xcode on OS X Mountain Lion.
I set a breakpoint on the line where I want to start debugging, but it never seems to get there.

Can anyone give me hints as to how I can debug?

TIA,

Jan Schenkel.

Re: Debugging tips?

Posted: Wed Jun 05, 2013 6:36 pm
by mwieder
<not at an OSX machine at the moment> Does OSX support strace? gdb?
Any hints in the console log?

Re: Debugging tips?

Posted: Wed Jun 05, 2013 8:40 pm
by LCMark
The script editor syntax highlighting is derived from the keyword tables - so if it's highlighting but not parsing it might be that you've missed adding the tinker command's constructor to the MCN_new_statement in newobj.cpp.

An alternative option is to debug your filter changes in the standalone engine with a stack that just has your script for testing it out. You can do this by running the standalone target in debug mode and setting a TEST_STACK environment variable to point to the stack to load on startup.

Re: Debugging tips?

Posted: Wed Jun 05, 2013 9:18 pm
by Janschenkel
Looks like I have gdb and it's running as soon as I launch LiveCode from within Xcode.
Here's the beginning of the Xcode console output:

Code: Select all

GNU gdb 6.3.50-20050815 (Apple version gdb-1824) (Wed Feb  6 22:51:23 UTC 2013)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
sharedlibrary apply-load-rules all
Jan Schenkel.

Re: Debugging tips?

Posted: Wed Jun 05, 2013 9:30 pm
by Janschenkel
@runrevmark
I did extend the switch structure in newobj.cpp - as a copy+paste+adapt artist I slavishly followed your example ;-)
Anyway, I pushed it to an experiment branch here https://github.com/quartamsoftware/live ... er_command
Just in case anybody wants to take a look and point out my silly mistake.

Cheers,

Jan Schenkel.

Re: Debugging tips?

Posted: Wed Jun 05, 2013 9:41 pm
by LCMark
@Janschenkel: You've done what I have done many times... Put the entry in the command_table in the wrong place - the engine does a binary-search on the table and so things need to be in alphabetically order - tinker has to go after throw :)

Re: Debugging tips?

Posted: Wed Jun 05, 2013 10:17 pm
by Janschenkel
Well that was embarrassing - and now the debug breakpoint kicks in where I want it to.
Turns out I had a few more mistakes to fix, but your post put the train back on the rails.
Thanks, Mark! Going to add a big red note that all table entries must be in alphabetical order...

Cheers,

Jan Schenkel.