Difference between revisions of "IDE Window: Call Stack"

From Free Pascal wiki
Jump to navigationJump to search
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[category:IDE Window|Call Stack]][[category:IDE Window - Debug|Call Stack]]
 
 
{{IDE Window: Call Stack}}
 
{{IDE Window: Call Stack}}
 +
 +
== Navigation ==
 +
 +
[[Main menu|Main Menu]] > [[Main menu#View|View]] > Debug Windows > Call Stack
  
 
== Important ==  
 
== Important ==  
  
You have to set up a debugger (via Tools->Options->Debugger) and then make sure your project is set to generate debug information in order to debug it (via Project->Project Options->Compiler Options->Linking; make sure you check "Generate debugging information for GDB"). Only then is the Call Stack window useful.  
+
You must [[Debugger_Setup |setup the debugger]] and start the project to debug it. Only then this window will be useful.
 +
 
 
The output shown on this page is based on the GNU debugger (GDB) which is currently the only debugger Lazarus supports. Its output looks at times like C, not Pascal. Other debuggers may show a more Pascal-like style.
 
The output shown on this page is based on the GNU debugger (GDB) which is currently the only debugger Lazarus supports. Its output looks at times like C, not Pascal. Other debuggers may show a more Pascal-like style.
  
Line 42: Line 46:
  
 
Double click on an item to jump to the source.
 
Double click on an item to jump to the source.
 +
 +
== Toolbar ==
 +
 +
;On/Off: Enable/Disable updates. Freezes the current content.
 +
 +
;View Source: Jump to selected location in source editor.
 +
 +
;Current: Set the selected frame as source for locals, watches, ...
 +
 +
;Max ##: Set the amount of frames shown in the list
 +
 +
;More: Increases the amount of frames shown in the list
 +
 +
;Top: Set the first shown index to 0
 +
 +
;Bottom: Set the first shown index, so that the bottom of the stack is visible.<br/>E.g. if you show "Max 10" lines, and your app has 55 frames (from the main entry point to the current location), then the window will show frames from index 45 to 54 (54 is the 55th frame - zero based)
 +
 +
;Edit & Goto selected <s>source line</s>: <br/>Show the entered index as first frame in the list.<br/> (<s>source line</s> => index)
 +
 +
;Copy all: copy to clipboard
 +
  
 
== Popup menu ==
 
== Popup menu ==

Latest revision as of 15:13, 10 September 2022

Deutsch (de) English (en) français (fr) русский (ru)

Navigation

Main Menu > View > Debug Windows > Call Stack

Important

You must setup the debugger and start the project to debug it. Only then this window will be useful.

The output shown on this page is based on the GNU debugger (GDB) which is currently the only debugger Lazarus supports. Its output looks at times like C, not Pascal. Other debuggers may show a more Pascal-like style.

Dialog

Callstack.png

What is the call stack?

The call stack is the stack of function calls. The top line is the current function, the lowest line is the main program.

Source column

This column lists the filename of the source file. This information is retrieved from the debug information contained in the executable (or from an external GDB symbol file if you have selected that option). Only those parts of the program explicitly compiled with debug information contain this information.

Line column

If the position contains debug information, the source line number will be shown, otherwise only the address pointer in the executable is shown. This line is where the next function was called.

Note: The line numbering is the numbering at the time the project was last compiled with debug information. If you have subsequently inserted or deleted lines, the numbering will appear to be incorrect.

Function column

The mangled name of the procedure or function. The compiler converts Pascal identifiers into names which the gnu tools (designed for C code) can use. For example:

 TAPPLICATION__CREATEFORM(0x81fb738, void, (^TAPPLICATION) 0xb7cd0014)

This means:

  • The mangled function name is TAPPLICATION__CREATEFORM, which is the TApplication.CreateForm procedure of the LCL unit forms.pp. Because Pascal is case insensitive and the gnu tools are case sensitive, FPC converts the name to uppercase. Because the gnu tools don't know about classes and objects, the class.method is converted to a global function name.
  • The parameter list depends on the platform and the calling convention. That means the parameter list may be reversed, starting with the rightmost parameter. This is the case in the above example.
  • The 'Self' parameter is implicit, meaning that you don't write it in the Pascal source, because FPC creates it automatically. This is always the first parameter emitted by the compiler (though invisible in the Pascal source code). Because of the reversed parameter order, Self is shown here as the last parameter. It is of type ^TAPPLICATION and its hexadecimal value is 0xb7cd0014.
  • The next parameter in Pascal is 'var Reference', which has no type. Therefore it is 'void'.
  • The last parameter in Pascal is 'InstanceClass: TComponentClass'. Gnu sees this parameter simply as a pointer with the hexadecimal value 0x81fb738.

Tricks

Double click on an item to jump to the source.

Toolbar

On/Off
Enable/Disable updates. Freezes the current content.
View Source
Jump to selected location in source editor.
Current
Set the selected frame as source for locals, watches, ...
Max ##
Set the amount of frames shown in the list
More
Increases the amount of frames shown in the list
Top
Set the first shown index to 0
Bottom
Set the first shown index, so that the bottom of the stack is visible.
E.g. if you show "Max 10" lines, and your app has 55 frames (from the main entry point to the current location), then the window will show frames from index 45 to 54 (54 is the 55th frame - zero based)
Edit & Goto selected source line

Show the entered index as first frame in the list.
(source line => index)
Copy all
copy to clipboard


Popup menu

Callstack popmenu.png

Show

Jump to the current item's source code position.

Set as current

Set the selected entry as the current stack frame. Local variables only exist within their own local stack frame. By setting the current frame, you can watch the values of variables in the (local) context of the procedure you have selected.

Copy all

Copy the call stack to the clipboard.