[0041] In the drawings, like reference numbers are used to indicate like or functionally similar elements. In addition, the first digit or digits of each reference number generally indicate the figure number in which the referenced item first appears.
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT
[0042] The present invention provides a new model for software diagnostics by tracing the execution path of a computer program and user interaction with the computer program. In the preferred embodiment of the invention, this tracing model is implemented within a set of tracing and debugging tools that are collectively referred to as the BugTrapper system (“BugTrapper”). The BugTrapper tools are used to monitor and analyze the execution of a computer program, referred to as a client. One feature of the BugTrapper is that it does not require special instructions or commands to be imbedded within the source code of the client, and it does not require any modifications to be made to the source or executable files of the client. “Tracing,” or “to trace,” refers generally to the process of using a monitoring program to monitor and record information about the execution of the client while the client is running. A “trace” generally refers to the information recorded during tracing. Unlike conventional debuggers that use breakpoints to stop the execution of a client, the BugTrapper tools collect data while the client is running. Using a process called “attaching”, the BugTrapper tools instrument the client by inserting interrupt instructions at strategic points defined by the developer (such as function entry points) in the memory image of the client. This instrumentation process is analogous to the process of connecting a logic analyzer to a circuit board by connecting probes to test points on the circuit board. When these interrupts are triggered, the BugTrapper collects trace information about the client without the need for a context switch, and then allows the client to continue running.
[0043] The BugTrapper implementations described herein operate under, and are therefore disclosed in terms of, the Windows-NT/2000 and Windows-95/98 operating systems and the like. It will be apparent, however, that the underlying techniques can be implemented using other operating systems that provide similar services. Other embodiments of the invention will be apparent from the following detailed description of the BugTrapper.
[0044] Overview of BugTrapper System and User Model
[0045] The BugTrapper provides two modes of use, remote mode, and online mode. As discussed in more detail in the following text accompanying FIGS 1 A- 1 C, using remote mode a developer can trace the remote execution of a program that has been shipped to an end user (e.g. a customer or beta user) without providing a special version of the code to the user, and without visiting the user's site or exposing the source code level details of the program to the user. The system can also be used in an online mode wherein the developer can interactively trace a program and view the trace results in real time.
[0046] Remote Mode
[0047] Remote mode involves three basic steps shown in FIGS. 1A through 1C . In step 1 , shown in FIG. 1A, a developer 112 uses a program called the BugTrapper analyzer 106 to create a file called a trace control information (TCI) file 120 . The TCI file 120 contains instructions that specify what information is to be collected from a program to be traced (the client). The analyzer 106 obtains information about the client from a build (e.g., compile and link) by-product, such as a link map file, or, as in the preferred embodiment, a debug information file 121 . Typically, the debug information file 112 will be created by a compiler and will contain information such as the names and addresses of software modules, call windows, etc. for the specific client. The developer 112 then sends the TCI file 120 and a small tracing application called the agent 104 to a user 110 as shown in FIG. 1B . The user 110 runs the agent 104 and the client 102 and instructs the agent 104 to attach to the client 102 . The agent attaches to the client 102 by loading a client-side trace library 125 into the address space of the client 102 . An agent-side trace library 124 is provided in the agent 104 . The client-side trace library 125 and the agent-side trace library 124 are referred to collectively as the “trace library.” The agent-side trace library 124 and the client-side trace library 125 exchange messages through normal interprocess communication mechanisms, and through a shared memory trace buffer 105 . The agent-side trace library 124 uses information from the TCI file 102 to attach the client-side trace library 125 into the client 102 , and thereby obtain the trace information requested by the developer 112 .
[0048] The agent 104 and the client-side trace library 125 run in the same context so that the client 102 can signal the client-side trace library 125 without performing a context switch and thus without incurring the overhead of a context switch. For the purposes herein, a context can be a process, a thread, or any other unit of dispatch in a computer operating system. The client 102 can be any type of software module, including but not limited to, an application program, a device driver, or a dynamic link library (DLL), or a combination thereof. The client 102 can run in a single thread, or in multiple processes and/or multiple threads.
[0049] In operation, the agent 104 attaches to the client 102 using a process known as “attaching.” The agent 104 attaches to the client 102 , either when the client 102 is being loaded or once the client 102 is running. Once attached, the agent 104 extracts trace information, such as execution paths, subroutine calls, and variable usage, from the client 102 . Again, the TCI file 120 contains instructions to the client-side trace library 125 regarding the trace data to collect. The trace data collected by the client-side trace library 125 is written to the trace buffer 105 . On command from the user 110 (such as when a bug manifests itself), the agent 104 copies the contents of the trace buffer 105 to a trace log file 122 . In some cases, the log data is written to a file automatically, such as when the client terminates. The user 110 sends the trace log file 122 back to the developer 112 . As shown in FIG. 1 C, the developer 112 then uses the analyzer 106 to view the information contained in the trace log file 122 . When generating screen displays for the developer 112 , the analyzer 106 obtains information from the debug information file 121 . Since the analyzer 106 is used to create the TCI file 120 and to view the results in the trace log file 122 , the developer can edit the TCI file 120 or create a new TCI file 120 while viewing results from a trace log file 122 .
[0050] Remote mode is used primarily to provide support to users 110 that are located remotely relative to the developer 112 . In remote mode, the agent 104 is provided to the user 110 as a stand-alone component that enables the user to generate a trace log file that represents the execution of the client. The TCI file 120 and the trace log file 122 both may contain data that discloses secrets about the internal operation of the client 102 and thus both files are written using an encoded format that is not readily decipherable by the user 110 . Thus, in providing the TCI file 120 and the agent 104 to the user, the developer 112 is not divulging information to the user that would readily divulge secrets about the client 102 or help the user 110 in an attempt to reverse engineer the client 102 . The Agent traces the client without any need for modification of the client. The developer 112 does not need to build a special version of the client 102 executable file and send it to the customer, neither does the customer need to pre-process the client executable file before tracing.
[0051] From the perspective of the remote user, the agent 104 acts essentially as a black box that records the execution path of the client 102 . As explained above, the trace itself is not displayed on the screen, but immediately after the bug reoccurs in the application, the user 110 can dump the trace data to the trace log file 122 and send this file to the developer 112 (such as by email) for analysis. The developer 112 then uses the analyzer 106 to view the trace log file created by the user 110 and identify the problematic execution sequence. In remote mode, the user 110 does not need access to the source code or the debug information. The agent 104 , the TCI file 120 , and the trace log file 122 are preferably small enough to be sent via email between the developer 112 and the user 110 . Further details regarding the remote mode of operation are provided in the sections below.
[0052] Online Mode
[0053] As shown in FIG. 2 , the BugTrapper may also be used in an online mode rather than remote mode as shown in the previous figures. In this mode, the BugTrapper is used by the developer 112 to locally analyze a client 102 , which will typically be a program that is still being developed. For example, the online mode can be used as an aid during the development as a preliminary or complementary step to using a conventional debugger. In many cases it is hard to tell exactly where a bug resides and, therefore, where breakpoints should be inserted. Online mode provides the proper basis for setting these breakpoints. Later, if further analysis is required, a more conventional debugger can be used. In online mode, the analyzer 106 is used to perform all of its normal operations (e.g. creating the TCI file 120 and viewing the trace results) as well as the operations performed by the agent 104 in remote mode. Thus, in online mode, the agent 104 is not used because it is not needed. The developer 112 uses the analyzer 106 to run the client 102 and attach the client-side trace library 125 to the client 102 . In online mode, the analyzer 106 reads the trace buffer 105 in near real-time to provide near real-time analysis functionality. In the online mode, the analyzer 106 immediately displays the trace information to the developer 112 .
[0054] The developer 112 uses the analyzer 106 to interactively create trace control information (TCI). The TCI may be sent to the client-side trace library 125 via file input/output operations or through conventional inter-process communication mechanisms such as shared memory, message passing or remote procedure calls. The TCI indicates to the client-side trace library 125 what portions of the client 102 to trace, and when the tracing is to be performed. As the client program 102 runs, the client-side trace library 125 collects the trace information and relays the information back to the analyzer 106 , which displays the information in near real-time within one or more windows of the BugTrapper.
[0055] Operational Overview of the Tracing Function
[0056] Regardless of which operational mode is used (online or remote), the client 102 is run in conjunction with the client-side trace library 125 . As described in detail below, the client-side trace library 125 is attached to the in-memory image of the client 102 and generates trace information that describes the execution of the client 102 . The TCI file 120 , provided by the developer 112 , specifies where tracing is to take place and what information will be stored. Because the client is traced without the need for context switches, the effect of this tracing operation on the performance of the client 102 is minimal, so that even time-dependent bugs can be reliably diagnosed. As described below, this process does not require any modification to the source or object code files of the client 102 , and can therefore be used with a client 102 that was not designed to be traced or debugged.
[0057] The analyzer 106 is used to analyze the trace data and isolate the bug. The developer 112 may either analyze the trace data as it is generated (online mode), or the developer 112 may analyze trace data stored in the trace log file 122 (mainly remote mode). As described below, the assembly level information in the trace log file is converted back to a source level format using the same debug information used to create the TCI file 120 . During the trace analysis process, the analyzer 106 provides the developer 112 with execution analysis options that are similar to those of conventional debuggers, including options for single stepping and running forward through the traced execution of the client 102 while monitoring program variables. In addition, the analyzer 106 allows the developer 112 to step backward in the trace, and to search for breakpoints both in the future and in the past.
[0058] The attaching mechanism used to attach the client-side trace library 125 to the client 102 involves replacing selected object code instructions (or fields of such instructions) of the memory image of the client 102 with interrupt (INT) instructions to create trace points. The locations of the interrupts are specified by the TCI file 122 that is created for the specific client 102 . When such an interrupt instruction is executed, a branch occurs to the tracing library 125 . The client-side trace library 125 logs the event of passing the trace point location and captures pre-specified state information, such as values of specific program variables and microprocessor registers. The instructions that are replaced by the interrupt instructions are maintained within a separate data structure to preserve the functionality of the application.
[0059] Overview of the Analyzer User Interface
[0060] The analyzer 106 comprises a User Interface module that reads trace data, either from the trace buffer 105 (during on-line mode tracing) or from the trace log file 122 (e.g. after remote tracing) and displays the data in a format, such as a trace tree, that shows the sequence of traced events that have occurred during execution of the client 102 . Much of the trace data comprises assembly addresses. With reference to FIG. 1 C, the analyzer 106 uses the debug information 121 to translate the traced assembly addresses to comprehensive strings that are meaningful to the developer. In order to save memory and gain performance, this translation to strings is preferably done only for the portion of the trace data which is displayed at any given time, not the whole database of trace data. Thus, for example, in formatting a screen display in the user interface, only the trace data needed for the display in the user interface at any given time is read from the log file 122 . This allows the analyzer 106 to display data from a trace log file 122 with more than a million trace records.
[0061] The debug information 121 is preferably created by a compiler when the client is compiled. Using the debug information 121 the analyzer translates function names and source lines to addresses when creating the TCI file 120 . Conversely, the analyzer 106 uses the debug information 121 to translate addresses in the trace data back into function names and source lines when formatting a display for the user interface. One skilled in the art will recognize that other build information may be used as well, including, for example, information in a linker map file and the Type Library information available in a Microsoft OLE-compliant executable.
[0062] Preferably, the debug information is never used by the trace libraries 124 , 125 or the agent 102 , but only by the analyzer 106 . This is desirable for speed because debug information access is typically relatively slow. This is also desirable for security since there is no need to send to the user 110 any symbolic information that might disclose confidential information about the client 102 .
[0063] The analyzer 106 allows the developer 112 to open multiple trace tree windows and define a different filter (trace control instructions) for each of window. When reading a trace record, each window filter is preferably examined separately to see if the record should be displayed. The filters from the various windows are combined in order to create the TCI file 120 , which is read by the client-side trace library 125 . In other words, the multiple windows with different filters are handled by the User Interface, and the client-side trace library 125 reads from a single TCI file 120 .
[0064] FIG. 3A is an illustration of a typical frame window 300 provided by the analyzer 106 . The analyzer frame window 300 displays similar information both when performing online tracing (online mode) and when displaying a trace log file (remote mode). The frame window 300 is a split frame having four panes. The panes include a trace tree pane 310 , an “executable” pane 314 , a trace detail pane 316 , and a source pane 318 . The analyzer frame 300 further provides a menu bar 304 , a dockable toolbar 306 , and a status bar 312 . The menu bar 304 provides drop-down menus labeled “File,” “Edit,” “View,” “Executable,” and “Help.” The trace tree pane 310 contains a thread caption bar 320 , described below in connection with the Analyzer. Below the thread caption bar 320 is a trace tree 330 . The trace tree 330 is a hierarchical tree control that graphically displays the current trace information for the execution thread indicated in the thread caption bar 320 . The trace tree 330 displays, in a hierarchical tree graph, the sequence of function calls and returns (the dynamic call tree) in the executable programs (collectively the client 102 ) listed in the executable pane 314 . Traced source lines also appear in the trace tree, between the call and return of the function in which the lines are located. FIG. 3 illustrates a single thread header and thread tree combination (the items 320 and 330 ). However, multiple thread captions and thread tree combinations will be displayed when there are context switches between multiple threads or processes.
[0065] The executable pane 314 displays an “executable” listbox 361 . Each line in the executable listbox 361 displays information about an executable image that is currently being traced. Each line in the list box 361 displays a filename field 360 , a process id (PID) field 362 , and a status field 364 . Typical values for the status field 364 include “running,” “inactive,” and “exited.” The trace detail pane 316 contains a trace detail tree 350 , which that is preferably implemented as a conventional hierarchical tree control. The trace detail tree 350 displays attributes, variables such as arguments in a function call window, and function return values of a function selected in the trace tree 330 . The source pane 318 displays a source listing of one of the files listed in the source listbox 361 . The source listing displayed in the source pane 318 corresponds to the source code of the function selected in the trace tree 330 of to the selected source line. The source code is automatically scrolled to the location of the selected function.
[0066] The frame window 300 also contains a title bar which displays the name of the analyzer 106 and a file name of a log or Trace Control Information (TCI) file that is currently open. If the current file has not yet been saved, the string “-New” is concatenated to the file name display.
[0067] The status bar 312 displays the status of the analyzer 106 (e.g. Ready), the source code file containing the source code listed in the source code pane 318 , and the line and column number of a current line in the source pane 318 .
[0068] The toolbar 306 provides windows tooltips and the buttons listed in Table 1.
[0069] FIG. 3B shows a typical frame window 300 with multiple threads in the trace tree pane 310 . FIG. 3B shows a separate trace tree for each thread and a thread caption bar (similar to the thread caption bar 320 shown in FIG. 3A ) for each thread.
1 | TABLE 1 |
|
|
| Buttons on the toolbar 306 |
| Menu | | |
| Button | Equivalent | Key | Description |
|
| “Open” | File | Open | Ctrl+O | Opens an existing Trace Control |
| | | Information file. |
| “Save” | File | Save | Ctrl+S | Saves the current Trace Control |
| | | Information to a file. |
| “Clear” | Edit | Clear | | Clears the Trace Tree pane, the |
| All | | Trace Detail pane, and the |
| | | Source pane. |
| “Find” | Edit | Find | Ctrl+F | Finds a specific string in the |
| | | executable source code or trace |
| | | tree. |
| “Bookmark” | Edit | | | Adds or deletes a bookmark for |
| Bookmark | | the currently selected function, |
| | | or edits the name of an existing |
| | | bookmark. |
| “Window” | View | New | | Opens a new instance of the |
| Window | | analyzer. |
| “Start/Stop” | Executable | | | Starts or stops tracing the |
| Start/Stop | | executables listed in the |
| Trace | | Executable pane. |
| “Add” | Executable | | Ins | Adds an executable to the |
| Add | | Executable pane, without |
| | | running it, so that it can be run |
| | | and traced at a later date. |
| “Run” | Executable | | F5 | When the <New Executable> |
| Run | | string is selected, adds an |
| | | executable to the |
| | | Executable pane, starts this |
| | | executable and begins tracing. |
| | | When an executable which is |
| | | not running is selected in the |
| | | Executable pane, starts this |
| | | executable and begins tracing. |
| “Attach” | Executable | | | When the <New Executable> |
| Attach | | string is selected, attaches a |
| | | running executable to the |
| | | Executable pane and begins |
| | | tracing. When an executable |
| | | that is not traced is selected, |
| | | attaches the running process of |
| | | this executable, if it exists. |
| “Terminate” | Executable | | | Terminates the executable |
| Terminate | | currently selected in the |
| | | Executable pane. |
| “Options” | Executable | | | Opens the Trace Options |
| Trace Options | | window in which you can |
| | | specify the elements that you |
| | | want to trace for the selected |
| | | executable. |
|
[0070] Using the Analyzer to Create the TCI File
[0071] The TCI file 120 specifies one or more clients 102 and the specific elements (functions, processes and so on) to be traced either in online or remote mode. The TCI information is specified in a trace options window (described in the text associated with FIG. 5 ). The TCI file 120 is used to save trace control information so that the same trace options can be used at a later time and to send trace control information to a user 110 to trace the client 102 . The subsections that follow provide a general overview of selecting trace information for a TCI file 120 and descriptions of various trace options, different ways to access the trace options, and how to use the trace options to specify elements to be traced.
[0072] The TCI file 120 for a client 102 is interactively generated by the software developer 112 using the analyzer 106 . During this process, the analyzer 106 displays the source structure (modules, directories, source files, C++ classes, functions, etc.) of the client 102 using the source code debug information 121 generated by the compiler during compilation of the client 102 . As is well known in the art, such debug information 121 may be in an open format (as with a COFF structure), or proprietary format (such as the Microsoft PDB format), and can be accessed using an appropriate application program interface (API). Using the analyzer 106 , the developer 112 selects the functions and source code lines to be traced. This information is then translated into addresses and instructions that are recorded within the TCI file. In other embodiments of the invention, trace points may be added to the memory image of the client 102 by scanning the image's object code “on the fly” for specific types of object code instructions to be replaced.
[0073] Trace control information is defined for a specific client 102 . In order to access the trace tool, the developer 112 first adds the desired programs 110 to the list of executables shown in the executable pane 314 shown in FIG. 3 . The executable is preferably compiled in a manner such that debug information is available. In many development environments, debug information may be included in an optimized “release” build such that creation of the debug information does not affect the optimization. In a preferred embodiment, the debug information is stored in a PDB file. If during an attempt to add the executable to the Executable pane 314 a PDB file is not found by the analyzer 106 , the developer 112 is prompted to specify the location of the PDB file. Once an executable has been added to the Executable pane 314 , the developer 112 can set the trace control information using the available trace options described below.
[0074] To use the online mode to trace an executable 314 that is not currently running, the developer selects an executable file to run as the client 102 . To run an executable file, the developer 112 double-clicks the <New Executable> text 365 in the executable pane 314 to open a file selection window thus allowing the developer 112 to select the required executable. Alternatively, the developer 112 can click the Run button on the toolbar 306 , or select the Run option from the “Executable” menu after selecting the <New Executable> text. The file selection window provides a command line arguments text box to allow the developer 112 to specify command line arguments for the selected executable file.
[0075] After selecting an executable to be a client 102 a trace options window (as described below in connection with FIG. 5 .) is displayed which allows the developer 112 to specify which functions to trace. After selecting the desired trace options and closing the trace options window, the executable starts running and BugTrapper starts tracing. As the client 102 runs, trace data is collected and the trace data are immediately displayed in the analyzer frame window 300 as shown in FIG. 3 .
[0076] To cause the analyzer 106 to trace an executable that is currently running, the developer 112 may click the “Attach” button on the toolbar 306 after selecting the <New Executable> text. Upon clicking the “Attach” button on the toolbar 306 , a process list window 400 is displayed, as shown in FIG. 4 . The process list window 400 displays either an applications list 402 or a process list (not shown). One skilled in the art will understand that, according to the Windows operating system, an application is a process that is attached to a top level window. The applications list 402 displays a list of all of the applications that are currently running. The process list window 400 also provides a process list, which is a list of the processes that are currently running. The applications list 402 is selected for display by an applications list tab and the process list is selected for display by pressing the applications list tab. To select a process from the process list window, the developer 112 clicks the Applications tab or the Processes tab as required, and then selects the application or process to be traced. The process list window 400 also provides a refresh button to refresh the application list and the process list, and an OK button to close the process list window 400 .
[0077] After the developer 112 selects an application or process using the process list window 400 , and closes the process list window 400 , the analyzer 106 displays a trace options window 500 , as shown in FIG. 6 below. The application or process selected in the process list window 400 becomes the client 102 . The analyzer 106 can display trace data for multiple processes and applications (multiple clients); however, for the sake of simplicity, the operation of the analyzer 106 is described below primarily in terms of a single client 102 . The trace options window 500 allows the developer 112 to select the functions to be traced. Selecting trace options is described below in the text in connection with FIG. 5 . After selecting trace options and closing the trace options window 500 , the client-side trace library 125 is attached to the client 102 , and the client 102 continues to run. The client-side trace library 125 thereafter collects trace information that reflects the execution of the client 102 and sends the trace information to the analyzer 106 for display.
[0078] The developer can also add an executable file (e.g. a windows .exe file) to the executable pane 314 without actually running the executable file. To add an executable that is not currently running (and which is not to be run yet) to the executable pane 314 , the developer 112 selects the <New Executable> text 365 and then clicks the Add button on the toolbar 306 , whereupon a file selection window is displayed. The developer 112 uses the file selection window to select the desired executable and closes the file selection window. The file selection window provides a text field to allow the developer to enter command line arguments for the executable. Upon closing the file selection window, the trace options window 500 is displayed which enables the developer 112 to select the functions to trace. After selecting trace options and closing the trace options window, the selected executable is inserted into the Executable pane 314 with the status “Inactive.” The developer can then begin a trace on the inactive executable by selecting the executable in the executable pane 314 and clicking the “Run” or “Attach” buttons on the toolbar 306 .
[0079] In a preferred embodiment, the developer 112 can only create a new TCI file 120 when the executable list 361 contains the names of one or more executable files. To create a TCI file 120 , the developer 112 selects “Save” from the “File” menu. The developer can also open a previously saved TCI file 120 and then modify the TCI file 120 using the trace options window 500 . Once a TCI file 120 has been created (or opened) the developer 112 can select an executable from the executable pane and click the “Run” or “Attach” button from the toolbar to start tracing.
[0080] FIG. 5 illustrates the trace options window 500 . The trace options window 500 is divided into two panes, a filter tree pane 501 and a source code pane 504 . The filter tree pane 501 is a multi-page pane having four pages: a file page 602 which is selected by a file tab 510 ; a class page 702 which is selected by a class tab 512 ; a name page 502 which is selected by a name tab 514 ; and a process page 802 which is selected by a process tab 516 . The name page 502 is shown in FIG. 5 . The file page 602 is shown in FIG. 6 , the class page 702 is shown in FIG. 7 , and the process page 802 is shown in FIG. 8 . The trace options window also provides an “advanced” button 520 and an “add DLL” button 522 .
[0081] The trace options window 500 allows the developer 112 to specify which functions to trace and what to display in the trace tree 330 . The trace options window 502 allows the developer 112 to filter out functions which have already been traced. These functions will be redisplayed where they were traced if they are later re-select for tracing. If a function is not selected for tracing in the trace options window 500 , it will not be displayed in the trace tree 330 . If a function that was not traced is filtered in again, it will not appear in that portion of the information that has already been displayed.
[0082] For example, consider the following C++ program:
2 | |
| |
| f1 ( ) { } |
| f2 ( ) { } |
| main ( ) { |
| while (1) { |
| getchar (c) ; |
| f1 ( ) ; |
| f2 ( ) ; |
| } |
| } |
| |
[0083] Using the above program as an example of a client 102 , and assuming that the user forms the following steps:
[0084] 1. Select the functions f1, f2, and main for tracing in the trace options window 500 .
[0085] 2. Execute one loop and view the resulting trace.
[0086] 3. Deselect (filter out) f2 for tracing in the Trace Options window 500 .
[0087] 4. Execute the loop again.
[0088] 5. Re-select (filter in) f2 for tracing in the Trace Options window.
[0089] 6. Execute the loop once more.
[0090] Then, after Step 4 the following depicts the elements that are displayed in the trace window, with the symbol ˜˜˜representing a tear in the trace as described below in connection with FIG. 12 .
1
[0091] After Step 6 the trace appears as follows:
2
[0092] In the above example, after f2 was filtered in again in step 5, it was restored in the first portion of the trace because filtering out occurred after this portion had already been executed. However, f2 never returned to the second portion, which was executed after f2 had been filtered out. Therefore, changing the trace options also determines which of the functions that have already been traced will be displayed. If a traced function is then filtered out from the trace, it can later be filtered in again.
[0093] In the filter tree pane 501 , the process tab 516 , corresponding to the process page 802 , is not displayed prior to activating a process. Each of the four pages in the filter tree pane 501 displays a tree that the developer 112 can use to select the functions to be traced and analyzed. The source code pane 504 displays a source code fragment that contains the source code for the selected function and enables the developer 112 to select the specific source lines to be traced. Each line of executable source in the source code pane 504 is provided with a check box displayed along the left edge of the pane 504 . The developer 112 checks the box to select the corresponding source line for tracing.
[0094] The “advanced” button 520 opens a window which allows the developer 112 to specify which elements to display during the trace (e.g. arguments, pointers, “this” class members and return values) and the maximum string length to be traced. The add DLL button 522 opens a window which allows the developer 112 to specify DLL files to be traced. This is useful when a DLL is loaded dynamically, as described below.
[0095] The developer 112 uses the filter tree pane 501 to select functions to be traced. Four page selection tabs at the top of the filter tree pane 501 enable the developer 112 to view the functions classified (sorted) according to file (on the file page 602 ), class (on the class page 702 ), name (on the name page 502 ) or process (on the process page 802 ). The way the functions are organized is different for each classification tab. However, the tree structure that is displayed in each of the four pages operates in the same way, even though the data elements in the tree are different for each page. Thus, the following discussion relating to the filter tree applies to any of the four pages of the filter tree pane 502 .
[0096] The filter tree is a tree of function names with check boxes to the left of each name. Function check boxes appear blank, checked or dimmed as follows:
[0097] Blank: No sub-element of this branch is checked.
[0098] Checked: All sub-elements of this branch are checked.
[0099] Dimmed: Some (but not all) sub-elements of this branch are checked.
[0100] The developer 112 uses the check boxes to selected the functions to trace and then closes the trace options window by clicking an OK button.
[0101] The file page 602 , shown in FIG. 6 , provides a hierarchical tree that lists the objects according to their hierarchical level in the following order:
3 |
|
| + | The Process that is traced. |
| + | The executable and DLL files which comprise the process. |
| + | Static Libraries |
| + | Source file directories. |
| + | Source files residing in these directories. |
| + | Classes contained in each source file and |
| | functions in each source file that do not |
| | belong to any class. |
| + | Functions belonging to the classes. |
| |
[0102] The source file structure is taken from the debug information (e.g., .PDB) files 121 for the client 102 . If the full path name of the source file is not contained in the .PDB file, then the functions contained in that source file are located in a separate branch of the trace tree 330 under the title <Unknown Directory>. Functions that are included in the .PDB file, but whose source file is unknown, are located in a separate branch of the trace tree 330 under the title <Unknown Source File>.
[0103] The class page 702 , shown in FIG. 7 , provides a hierarchical tree that lists the trace objects sorted by class, ignoring their distribution amongst source files. Functions, which do not belong to a specific class are located in a separate branch of the trace tree 330 under the title <Functions>. The name page 502 , shown in FIG. 5 , provides a hierarchical tree that lists functions sorted alphabetically by name. Leading underscores and class names for methods are ignored. The process page 802 , shown in FIG. 8 , provides a hierarchical tree that displays each process that has been selected for tracing. Under each process is a list of the threads for that process.
[0104] DLL files that are not linked with the executable but rather are loaded dynamically (e.g. libraries loaded using the LoadLibrary system call), are not shown by default in the trace options window 500 . In order to trace a dynamically loaded DLL file, the dynamically loaded DLL file should be added to the list of DLL files using the Add DLL button 522 in the Trace Options window 500 . Clicking the add DLL button 522 displays a file selection window. Using the file selection window, the developer 112 then selects the required DLL file. The selected DLL file is added to the filter tree in the filter tree pane 502 of the trace options window 500 .
[0105] The BugTrapper can also trace DLL files loaded by an executable, even when the executable does not contain debug information. For example, if the developer 112 writes a DLL file as an add-on (e.g., an ActiveX control) to a commercial program (e.g. Microsoft Internet Explorer), the developer 112 can activate BugTrapper on the commercial program and perform a trace on the add-on.
[0106] The BugTrapper also allows the developer 112 to specify various function attributes to be displayed in the trace detail pane 316 of the analyzer frame window 300 , (shown in FIG. 3 ) while performing a trace. The developer 112 can choose to display arguments, pointers, “this” class members and return values. One skilled in the art will recognize that under the terminology of C++, a “this” class member is a class member that is referenced by the C++ “this” pointer. The developer 112 can also specify the maximum string length to be displayed. Selecting more options generally reduces the number of records in the trace log file and thus reduces the amount of execution time that is logged. The discussion below regarding the cyclic trace buffer provides further details of how much execution time is actually logged. The advanced button provides access to an advanced options window (not shown).
[0107] Selecting the arguments checkbox causes function arguments to be displayed in the trace detail pane 316 . Selecting the “pointers” checkbox causes data to which a first level function argument of the pointer type points to be displayed. In other words, selecting the pointers checkbox causes function arguments that are pointers to be de-referenced for the display. The developer 112 may select the “this” checkbox to have “this” to have all members in a class displayed in the trace detail pane 316 when there is a call to a method which has a this pointer. The developer 112 may select the return checkbox to have function return values displayed in the trace detail pane 316 .
[0108] The BugTrapper also allows the developer 112 to control tracing of specific source lines. In the source code pane 504 , a checkbox is located to the left of each executable source line, which can be traced. To view the source code fragment containing a specific function, the developer 112 selects the required function in the filter tree pane 502 and the analyzer 106 displays the appropriate source code fragment in the source code pane 504 . If analyzer cannot locate the source code, then the source code is not displayed and the developer 112 may press the spacebar or right-click in the source code pane 504 and select a “Source Location” command from a pop-up menu. The “Source Location” command opens a dialog box which allows the developer 112 to specify a source code file to be displayed in the source code pane 504 . The appropriate source code is then displayed in the source code pane 504 , as shown in FIG. 5 .
[0109] To select the source code lines to trace, the developer clicks the check boxes corresponding to the desired lines. To select multiple lines, the developer 112 can either press CTRL+A to select the whole source code file, or drag the mouse along several lines and thereby select a group of lines. The developer 112 can then click on any checkbox in the selected area to check all the selected lines or click on a checkbox that is already checked to deselect all selected the lines. If lines of code in a file are selected for tracing, then the filename is displayed in blue. The developer 112 may also select which variables (e.g., local variables, global variables, static variables, etc.) should be traced for each traced line.
[0110] If a client 102 is modified and recompiled, it may not be desirable to use an existing TCI file for that client 102 (for example, a function that was selected for tracing may have been from the modified and recompiled version). Whenever the BugTrapper encounters an outdated TCI file 122 , it issues a warning and then continues to trace based on a heuristic algorithm, which attempts to match the trace instructions to the modified client executable. Trace information for an application that may be recompiled at some future date can be supplemented by saving the trace information to an Extended Trace Control Information (TCE) file rather than a regular TCI file 120 . The TCE file contains extra symbolic information (such as function names) that is not part of a regular TCI file 120 . Using the extra symbolic information greatly increases the chances that the heuristic trace algorithm will produce the desired results. It is especially desirable to use a TCE file at the user 102 site when the client 102 is frequently modified, and the developer 112 does not want to redefine the trace options after each compilation. The TCE file is identified by a .TCE extension.
[0111] The developer may save a TCI file 120 by clicking the save button on the toolbar 306 , whereupon the trace control information is saved. The first time that information is saved to a new TCI file 120 , a file selection window appears. In the file selection window, the developer 112 may select the type of file (TCI or TCE) in a “Save as” type box.
[0112] The TCI file 120 can be used to trace a local client 102 at a later time, or it can be sent to a user 110 for use with the agent 104 to trace a client 102 at a remote site. In a preferred embodiment, for remote tracing, the developer 112 sends the user 110 a self-extracting zip file that contains the agent 104 and the TCI file 120 .
[0113] Using the Agent
[0114] As described above, the agent 104 is an executable module which the developer 112 can provide to a user 110 along with a Trace Control Information (TCI) file in order to trace a client 102 . The trace data collected by the agent 104 are written to the trace log file 122 which the user sends to the developer 112 . The developer 112 uses the analyzer 106 to view the contents of the trace log file and analyze the trace information in the log file 122 . Trace analysis using the analyzer 106 is discussed in subsequent sections of this disclosure. The present section discusses the procedures for starting the agent 104 , including the first step performed by the user 110 to run the agent 104 . The present section also discloses techniques for selecting the TCI file 120 , specifying a directory for the trace log file 122 , specifying the client 102 , and, finally, using the agent 104 to control the logging of trace data. The agent 104 is an easy-to-run standalone application, with step-by-step instructions provided on the screen. To trace an application, the user 102 needs both the agent 104 and the TCI file 120 . The TCI file 120 is prepared, as described above, by the developer 112 and contains information about the client 102 and the specific functions to be traced.
[0115] In a preferred embodiment, the developer supplies the agent 104 as a self extracting zip file that can be installed by simply double clicking on the zip file name. At the end of the installation, the user 110 can launch the agent 102 . When the agent 102 is launched, it displays a TCI select window (not shown) which is a conventional file select dialog that allows the user to select the TCI file 120 . Likewise, the agent 104 provides a log file window, which allows the user 110 to select a directory for the log file 122 . The default log file is the last log file that was opened by the agent 104 . The next step in using the agent 104 is to specify the client 102 executable(s) to trace.
[0116] If an executable specified in the TCI file 120 is already running, an attach to running processes window (running window) 900 is displayed, as shown in FIG. 9 . The running window 900 provides a finish button 902 , a cancel button 904 , a back button 906 , and a list of processes 908 . The list of processes 908 shows any currently running processes that are specified in the TCI file 120 . The list of processes 908 shows all processes that are specified in the TCI file 120 that are not currently running as disabled (grayed). The running window 900 allows the user 102 to select a currently running process to trace by selecting items in the list 908 . Preferably, the user 110 will deselect any executables that are to be re-run from the start (that is, when the user does not want to attach to an executable that is already running). To select a running process, the user 110 selects a process from the list 908 , and then presses the finish button 902 to cause the BugTrapper to attach to the client processes and starts to collect trace data.
[0117] If an executable specified in the TCI file is not currently running, then a start processes window (start window) 1000 is displayed, as shown in FIG. 10, . The start window 1000 provides a finish button 1002 , a cancel button 1004 , a back button 1006 , and a list of executable files 1010 . The start window 1000 also provides a path field 1012 , a parameters field 1014 , and a directory field 1016 . The list of files 1010 shows any currently running processes that are specified in the TCI file. The start window 1000 allows the user to specify executables that are not currently running to be traced. The agent 104 will run the selected client(s) 102 and trace them according to the information in the TCI file 120 .
[0118] The file list 1010 displays the executables, which are listed in the TCI file. Each item in the file list 1010 is provided with a check box. To specify the executables to run, the user 102 checks the boxes for the desired executables in the file list 1010 . If the file path in the file list 1010 is not correct, then the user may enter the correct file path in the path field 1012 . The user 110 may also add command line arguments in the parameters field 1014 . The file path and command line steps may be repeated as needed to specify the file path and commands for additional executables. When the finish button 1002 is clicked, an agent window (described below) is displayed and the agent 104 runs the specified executables, attaches to the executable processes, and starts tracing.
[0119] The agent window (not shown) is displayed by the agent 104 . The agent window displays the names of the TCI file and the log file. The agent window also contains an animated icon whose movement indicates whether trace data is currently being collected while the client 102 is running. The agent window also contains: a “Start/Stop” button to start or stop the trace; a “Clear” button to clear the trace buffer 105 , a “Dump” button to save the contents of trace buffer 105 to the log file; and an “Exit” button to exit the agent 104 .
[0120] The “Stop/Start” button allows the user 110 to stop and restart tracing when desired. Stopping the trace may improve system performance. The “Start/Stop” button toggles between Stop and Start according to the tracing status. The animated icon moves when tracing is in progress. The “Clear” button allows the user 110 to clear the trace buffer 105 . The cleared information is not stored in the log file 122 unless the user first uses the dump button. The dump button allows the user 110 to save the contents of the trace buffer 105 to the log file 122 . On the first save after a new process had been started, the agent 104 overwrites the old log file 122 (if one exists). On subsequent saves, new information will be appended to the existing log file 122 . Clicking the exit button causes the agent 104 to exit. Upon exiting, the trace buffer is written to the log file. Note that the trace information is written to the log file when either dump or exit is clicked and also when the traced application crashes or terminates. The user 110 will preferably use the dump button frequently if it appears likely that the entire operating system may crash.
[0121] In one embodiment, the user may select to write every trace line to the disk as it is traced, or, the user may select to write trace lines periodically every N seconds. Such writing is useful, for example, when it appears likely that the entire operating system may crash.
[0122] Analysis of the Trace Information
[0123] The analyzer 106 is used to analyze a trace, either online as an application runs or off-line using a remote trace log. The general topics that fall under the rubric of trace analysis include, starting an online trace, opening a previously saved trace log file, viewing trace information, interpreting the trace information, working with trace information, and additional trace functions that are available when performing an online trace.
[0124] The BugTrapper allows the developer 112 to trace a client 102 executable in order to pinpoint an element in the client 102 code that causes a bug. The primary device for displaying trace information in the analyzer 106 is the trace tree 330 in the trace tree pane 310 shown in FIG. 3 . The trace control information (TCI) filters can be modified during trace analysis to filter out some of the available trace data according to the needs of the developer 112 .
[0125] Analysis of a remote trace (or a previously saved online trace) is started by opening a previously saved trace log file and displaying the trace information that it contains in the trace tree pane 310 . The log file 122 may either have been created by saving trace information using the analyzer 106 , or the log file 122 may have been created at a remote location using the agent 104 . A trace log file 122 is opened by using an “Open Log” command from the “File” pull down menu found on the menu bar 304 . Once a trace log file 122 is open, the title bar 302 displays the name and path of the opened log file 122 . Once a trace log file 122 is open, the developer can view the trace information using various panes in the analyzer frame window 300 . Trace information is displayed in the trace tree pane 310 , the trace detail pane 316 , and the source pane 318 .
[0126] The trace tree 330 , in the trace tree pane 310 , is a hierarchical tree showing trace data collected from the client 102 . Trace data includes information about events that took place during execution of the client 102 , including function calls, function returns, selected source lines, etc. The developer 112 can use the mouse to choose any function from the trace tree, whereupon the arguments and return values for the chosen function are shown in the trace detail pane 316 , and the source for the chosen function is displayed in the source pane 318 . The types of trace information displayed for both online traces and a trace from log files is almost identical, however the log file trace provides a static display, while the online trace is dynamic and can be viewed as the trace information is being collected.
[0127] The trace tree 330 displays a hierarchical tree of the sequence of function calls and returns in the client 102 . The number of lines in the trace tree is shown in the trace tree pane title bar 308 . The trace tree 330 is organized in a standard tree structure and the developer 112