Post Debugger: Difference between revisions

From Compost Wiki
Jump to navigation Jump to search
ChrisH (talk | contribs)
No edit summary
Jeffm (talk | contribs)
 
(18 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Overview==


The post debugger is a tool that can be used by post developers to view the output and logic flow of a running post processor


==Components==
[[Image:Compost4Debugger.PNG | 800px | right]]


The post debugger requires 3 separate components to be run properly.
=Overview=
Debugging a post processor requires several components.


===Post Debugger Plug-in===
# A debug enabled post
The plug-in provides the interactive interface to the post debugger and allows developers to view the posting process as it runs.
# A debug tool
# A GibbsCAM session with a part that can run the post


===GibbsCAM===
With these components, the debug tool allows the post developer to inspect how the GibbsCAM part uses the post processor as it runs.
The plug-in requires the use of GibbsCAM v8.7.13 or later.  It will not work properly in any earlier version of the software.  Once a valid GibbsCAM version is installed, copy the plug-in "PostDebug.dll" into the Plugins folder.


===Compiler===
==Legacy Post Debugger==
The post debugger requires the [[Compost]]3 compiler version 1.3.5 or later. This version contains an option in its Preferences dialog that allows for the generation of debug information (near the lower right corner of the dialog box ).
The legacy post debugger was an experimental tool that was used with some versions of Compost3 to assist developers in debugging post processors. It was de-supported with GibbsCAM V11 and Compost4.


==Usage==
=Compost4 Integrated Debugger=
Compost4 v 4.3 and later includes an integrated debugger. Beta versions of Compost4 4.2.99.x have been released to allow users to test the post debugger.


When posting the user will see the Post Debugger dialog if the following conditions are met:
==File Format==
Compost was designed from inception to contain integrated debug services and the POST format has always included debug information. The debugger built into Compost4 works using these features of the POST format, so it can only debug posting sessions that use a POST file. Compost4 always upgrades a PST file into a POST when opened. When using the debugger post developers must use the POST version of the file inside GibbsCAM when debugging.


* The PostDebug.dll is in the Plugins folder
==Features==
* The Post processor must have compiled with the "Generate Debug" option selected
Debugger Features include
* Both the prog and form (pst and txt) file must be in the same folder.
* Breakpoints
* interactive code stepping
* Output inspection (Output Window)
* Variable/Flag inspection (Variables)
* Program State inspection (Watches and Callstack)


The debugger will look for a .txt file with the same name as the .pst file when it loads. It will use the txt file that has the same name as the currently runing post processor and load it for the prog. If this file is not current there can be problems.
== Usage ==
The Compost4 debugger has 3 software components.
* Compost4 v.4.2.99.x or later
* GibbsCAM 11.3.10 or later.
* GibbsCAMCompostDebugAddin (the plug-in that links GibbsCAM and Compost).


===Interface===
The GibbsCAMCompostDebugAddin is shipped with all compatible versions of GibbsCAM, but is disabled by default. Before a post can be debugged, this plug-in must be manually enabled in the plug-in manager.
The Debugger interface is divided into 3 sections. The top section is used to control
the debugger, the middle section shows the source of the post (with line numbers)
and the lower section shows the output code.


The top right of the control section provides buttons to control the posting.
When enabled, the post developer has 2 choices for how to start a debug session.
"Next Op", "Next Tool", "Next Flow" will post until the next op, tool or flow
is reached. "Next NC" line will run until a new line of code is created.
"Next Post Line" is used to show the execution of the post one line at a time.


Whilst the post is running, each line of the post can be shown as it is being executed
===Starting from GibbsCAM ===
but can take considerable time.THe "Display Post" option controls this display, when it is unchecked the output will be suppressed for speed.
When a part is open in GibbsCAM and a post is selected, the Compost Debugger -> Attach to Compost menu item can be used to start a debug session using the current part/post. If there are no compost instances running, GibbsCAM will start a new one and open the selected post. If a single compost instance is already running, it will automatically be used. If there are multiple compost instances running the plugin will show a compost selection dialog to allow the user to pick what compost instance to use.


The post can be run until a break point is reached, by pressing the "Run" button.
===Starting from Compost===
A post developer can trigger a debug session from the debug menu or the debug toolbar button. When started from Compost, a new instance of GibbsCAM is always started.


===Breakpoints===
==Connecting GibbsCAM and Compost==
There are a number of types of break point available. These allow the user to control when the debuggers stops the execution of the posted program.
Once, the session is started, GibbsCAM and Compost will connect to each other and establish a debug link. When the link is established, Compost will enable a number of debug features that are available from the debug menu.


'''Break At Op Num'''
Some features, such as step control and the output window, will only be functional when GibbsCAM is actually posting. Some common compost features will be disabled while debugging an active posting session, such as compiling and saving.


This option requires an operation number to be entered into the corresponding field. Execution
==Breakpoints==
will stop when the given op number is reached. The box next to the op number will
A breakpoint is a way to tell GibbsCAM to pause posting at a specific location in the program, or when a specific set of conditions are true. Breakpoints are primarily accessed via the Breakpoints window.
be updated during posting to indicate the current op number.


'''Break At Tool Num"'''
From this window a post developer can define two types of breakpoints.


This is similar to "Break At Op Num" but will break on a given tool number.
===Line Breakpoints===
Line breakpoints will pause the post execution right before the first command of the selected line is executed.


'''Break At NC Cod'''
===State Breakpoints===
State breakpoints do not define a specific lotion in the post to break on, but a set of conditions. When all the conditions are true, the program will break and allow the developer to inspect the state. The most common condition to use is "Specified text is in output" so developers can easaly learn what part of the post is generating questionable output.


This breakpoint is used to stop the execution when a block of code contains the given text.
==Step Control==
The check for text is not case sensitive.
When the post program is in the break state, GibbsCAM will not process any more commands until instructed to do so by the debugger. Several tools are available to the developer to control how the program will continue from this state. As a program is stepped, the current line will be highlighted with a yellow arrow. The current command will be highlighted with a yellow background.


* Resume. Causes the program to continue as normal and process commands until ether the program ends, or another breakpoint is encountered.
* Step Over. Executes the next command and stops on the next one in the current progsub. If that command is a call to a progsub, then the entire progsub will be executed before control is returned to the next command.
* Step Into. Executes the next command in any progsub. If the next command is a progsub, the program will break at the first command in that progsub.
* Step Out. Runs to the end of the current prog sub and then breaks at the next command in the calling progsub.
* Run to next line. Runs to the first command of the next line in the prog.
* Run to Cursor. Runs to the command where the cursor is in the compost editor window.


When processing is stopped due to one of these break conditions, the box containing
==Variables==
the Op number, Tool number or NC text will change to red to highlight the break.
The variables window will show all variables that have been defined (set, or used) in the program at the time they are viewed. The variable values will update as they are changed by the prog. Variables commands work in one of 2 scopes, Global or Local. Legacy commands such as [[GetVar]]# and [[Flag]]? all work in the global scope and will appear on the Globals tab. Newer commands such as [[SetLocalVar]]# are local to the current progsub and will appear in the Locals tab.


The fourth method of breaking is to stop at a particular line in the post. When clicking
==Callstack==
on a line of text in the post display section, that line will change to yellow to show
The callstack window shows what progsubs have been called at the time it is viewed. Each callstack item shows what line it was on when the next progsub was called.
that it has been added as break point on that line. If the line is clicked again the breakpoint will be removed.


When posting stops due to a break, the "Back" button can be used to step backwards from
==Watches==
the current line in the post, one line at a time to help to identify the path through
The watches window allows a post developer to inspect data about the current posting program and its state. Each watched item is selected from the pulldown menu at the top, and then added to the watch list using the "+" button. Some watch types require additional information (such as an axis name) that can be entered into the text box next to the pulldown menu. Watch data is only updated when the program is broken for performance reasons.
the post to the current state. The "Fwd" button takes you in the opposite direction.


The "Watch" button provides a method to check the status of some variables and
===Data===
internal post registers. Click on the "Watch" button to show the "Watch Variables" dialog.
* CurrentOp, The current operation
The "Add Watch" button will show a list of Number variables, Flags and Internal Registers.
* CurrentFeatureNumber, [[FeatNum]]# for the current feature.
You can simply watch the value, break when the value changes, or break when it changes to
* CurrentFeature, Information about the current input feature (type, location, etc...).
to a given value. This is the fifth type of break point available.
* CurrentPart, The current part instance.
* CurrentRepeat, Information on the current repeat status (rotations, origins, repeats)
* CurrentFeedrate, The current feedrate for the current program step
* AxisStatus, The status register value for the specified axis in the current output mode
* CurrentAxisValue, The value of the specified axis for the current program in the current output mode.
* FlowAxisSetName, The current flow axis set name
* FlowAxisSetAxes, The axis names that make up the current flow axis set
* InterpSetAxes, The axis names that make up the current interpolation set
* CurrentModeName, The name of the current output mode
* CurrentTGSpeed, The current toolgroup speed and direction
* CurrentWPSpeed, The current workpeice speed and direction
* CurrentCRC, The current CRC state
* CurrentFlow, the current flow
===Commands===
Both number and boolean commands can be set as watches. When set the watch window will show the returned value of the command in the watch window as if it had been called at the time when the post execution is broken. Currently commands that take arguments can not be used in the watch window. In order to get the value, the post debugger must actually call the command. This can affect posting performance and possibly have unintended side effects on the state of the post processor, since the commands are being called on every step of the debugger. The debugger automatically suppresses the output and status register updates from watch commands, but due to the large number of legacy commands, there may be other undesired side effects from using watch commands, so post developers should be aware of this fact.


Select one of these from the drop down menus, select the Watch action from the 3 radio
==Output==
buttons and press the button next to the drop down menu to add it to the watch list.
The output window shows the last few lines of output as well as the current line being built up by the post.


If the Post Debugger dialog is closed, posting will continue as usual until it is completed.


==Notes==
==Notes on using the debugger==
When compiling with the "Generate Debug" option, Compost3 will add information to
# Posts can not be edited while they are being debugged. Compost disabled edit,save, and compile while GibbsCAM is posting. It is not possible to change a post while it is being run.
the .pst file that relates to the line numbers in the post. It will not include any of
# It is not necessary to stop debugging or detach compost from GibbsCAM when posting has finished. GibbsCAM and compost can stay attached for many postings. The post just can't be edited while posting is actualy happening. After posting ends, edits can be done as normal.
the source code itself. This means that the size of the compiled post will not be
# Breakpoints are cleared when GibbsCAM is disconnected from Compost. This issue will be addressed in future updates.
significantly increased, but it also means that both .pst and .txt files must be
# The POST version of a post MUST be selected in GibbsCAM. PST files can not be directly debugged.
in the same folder for the debugger to work.
# Line Numbers can not be used for conditional state breakpoints. Due to the nature of how [[Retag]] works, line numbers are not generated until after the output is complete.


Post developers can remove the post debugger information by recompiling the post with out option enabled in compost. The debug information will make the post slighty larger, but should not be a major concern. No source code included in a debug post so there is no thread of that information being exposed.


[[Category:Articles]]
[[Category:Articles]]

Latest revision as of 17:12, 20 September 2017


Overview

Debugging a post processor requires several components.

  1. A debug enabled post
  2. A debug tool
  3. A GibbsCAM session with a part that can run the post

With these components, the debug tool allows the post developer to inspect how the GibbsCAM part uses the post processor as it runs.

Legacy Post Debugger

The legacy post debugger was an experimental tool that was used with some versions of Compost3 to assist developers in debugging post processors. It was de-supported with GibbsCAM V11 and Compost4.

Compost4 Integrated Debugger

Compost4 v 4.3 and later includes an integrated debugger. Beta versions of Compost4 4.2.99.x have been released to allow users to test the post debugger.

File Format

Compost was designed from inception to contain integrated debug services and the POST format has always included debug information. The debugger built into Compost4 works using these features of the POST format, so it can only debug posting sessions that use a POST file. Compost4 always upgrades a PST file into a POST when opened. When using the debugger post developers must use the POST version of the file inside GibbsCAM when debugging.

Features

Debugger Features include

  • Breakpoints
  • interactive code stepping
  • Output inspection (Output Window)
  • Variable/Flag inspection (Variables)
  • Program State inspection (Watches and Callstack)

Usage

The Compost4 debugger has 3 software components.

  • Compost4 v.4.2.99.x or later
  • GibbsCAM 11.3.10 or later.
  • GibbsCAMCompostDebugAddin (the plug-in that links GibbsCAM and Compost).

The GibbsCAMCompostDebugAddin is shipped with all compatible versions of GibbsCAM, but is disabled by default. Before a post can be debugged, this plug-in must be manually enabled in the plug-in manager.

When enabled, the post developer has 2 choices for how to start a debug session.

Starting from GibbsCAM

When a part is open in GibbsCAM and a post is selected, the Compost Debugger -> Attach to Compost menu item can be used to start a debug session using the current part/post. If there are no compost instances running, GibbsCAM will start a new one and open the selected post. If a single compost instance is already running, it will automatically be used. If there are multiple compost instances running the plugin will show a compost selection dialog to allow the user to pick what compost instance to use.

Starting from Compost

A post developer can trigger a debug session from the debug menu or the debug toolbar button. When started from Compost, a new instance of GibbsCAM is always started.

Connecting GibbsCAM and Compost

Once, the session is started, GibbsCAM and Compost will connect to each other and establish a debug link. When the link is established, Compost will enable a number of debug features that are available from the debug menu.

Some features, such as step control and the output window, will only be functional when GibbsCAM is actually posting. Some common compost features will be disabled while debugging an active posting session, such as compiling and saving.

Breakpoints

A breakpoint is a way to tell GibbsCAM to pause posting at a specific location in the program, or when a specific set of conditions are true. Breakpoints are primarily accessed via the Breakpoints window.

From this window a post developer can define two types of breakpoints.

Line Breakpoints

Line breakpoints will pause the post execution right before the first command of the selected line is executed.

State Breakpoints

State breakpoints do not define a specific lotion in the post to break on, but a set of conditions. When all the conditions are true, the program will break and allow the developer to inspect the state. The most common condition to use is "Specified text is in output" so developers can easaly learn what part of the post is generating questionable output.

Step Control

When the post program is in the break state, GibbsCAM will not process any more commands until instructed to do so by the debugger. Several tools are available to the developer to control how the program will continue from this state. As a program is stepped, the current line will be highlighted with a yellow arrow. The current command will be highlighted with a yellow background.

  • Resume. Causes the program to continue as normal and process commands until ether the program ends, or another breakpoint is encountered.
  • Step Over. Executes the next command and stops on the next one in the current progsub. If that command is a call to a progsub, then the entire progsub will be executed before control is returned to the next command.
  • Step Into. Executes the next command in any progsub. If the next command is a progsub, the program will break at the first command in that progsub.
  • Step Out. Runs to the end of the current prog sub and then breaks at the next command in the calling progsub.
  • Run to next line. Runs to the first command of the next line in the prog.
  • Run to Cursor. Runs to the command where the cursor is in the compost editor window.

Variables

The variables window will show all variables that have been defined (set, or used) in the program at the time they are viewed. The variable values will update as they are changed by the prog. Variables commands work in one of 2 scopes, Global or Local. Legacy commands such as GetVar# and Flag? all work in the global scope and will appear on the Globals tab. Newer commands such as SetLocalVar# are local to the current progsub and will appear in the Locals tab.

Callstack

The callstack window shows what progsubs have been called at the time it is viewed. Each callstack item shows what line it was on when the next progsub was called.

Watches

The watches window allows a post developer to inspect data about the current posting program and its state. Each watched item is selected from the pulldown menu at the top, and then added to the watch list using the "+" button. Some watch types require additional information (such as an axis name) that can be entered into the text box next to the pulldown menu. Watch data is only updated when the program is broken for performance reasons.

Data

  • CurrentOp, The current operation
  • CurrentFeatureNumber, FeatNum# for the current feature.
  • CurrentFeature, Information about the current input feature (type, location, etc...).
  • CurrentPart, The current part instance.
  • CurrentRepeat, Information on the current repeat status (rotations, origins, repeats)
  • CurrentFeedrate, The current feedrate for the current program step
  • AxisStatus, The status register value for the specified axis in the current output mode
  • CurrentAxisValue, The value of the specified axis for the current program in the current output mode.
  • FlowAxisSetName, The current flow axis set name
  • FlowAxisSetAxes, The axis names that make up the current flow axis set
  • InterpSetAxes, The axis names that make up the current interpolation set
  • CurrentModeName, The name of the current output mode
  • CurrentTGSpeed, The current toolgroup speed and direction
  • CurrentWPSpeed, The current workpeice speed and direction
  • CurrentCRC, The current CRC state
  • CurrentFlow, the current flow

Commands

Both number and boolean commands can be set as watches. When set the watch window will show the returned value of the command in the watch window as if it had been called at the time when the post execution is broken. Currently commands that take arguments can not be used in the watch window. In order to get the value, the post debugger must actually call the command. This can affect posting performance and possibly have unintended side effects on the state of the post processor, since the commands are being called on every step of the debugger. The debugger automatically suppresses the output and status register updates from watch commands, but due to the large number of legacy commands, there may be other undesired side effects from using watch commands, so post developers should be aware of this fact.

Output

The output window shows the last few lines of output as well as the current line being built up by the post.


Notes on using the debugger

  1. Posts can not be edited while they are being debugged. Compost disabled edit,save, and compile while GibbsCAM is posting. It is not possible to change a post while it is being run.
  2. It is not necessary to stop debugging or detach compost from GibbsCAM when posting has finished. GibbsCAM and compost can stay attached for many postings. The post just can't be edited while posting is actualy happening. After posting ends, edits can be done as normal.
  3. Breakpoints are cleared when GibbsCAM is disconnected from Compost. This issue will be addressed in future updates.
  4. The POST version of a post MUST be selected in GibbsCAM. PST files can not be directly debugged.
  5. Line Numbers can not be used for conditional state breakpoints. Due to the nature of how Retag works, line numbers are not generated until after the output is complete.