Understanding the Debugging Process

fork2fork2 Join Date: 2007-11-08 Member: 62854Members
edited November 2007 in Decoda
<div class="IPBDescription">Attaching Decoda to a Lua Process</div>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:<ul><li>Running "cgi-fcgi.exe -start -connect :3333 invoke.exe" starts an executable "invoke.exe"</li><li>Invoke.exe does a system("lua5.1 web.lua");</li><li>Lua5.1 (standard binaries from luaforge) happily runs my CGI application.</li></ul>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).

<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Debugging session started
Warning 1000: Lua functions were not found during debugging session
Debugging session ended<!--QuoteEnd--></div><!--QuoteEEnd-->

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 Join Date: 2007-10-30 Member: 62771Members
    <!--quoteo(post=1659842:date=Nov 8 2007, 05:34 AM:name=fork2)--><div class='quotetop'>QUOTE(fork2 @ Nov 8 2007, 05:34 AM) <a href="index.php?act=findpost&pid=1659842"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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:<ul><li>Running "cgi-fcgi.exe -start -connect :3333 invoke.exe" starts an executable "invoke.exe"</li><li>Invoke.exe does a system("lua5.1 web.lua");</li><li>Lua5.1 (standard binaries from luaforge) happily runs my CGI application.</li></ul>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.<!--QuoteEnd--></div><!--QuoteEEnd-->

    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 Join Date: 2002-03-15 Member: 318Super Administrators, Retired Developer, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, Subnautica Developer, Pistachionauts, Future Perfect Developer
    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?
  • fork2fork2 Join Date: 2007-11-08 Member: 62854Members
    edited November 2007
    <!--quoteo(post=1659990:date=Nov 9 2007, 02:53 AM:name=Max)--><div class='quotetop'>QUOTE(Max @ Nov 9 2007, 02:53 AM) <a href="index.php?act=findpost&pid=1659990"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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?<!--QuoteEnd--></div><!--QuoteEEnd-->

    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 Join Date: 2002-03-15 Member: 318Super Administrators, Retired Developer, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, Subnautica Developer, Pistachionauts, Future Perfect Developer
    <!--quoteo(post=1659995:date=Nov 8 2007, 08:28 PM:name=fork2)--><div class='quotetop'>QUOTE(fork2 @ Nov 8 2007, 08:28 PM) <a href="index.php?act=findpost&pid=1659995"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->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.<!--QuoteEnd--></div><!--QuoteEEnd-->
    If you send me your exe, dlls (and pdbs if they exist) I'll take a look at it (max@unknownworlds.com).

    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)
  • fork2fork2 Join Date: 2007-11-08 Member: 62854Members
    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).
Sign In or Register to comment.