DebuggingScripts.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <html>
  2. <head>
  3. <title>
  4. Debugging Scripts
  5. </title>
  6. </head>
  7. <body bgcolor="#FFFFFF" vlink="silver" alink="navy" link="navy">
  8. <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
  9. <tr>
  10. <td valign="bottom">
  11. <div align="left">
  12. <b><font face="Tahoma" size="3" color="navy">Debugging Scripts</font></b>
  13. <br>
  14. <font face="Tahoma" size="2">
  15. <a href="TopicGroup_PWL.html">Topic Groups</a>
  16. </font>
  17. </div>
  18. </td>
  19. <td>
  20. <font face="Tahoma" size="1" color="silver">
  21. <div align="right" valign="top">
  22. <a href="http://www.lua.org">Lua homepage</a>
  23. </div>
  24. </font>
  25. </td>
  26. </tr>
  27. <tr valign="top">
  28. <td colspan="2">
  29. <hr size="1" color="#000000" align="top">
  30. <br>
  31. <br>
  32. <font face="Tahoma" size="2">
  33. <p style="text-align: justify">
  34. <img width="227" height="57" src="../Medias/DebugToolBar.jpg" align="right" alt="Picture 1.1" hspace="15">
  35. Debugging is long and difficult task to do. It is also a crucial state in programming project because
  36. this task have to be well done in order to bring a project successful. LuaEdit provides servaral tools
  37. to get this *painful* task done as easy as possible. This section will explain the basic actions to debug
  38. scripts with LuaEdit.
  39. <br>
  40. <br>
  41. <b>Basics</b><br>
  42. First of all, you must press the "Run" (F5) button on the "Debug Toolbar" (Picture 1.1) or by using the menu "Run/Run Script"
  43. in order to get into a debug session. This will load the script into a "Lua State" (See Lua 5.0 documentation
  44. available through the menu "?/Lua Help") and execute each valid line of you script until it reaches the end or a
  45. valid breakpoint (See documentation below for more informations about breakpoints). If an error happened while running
  46. the script, LuaEdit will display the message through a message box and through the "Messages Window" (Picture 1.2).
  47. Several debugging informations are available, once the script execution breaks on a line. Local and Global variables
  48. values are available through the "Local Variables Window" and the "Global Variables Window". Also, the "Lua Stack Window"
  49. shows all Lua's stacked variables values at the moment of the current execution and the "Call Stack Window" shows the
  50. history of all function calls made from the current script. This call stack may be useful to trace back the values of the
  51. local and global variables in previous calls.
  52. <br>
  53. <br>
  54. <b>Step by Step</b><br>
  55. <img width="320" height="120" src="../Medias/LuaEditMessages.jpg" align="right" alt="Picture 1.2" hspace="15">
  56. A few choices are available to pursue the execution of the script. The "Step Over" (F10) and "Step Into" (F11) buttons allows
  57. to jump the function call of the current debugging line if any. If "Step into" is pressed and no function call is made on the
  58. current debugging line, the debugger will simulate the "Step Over" feature wich simply jump to the next executed line. The
  59. "Run Script to Cursor" (Ctrl+F10) button will run the script until it reaches the line where cursor is currently positioned
  60. or until the end of the script. The "Run" (F5) button will pursue the execution of the scipt if already started.
  61. <br>
  62. <br>
  63. <b>Manipulating Breakpoints</b><br>
  64. Breakpoins are very useful when debugging. To insert a breakpoint at the line where the cursor is, press the "Toggle Breakpoint"
  65. (F9) button from the debug toolbar (Picture 1.2). When debugging a script, the execution should break on a line where a breakpoint
  66. <img width="363" height="128" src="../Medias/Breakpoints.jpg" align="right" hspace="15" vspace="15">
  67. has been detected. Advanced manipulation and features for breakpoint are available through the "Breakpoints Window" (Picture 1.3)
  68. such as disabling/enabling breakpoints. A disabled breakpoint won't break the execution of the script but will leave the breakpoint marker
  69. (maroon/grayed) on the code editor. To disable/enable a breakpoint, simply check/uncheck the checkbox on the left of the breakpoint name
  70. in the "Breakpoints Window". You can also set a condition on a breakpoint wich will be evaluated when the scipt is runnning
  71. to determine whether or not it will break on this breakpoint. The evaluation of the condition should always return "true" or "false".
  72. You can also remove, add and goto breakpoints through the "Breakpoints Window".
  73. <br>
  74. <br>
  75. <b>Using the Initializer</b><br>
  76. LuaEdit offer the possibility to bind the code to a Dynamic-Link Library (DLL) before the execution of the script. This can be very useful
  77. if any function call in the scripts refer to some C++ functions defined in such a file. By using the initializer, you will prevent error
  78. raised by Lua 5.0 because it can't find the reference of the function call. To set the initializer, just popup the "Project Options Window"
  79. by clicking on the "Project/Options..." menu. Once the windowis displayed, select the "Debug" tab and enter the full path of the DLL or simply
  80. click on the browse button and open the DLL from the browse dialog. In order to make this feature working your DLL must export a function of
  81. one of these prototype according to the right language it has been built from:
  82. <ul type="square">
  83. <li>Delphi: <b style="color: navy">&nbsp;LuaDebug_Initializer(L: PLua_State): Integer; cdecl;&nbsp;</b></li>
  84. <li>C/C++: <b style="color: navy">&nbsp;int LuaDebug_Initializer(lua_State *L);&nbsp;</b></li>
  85. </ul>
  86. <b>NOTE:</b> The initializer property is only available when the unit is part of a project.
  87. </p>
  88. <br>
  89. </font>
  90. </td>
  91. </tr>
  92. <tr>
  93. <td colspan="2">
  94. <font face="Tahoma" size="1" color="silver">
  95. <hr size="1" color="#000000">
  96. <div align="right">
  97. <a href="http://luaedit.luaforge.net">http://luaedit.luaforge.net</a>
  98. <br>
  99. © Copyright 2004-2005 LuaEdit
  100. <br>
  101. LuaEdit v 2.0 for Lua 5.0
  102. </div>
  103. </font>
  104. </td>
  105. </tr>
  106. </table>
  107. </body>
  108. </html>