Debugging Memory Problems with MemoryScape : Attach to a Running Program
Attach to a Running Program
Use this screen to attach to a running program. While the process of attaching to a process within MemoryScape is quite simple—just select the process and click a button—MemoryScape cannot obtain memory debugging information from that file unless you either:
Link in the Heap Interposition Agent (HIA) into the program before the program began executing. This is discussed in the Debugging Memory Problems with MemoryScape book.
Set a preload environment variable before launching the program. The preload variables are:
Platform
Variable
Apple Mac OS X
DYLD_INSERT_LIBRARIES
IBM AIX
MALLOCTYPE
Linux
LD_PRELOAD
Sun
LD_PRELOAD
IBM Blue Gene/P and Blue Gene/Q
LD_PRELOAD
The best way to set this variable is by using the env command. For example, here’s how you would set this variable on a Linux system:
env LD_PRELOAD=user:tvheap_mr.a my_prog
Move your cursor over the graphic to obtain help.
Host
Either click Add Host to add a new remote host on which your program will execute, or select a previously named machine from the dropdown list. The machine entered must have the same architecture as the machine on which you are running MemoryScape, with the exception of those heterogeneous platforms described in Heterogeneous and Cross-Debugging on Linux, in the TotalView Platforms Guide. For example, if you are running MemoryScape on a linux-x86 machine, you cannot name a Sun Solaris system.
Add Host
To enter a new host, select the Add host button and enter its name or IP address in the displayed dialog box.
You can add multiple hosts separated by a space. Alternatively, add the IP address. For example:
server1 server2 server3
or
10.5.6.123 10.5.7.124
If TotalView cannot connect to the host, it displays an error dialog.
To manually enter a connection string or to view the default string TotalView will use to launch the remote debug session, select the Advanced button () to open the Remote Server Launch Command field.
You can edit this string and then click Save as preference to have TotalView save it to your preferences. Once saved, you can view or edit it at File > Preferences > Launch Strings tab.
Note that if you hover your cursor inside the text field, a popup displays the substitutions used in the launch string.
Select Processes
After selecting a host, MemoryScape displays all of the processes running on that host. Select the process to which MemoryScape will attach.
PID & Program
These fields are populated with any selected process. Alternatively, you can browse to and select a process using the Browse button here, or enter a PID number.
Adding Programs
This workflow shows how many steps are involved in attaching to a file and where you are in this process.
Search and Filter
IYou can searching for files specifically or enter terms to filter by, using normal shell globbing rules; that is, you can use such characters as asterisks (*) and question marks (?) as wildcard characters. For example, you could type “fo*b?r”. After entering a filter, click the Refresh button to apply the filter against the displayed list of processes.
Debug in TotalView
Opens the currently selected process in TotalView. The TotalView process window will display the current state of that process. You must have a TotalView license available to debug in TotalView.
Be aware that opening the TotalView process window from within MemoryScape does not initialize TotalView in the same way as starting TotalView directly. The definitions in your .tvdrc file and your saved breakpoints are not loaded. However, you can load a breakpoint file using the Action Point menu item in the process window. If you need the definitions in your .tvdrc file, start TotalView first and open MemoryScape from within TotalView.
Red Zones
Tells MemoryScape to set the Red Zones option on or off for the selected processes.
Add User
Launches the Add Username dialog so you can add another user to see his processes and attach to them. If you wish to attach to a process owned by someone else, you need the proper permissions.
Add Username dialog
Click the icon to launch the Add username dialog. Enter a known username, then click OK.
 
If the username is not recognized, the system returns an error; otherwise, the user is added to the User drop-down and selected as the current user.
 
The selected user’s processes are displayed. Attach to another user’s processes just by clicking the process and selecting Start Session.
If you do not have permissions to attach to the process, an error is returned.