Understanding the Debugging Process

fork2fork2 Members Join Date: 2007-11-08 Member: 62854Posts: 3
edited November 2007 in Decoda
Attaching Decoda to a Lua Process
I am attempting to attach Decoda to a Lua script I've got running as a FastCGI program. The (messy) way my Lua code is invoked is as follows:
  • Running "cgi-fcgi.exe -start -connect :3333 invoke.exe" starts an executable "invoke.exe"
  • Invoke.exe does a system("lua5.1 web.lua");
  • Lua5.1 (standard binaries from luaforge) happily runs my CGI application.
As of yet, I've been unable to figure out how to break into web.lua with this process. When I attach Decoda to the invoke.exe process, I get the following message (after using the CGI script for a bit, and then killing it).

QUOTE
Debugging session started
Warning 1000: Lua functions were not found during debugging session
Debugging session ended


Does anyone have any idea how I might go about successfully attaching to this process?

Unrelated to this - I was really surprised to find that the guys who wrote Decoda are the Natural Selection team. Natural Selection being one of my favourite games, and coming across Decoda unrelated to this on the Lua mailing list.

Comments

  • TeknogreboTeknogrebo Members Join Date: 2007-10-30 Member: 62771Posts: 4
    QUOTE(fork2 @ Nov 8 2007, 05:34 AM) »
    I am attempting to attach Decoda to a Lua script I've got running as a FastCGI program. The (messy) way my Lua code is invoked is as follows:
    • Running "cgi-fcgi.exe -start -connect :3333 invoke.exe" starts an executable "invoke.exe"
    • Invoke.exe does a system("lua5.1 web.lua");
    • Lua5.1 (standard binaries from luaforge) happily runs my CGI application.
    As of yet, I've been unable to figure out how to break into web.lua with this process. When I attach Decoda to the invoke.exe process, I get the following message (after using the CGI script for a bit, and then killing it).
    Does anyone have any idea how I might go about successfully attaching to this process?

    Unrelated to this - I was really surprised to find that the guys who wrote Decoda are the Natural Selection team. Natural Selection being one of my favourite games, and coming across Decoda unrelated to this on the Lua mailing list.


    At a guess I would say that you need to attach Decoda to the lua5.1 exe that is spawned from Invoke.exe, not the Invoke itself.
  • MaxMax Technical Director, Unknown Worlds Entertainment Super Administrators, Retired Developer, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, Subnautica Developer, Pistachionauts, Future Perfect Developer Join Date: 2002-03-15 Member: 318Posts: 1,737 admin
    If you put your cursor on the warning and press F1 it should bring up the help section with some advice on the cause.

    Most likely the problem is that the Lua executable you are using statically links with Lua and you don't have the PDB files. Decoda requires one of these two things so that it can locate the Lua API functions in memory. I downloaded the latest version from Lua forge (http://luaforge.net/frs/download.php/2218/lua5_1_2_Win32_bin.zip) which does dynamically link with the Lua DLL. I tested it with Decoda and it works correctly. Is this is the same version you are using?
    Max McGuire
    Technical Director, Unknown Worlds Entertainment
  • fork2fork2 Members Join Date: 2007-11-08 Member: 62854Posts: 3
    edited November 2007
    QUOTE(Max @ Nov 9 2007, 02:53 AM) »
    If you put your cursor on the warning and press F1 it should bring up the help section with some advice on the cause.

    Most likely the problem is that the Lua executable you are using statically links with Lua and you don't have the PDB files. Decoda requires one of these two things so that it can locate the Lua API functions in memory. I downloaded the latest version from Lua forge (http://luaforge.net/frs/download.php/2218/lua5_1_2_Win32_bin.zip) which does dynamically link with the Lua DLL. I tested it with Decoda and it works correctly. Is this is the same version you are using?


    I'm using that version (although I've also compiled a version of Lua with a massive pause at the start so I can attach Decoda before lua_open, in case that makes a difference). I think somehow the way I've set up my FastCGI is causing the problem, as Decoda has worked great for all my other programs. I'll play with it a little bit more, and if I can't get anywhere, I'll throw away the abomination that FastCGI seems to be, and move to SCGI (although that means writing a lot more code for me). I really do think that Decoda seems like a potentially extremely handy tool for debugging long-lived CGI processes (i.e. FastCGI/SCGI).

    Unrelated to this issue, it would be somewhat handy if there was an option in Decoda to pass through the name of the current file being edited as a parameter to an External Tool (although I wouldn't be surprised if this was already built in, and I just hadn't come across it) - allowing it to also be used as an IDE for the standard Lua interpreter, which is a fairly common scenario for me.
  • MaxMax Technical Director, Unknown Worlds Entertainment Super Administrators, Retired Developer, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, Subnautica Developer, Pistachionauts, Future Perfect Developer Join Date: 2002-03-15 Member: 318Posts: 1,737 admin
    QUOTE(fork2 @ Nov 8 2007, 08:28 PM) »
    I'm using that version (although I've also compiled a version of Lua with a massive pause at the start so I can attach Decoda before lua_open, in case that makes a difference). I think somehow the way I've set up my FastCGI is causing the problem, as Decoda has worked great for all my other programs. I'll play with it a little bit more, and if I can't get anywhere, I'll throw away the abomination that FastCGI seems to be, and move to SCGI (although that means writing a lot more code for me). I really do think that Decoda seems like a potentially extremely handy tool for debugging long-lived CGI processes (i.e. FastCGI/SCGI).

    Unrelated to this issue, it would be somewhat handy if there was an option in Decoda to pass through the name of the current file being edited as a parameter to an External Tool (although I wouldn't be surprised if this was already built in, and I just hadn't come across it) - allowing it to also be used as an IDE for the standard Lua interpreter, which is a fairly common scenario for me.

    If you send me your exe, dlls (and pdbs if they exist) I'll take a look at it ([email protected]).

    As for the external tools, there's currently a way to do what you want. It basically works the same as MSVC where you can use "macros" in the command line. These are the ones that exist with their meaning:

    $(ItemPath) - Complete directory, file name and extension.
    $(ItemDir) - Directory the file is in (no trailing backslash)
    $(ItemFileName) - Name of the file with no directory
    $(ItemExt) - File extension (no preceding period)
    Max McGuire
    Technical Director, Unknown Worlds Entertainment
  • fork2fork2 Members Join Date: 2007-11-08 Member: 62854Posts: 3
    edited November 2007
    It's working now - I think the long chain of processes starting other processes in my FastCGI setup was making it difficult for me to track down which process to actually attach to. I've moved to SCGI and Decoda is handling it well.

    Now I'm able to break into my web application and check tree-structured variable contents without having to trawl through massive logs (logs get annoying very quickly).
    Post edited by Unknown User on
Sign In or Register to comment.