Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "LDT/User Area/User Guides/User Guide 0.8"

(Remote Debug)
Line 35: Line 35:
 
To use it, you must have these two files in your lua path.<br> To begin the connection, you must execute this Lua code&nbsp;:  
 
To use it, you must have these two files in your lua path.<br> To begin the connection, you must execute this Lua code&nbsp;:  
  
  &gt; local initconnection = require("debugger")
+
  > local initconnection = require("debugger")
  &gt; initconnection(host, port, idekey)
+
  > initconnection(host, port, idekey)
  
 
or shortly  
 
or shortly  
  
  &gt; require("debugger")(host, port, idekey)
+
  > require("debugger")(host, port, idekey)
  
 
*'''host''': the host name or the IP address of the DBGP server (thus, of your IDE).  
 
*'''host''': the host name or the IP address of the DBGP server (thus, of your IDE).  
Line 68: Line 68:
 
<br> Now you can start your debug session by clicking '''Debug'''. IDE will wait for an incoming connection from the debugger client, on the port you can see in the debug view.<br> [[Image:DebugView.png|center]]  
 
<br> Now you can start your debug session by clicking '''Debug'''. IDE will wait for an incoming connection from the debugger client, on the port you can see in the debug view.<br> [[Image:DebugView.png|center]]  
  
If needed, you can change the server port, in ''Window &gt; Preferences &gt; Dynamic Languages &gt; Debug''. [[Image:DebugUI.png|center]]  
+
If needed, you can change the server port, in ''Window > Preferences > Dynamic Languages > Debug''. [[Image:DebugUI.png|center]]  
  
 
===Paths configuration===
 
===Paths configuration===

Revision as of 17:43, 14 December 2011

Lua development tools overview

LDT provides tooling to facilitate Lua application development. It allows to structure the code into projects, which enables project-based configuration. LDT aims, as well, to enhance user Lua experience with features such as variable occurrences and scope aware completion. Have a look at some of our features:

Getting started

In order to be able to enjoy Lua Development Tools, there only a few steps.

  • Create a project
    • Name it
  • Edit a Lua source file

Create a project

For your code to benefit from Lua Development Tool, it has to be marked as Lua compliant. How could you do this. Just create a Lua Project, it will add Lua nature to your code.

Choose Lua Project

Select the right project type: Lua Project.

ProjectList.png

Name it

Just enter a valid name.

NewLuaProject.png

Edit a Lua source file

Now that your project is created. You might want to write some Lua. In every project, there is a default source folder so far named src. You can edit the main.lua file in it.

EditingFile.png

Source folders are imported, as they are the one processed to compute tooling information. As example, if you code a module outside any source folder, when called from another module or script, it content won't be available in code assistance.

Concepts

In order to use LDT at its finest level, they are some concept to understand:

Remote Debug

The Debugger of Lua Development Tools is based on the DBGP protocol.
The IDE contains a DBGP server. To connect to this server, and begin remote/attach debugging, you need to get our DBGP Lua client.

DBGP Client

The DBGP Lua client is composed of two Lua files (debugger.lua and debugintrospection.lua).
It runs on Unix-like OS and Windows (XP and later). It is written in Lua 5.1 and depends on lua-socket.
You can get Lua on http://www.lua.org/download.html and install lua-socket thanks to luarocks, or via your official OS repositories.

To use it, you must have these two files in your lua path.
To begin the connection, you must execute this Lua code :

> local initconnection = require("debugger")
> initconnection(host, port, idekey)

or shortly

> require("debugger")(host, port, idekey)
  • host: the host name or the IP address of the DBGP server (thus, of your IDE).
    • if host is nil, the DBGP_IDEHOST environment variable is used.
    • if the environment variable is nil, the default value '127.0.0.1' is used.
  • port: the port of the DBGP server (must be configured in the IDE).
    • if port is nil, the DBGP_IDEPORT environment variable is used.
    • if the environment variable is nil, the default value '10000' is used.
  • idekey: a string which is used as session key (must be configured in the IDE).
    • if IDEKEY is nil, the DBGP_IDEKEY environment variable is used.
    • if the environment variable is nil, the default value 'luaidekey' is used.

So, To debug your application you could do :

lua -e "require('debugger')("idehost","ideport");" MyApp.lua 

DBGP Server

The DBGP Server is integrated in LDT.
In order to accept incoming debug sessions, you must create a new Remote Lua Application launch configuration, then launch it.

Go in Run/Debug Configurations....
LaunchConfiguration.png

  • Project : Set the LDT project in your workspace which includes the Lua source file(s) of the application you want to debug.
  • IdeKey : Default value is luaidekey, if you need to debug more than one application at the same time, you should change it to associate a launch configuration with only one application to debug.
  • Source Mapping : Define a common way for DBGP Server (IDE) and DBGP Client (running application) to identify source file. There are several strategy, each more or less adapted to a specific used case. To better understand it, see the advanced documentation on it.

Now you can start your debug session by clicking Debug. IDE will wait for an incoming connection from the debugger client, on the port you can see in the debug view.
DebugView.png
If needed, you can change the server port, in Window > Preferences > Dynamic Languages > Debug.
DebugUI.png

Paths configuration

In order to use propoperly remote debugging, you must care about paths. In our case, they are several kind of them to consider:

  • Project path
  • Runtime path

Project path

Project path is the one set using the Build Path > Configure Build Path ... UI. From there you can specify dependency to other project from current workspace. As a result, will enjoy completion and navigation between your project and the ones configured in Build Path.

BuildPath.png

Runtime path

Once your program is ready, you might try Remote debugging. Before hande, you must ensure that all project which you depend on are in lua path. This path configuration is not explained here as it fully dependant of your development environment.

Back to the top