Table of Contents

Custom initialization scripts

Sometimes it is necessary to run some commands just after debugger has been started. WinGDB supports such case through custom initialization scripts. User can provide path to script in dialog Launch Process, Attach Process or Examine Core Dump in field 'Custom initialization script'.

Syntax of script is simple. Single line may contain only one gdb command or comment, eventually it is empty. Line is treated as comment if it begins with two slashes (//) or hash (#). Blank characters at the beginning of line are ignored. There is no limit for number of lines.

Sample of script (there are two empty lines intentionally):
Output generated by script is redirected into VisualStudio console (pane "Debug").

CAUTION!
All commands are allowed to run through custom initialization script, but please proceed with them carefully, because they may change the way GDB bahaves and introduce negative side-effects for WinGDB operations.

All breakpoints set through custom initialization script are not visible in Visual Studio environment, but GDB sees them and reacts as usually.


Currently WinGDB supports scripts which are located on local file system only. If there is need to run scripts which are located on remote machine, then please let us know about it. The same if you have any problems with custom initialization scripts.

Custom runtime scripts

In addition to initialization scripts, WinGDB supports execution of custom GDB scripts at arbitrary moments during debugging (however the debugger must be stopped). These scripts may be bound to menu commands for convenience. This way, you can use some extended features of GDB even though WinGDB does not support them directly. This can be especially useful on embedded systems.

Defining scripts

In order to define a custom script, open the User scripts submenu from WinGDB menu.

The first option opens the Custom script manager window, which allows you to define up to eight scripts and bind them to commands in the menu. Remaining options are corresponding commands which have been bound. After selecting the first option, the following dialog appears:

Click on one of the rows on the left side. You will be able to edit a script which is bound to that particular command. Enter the name of the command in User command name field and the contents of the script below. After clicking OK or Apply your script will be saved. You may edit an existing script as well.

Executing scripts

In order to execute as script, just select corresponding option from the User scripts menu. The debugging session must be active and the debugger must be stopped, otherwise the command will be disabled.

Limitations and warnings

The following limitations and warnings apply to custom scripts.

Table of Contents


Copyright (C) 2008-2012 WinGDB.com. All rights reserved.