DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Using the command line interface of debug

Code in header files

None of the programs in this tutorial have code that comes from an included file, but having code in header files is a common situation, particularly in C++ programs, which frequently have numerous inline functions defined in header files or make use of templates, whose source may be included automatically by the compiler. Any statement that comes from a header file is displayed by the debugger in terms of both the compilation unit (or primary source file name) and the included file name, using the syntax compilation_unit@included_file. For example, given the following program:

   process.c:
     #include <stdlib.h>
     #include "chdr.h"
     
     void
     process(char *str)
     {
   	f(str);
      	...
     }
      
   chdr.h:
   
     static void
     f(char *str)
     {
   	if (str == 0)
   		return;
      	...
     }
The location of the function f called by the function process is given by process.c@chdr.h@f. When you stop in that function, the location is displayed in the event notification and in the stack trace.
   debug> stop process.c@chdr.h@f
   EVENT [1] assigned
   debug> run
   STOP EVENT TRIGGERED: f  in p1 [f in process.c@chdr.h]
   4:		if (file == 0)
   debug> stack
   Stack Trace for p1, Program a.out
   *[0] f(str="testing")	[process.c@chdr.h@4]
    [1] process(str="testing")	[process.c@6]
           ...
Also, although the source file displayed by list is from chdr.h, the debugger can only find chdr.h by looking through the debugging information generated for process.c. The debugger variables %file and %list_file reflect that condition:
   debug> print %list_file
   "process.c@chdr.h"

This has several implications for you in setting breakpoints or in examining the source for code in included files:


Next topic: Debugger command summary
Previous topic: Templates

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005