Debug Lua embeded without access to c++ source

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Debug Lua embeded without access to c++ source

daveaceinc
I have a question that no one seems to have the answer to. I was going over your site and found it very interesting and helpful. Thought I ask the question and you might be able to help or maybe know someone I can ask it from.

In my company we design games. We use Lua to write our scripts.

The engine is written in C++. We have no access to it other then its .exe file

We use our Linux box and run the engine.exe with the path to our lua script.

Here is the problem. We haven;t been able to find a way to debug ( break points, step thru, etc). As the program is being run to see if our lua script is having any bugs and if so where the bug is. So what happens is that if there is an issue it crashes and we have to trace our steps back and try to find the bug. Very painful and time consuming.

If we had access to the c++ engine, we could have just loaded it to say Visual studio, add our lua files and debug while its running. But we don't

So I am on a mission to find a way for us to debug. Any ideas you might have are greatly appreciated.

Sincerely

Dave Kay
Reply | Threaded
Open this post in threaded view
|

Re: Debug Lua embeded without access to c++ source

Paige DePol
[hidden email] wrote:

> Here is the problem. We haven;t been able to find a way to debug ( break
> points, step thru, etc). As the program is being run to see if our lua
> script is having any bugs and if so where the bug is. So what happens is
> that if there is an issue it crashes and we have to trace our steps back
> and try to find the bug. Very painful and time consuming.
>
> If we had access to the c++ engine, we could have just loaded it to say
> Visual studio, add our lua files and debug while its running. But we don't
>
> So I am on a mission to find a way for us to debug. Any ideas you might
> have are greatly appreciated.

I am not sure you will find a way to debug your Lua scripts directly with
the engine unless the engine itself provides some sort of debugging hooks.

Which engine are you using? Have you tried to contact them to inquire about
debugging capabilities for Lua scripts? There are a number of programs out
there for Lua to allow you to edit and run scripts, however, unless they
know how to interface with your game engine they won't be of much help.

Usually game engines that come as "black boxes", where you only have the
game engine to run itself without sources, have some sort of facility to
enter a debugging mode... or come with a special debugging version of
the engine you can run while developing. Another issue is that standalone
Lua editors will not have access to the libraries present in the game
engine, making debugging scripts externally pretty much impossible.

I would suggest trying to contact the vendor of the game engine as they
will be more in a position to help you with your debugging issues.

Good luck with your game!

~Paige



Reply | Threaded
Open this post in threaded view
|

Re: Debug Lua embeded without access to c++ source

Heinrich Hartmann
Hi Dave,

Well, you can inject a debugger into the script itself. For a while I had a setup like this:

function break()
  -- 1. Open a TCP socket port 1125
  -- 2. When a client connected, load a debugger script
  -- 3. RPEL
  while true do 
   -- read line from socket
   -- eval line
   -- print output
   end
end

When you inject a call to break() into your script the interpreter will block and wait for
a client to connect with `telnet localhost 1125`. I don't have the code at hand to share,
but it was not much effort to build.

Best regards,
Heinrich


On 31 January 2018 at 22:00, Paige DePol <[hidden email]> wrote:
[hidden email] wrote:

> Here is the problem. We haven;t been able to find a way to debug ( break
> points, step thru, etc). As the program is being run to see if our lua
> script is having any bugs and if so where the bug is. So what happens is
> that if there is an issue it crashes and we have to trace our steps back
> and try to find the bug. Very painful and time consuming.
>
> If we had access to the c++ engine, we could have just loaded it to say
> Visual studio, add our lua files and debug while its running. But we don't
>
> So I am on a mission to find a way for us to debug. Any ideas you might
> have are greatly appreciated.

I am not sure you will find a way to debug your Lua scripts directly with
the engine unless the engine itself provides some sort of debugging hooks.

Which engine are you using? Have you tried to contact them to inquire about
debugging capabilities for Lua scripts? There are a number of programs out
there for Lua to allow you to edit and run scripts, however, unless they
know how to interface with your game engine they won't be of much help.

Usually game engines that come as "black boxes", where you only have the
game engine to run itself without sources, have some sort of facility to
enter a debugging mode... or come with a special debugging version of
the engine you can run while developing. Another issue is that standalone
Lua editors will not have access to the libraries present in the game
engine, making debugging scripts externally pretty much impossible.

I would suggest trying to contact the vendor of the game engine as they
will be more in a position to help you with your debugging issues.

Good luck with your game!

~Paige






--
Dr. Heinrich Hartmann
Am Bökel 3
32351 Stemwede Levern

Mobile: <a href="tel:01525%203638134" value="+4915253638134" style="color:rgb(17,85,204)" target="_blank">+49 1525 363 8134
Landline: <a href="tel:05745%209200511" value="+4957459200511" style="color:rgb(17,85,204)" target="_blank">+49 5745 9200511
Reply | Threaded
Open this post in threaded view
|

Re: Debug Lua embeded without access to c++ source

Paige DePol
Heinrich Hartmann <[hidden email]> wrote:
> Well, you can inject a debugger into the script itself. For a while I had
> a setup like this:
>
> When you inject a call to break() into your script the interpreter will
> block and wait for a client to connect with `telnet localhost 1125`. I
> don't have the code at hand to share, but it was not much effort to build.

Very good idea... I hadn't contemplated that idea. I think I was more stuck
on the fact he said the entire engine was crashing outright. Which, to me,
seems to indicate a badly written engine if the scripting language is
capable of outright crashing the game engine.

Hopefully the game engine itself will allow socket connections. For example,
the Lua engine in World of Warcraft has no facilities for access to things
like the network or arbitrary files. Hopefully if the game engine does give
access to the network via Lua it will easy to tell where the game engine is
crashing from the script, otherwise you may have to step through a lot of
Lua code first.

Still, I am surprised that the game engine itself doesn't have a facility
for debugging Lua scripts, given it has an embedded Lua runtime! I would
still check with the vendors to see if they have some sort of debugging
environment available for their game engine... it seems odd they wouldn't!

~Paige



Reply | Threaded
Open this post in threaded view
|

Re: Debug Lua embeded without access to c++ source

Coda Highland
On Thu, Feb 1, 2018 at 10:16 AM, Paige DePol <[hidden email]> wrote:

> Heinrich Hartmann <[hidden email]> wrote:
>> Well, you can inject a debugger into the script itself. For a while I had
>> a setup like this:
>>
>> When you inject a call to break() into your script the interpreter will
>> block and wait for a client to connect with `telnet localhost 1125`. I
>> don't have the code at hand to share, but it was not much effort to build.
>
> Very good idea... I hadn't contemplated that idea. I think I was more stuck
> on the fact he said the entire engine was crashing outright. Which, to me,
> seems to indicate a badly written engine if the scripting language is
> capable of outright crashing the game engine.
>
> Hopefully the game engine itself will allow socket connections. For example,
> the Lua engine in World of Warcraft has no facilities for access to things
> like the network or arbitrary files. Hopefully if the game engine does give
> access to the network via Lua it will easy to tell where the game engine is
> crashing from the script, otherwise you may have to step through a lot of
> Lua code first.

Not ARBITRARY files, but WoW scripts can access certain permitted
files. I've seen scripts do I/O against a file that's managed by an
external daemon process to provide broader functionality.

In a pinch, you could use something like this.

/s/ Adam

Reply | Threaded
Open this post in threaded view
|

Re: Debug Lua embeded without access to c++ source

Paige DePol
Coda Highland <[hidden email]> wrote:

> Not ARBITRARY files, but WoW scripts can access certain permitted files.
> I've seen scripts do I/O against a file that's managed by an external
> daemon process to provide broader functionality.
>
> In a pinch, you could use something like this.

Granted, it has been years since I've played WoW, however, the files we used
to be able to access were the ones specifically granted in the script config
file for saving state or loading static data.

Back when I played and wrote a number of AddOns there was no facility to
flush the contents of state out... I have done some cursory Google searching
and it appears this is still the case.

Any external daemons are simply just parsing the AddOn state Lua files,
which only save under WoW's control. The only other way to refresh data was
to execute an entire UI reload.

Usually game engines have a much more restricted environment, online ones
even more so, to help prevent against cheating or the theft of account
information via the scripting engine.

~Paige


Reply | Threaded
Open this post in threaded view
|

Re: Debug Lua embeded without access to c++ source

dyngeccetor8
In reply to this post by Coda Highland
On 02/01/2018 07:33 PM, Coda Highland wrote:
> Not ARBITRARY files, but WoW scripts can access certain permitted
> files. I've seen scripts do I/O against a file that's managed by an
> external daemon process to provide broader functionality.
> [...]
> /s/ Adam

Can you provide more details? Because from what I know about Wow
addons, you may ask to store some tables at logoff time. So there
is no official way to exchange data in runtime.

-- Martin

Reply | Threaded
Open this post in threaded view
|

Re: Debug Lua embeded without access to c++ source

Coda Highland
On Thu, Feb 1, 2018 at 2:30 PM, dyngeccetor8 <[hidden email]> wrote:

> On 02/01/2018 07:33 PM, Coda Highland wrote:
>> Not ARBITRARY files, but WoW scripts can access certain permitted
>> files. I've seen scripts do I/O against a file that's managed by an
>> external daemon process to provide broader functionality.
>> [...]
>> /s/ Adam
>
> Can you provide more details? Because from what I know about Wow
> addons, you may ask to store some tables at logoff time. So there
> is no official way to exchange data in runtime.
>
> -- Martin
>

I've been corrected; I misunderstood what was actually going on. I
thought the I/O was happening in realtime, but it turns out to have
been done in batch mode.

/s/ Adam