file (idb mode only)

Switch to the specified source file.

Syntax

file [filename]

Parameters

filename

The name of the file for which you want to set the scope.

Description

This command displays the name of the current file scope, or switches the file scope. Change the file scope to see source code for or to set a breakpoint in a function not in the file currently being executed.

To display the name of the current file scope, do not include filename.

To change the name of the current file scope, include filename.

If the file name is not a literal, use the fileexpr command. For example, if you have a script that calculates a file name in a debugger variable or in a routine that returns a file name as a string, you can use fileexpr to set the file.

Example

The following example uses the file command to set the debugger file scope to a file different from the main program, and then stops at line number 26 in that file. This example also shows the fileexpr command setting the current scope back to the original file, which is solarSystem.cxx.

(idb) run
[1] stopped at [int main(void):114 0x080569f8] 
114 unsigned int j = 1; // for scoping examples 
(idb) file
/home/user/examples/solarSystemSrc/main/solarSystem.cxx 
(idb) set $originalFile = "solarSystem.cxx"
(idb) list 36:10
36 Moon *enceladus = new Moon("Enceladus", 238, 260, saturn); 
37 Moon *tethys = new Moon("Tethys", 295, 530, saturn); 
38 Moon *dione = new Moon("Dione", 377, 560, saturn); 
39 Moon *rhea = new Moon("Rhea", 527, 765, saturn); 
40 Moon *titan = new Moon("Titan", 1222, 2575, saturn); 
41 Moon *hyperion = new Moon("Hyperion", 1481, 143, saturn); 
42 Moon *iapetus = new Moon("Iapetus", 3561, 730, saturn); 
43 
44 Planet *uranus = new Planet("Uranus", 2870990, sun); 
45 Moon *miranda = new Moon("Miranda", 130, 236, uranus); 
(idb) file star.cxx
(idb) list 36:10
36 void Star::printBody(unsigned int i) const 
37 { 
38 std::cout << "(" << i << ") Star [" << name() 
39 << "], class [" << stellarClassName(classification()) 
40 << ((int)subclassification()) << "]" << std::endl; 
41 } 
42 
43 StellarClass Star::classification() const 
44 { 
45 return _classification; 
(idb) stop at 38
[#2: stop at "/home/user/examples/solarSystemSrc/star.cxx":38] 
(idb) cont
[2] stopped at [virtual void Star::printBody(unsigned int) const:38 0x08054526] 
38 std::cout << "(" << i << ") Star [" << name() 
(idb) file
/home/user/examples/solarSystemSrc/main/solarSystem.cxx 
(idb) fileexpr $originalFile
(idb) file
/home/user/examples/solarSystemSrc/main/solarSystem.cxx 
(idb) list 36:10
36 Moon *enceladus = new Moon("Enceladus", 238, 260, saturn); 
37 Moon *tethys = new Moon("Tethys", 295, 530, saturn); 
38 Moon *dione = new Moon("Dione", 377, 560, saturn); 
39 Moon *rhea = new Moon("Rhea", 527, 765, saturn); 
40 Moon *titan = new Moon("Titan", 1222, 2575, saturn); 
41 Moon *hyperion = new Moon("Hyperion", 1481, 143, saturn); 
42 Moon *iapetus = new Moon("Iapetus", 3561, 730, saturn); 
43 
44 Planet *uranus = new Planet("Uranus", 2870990, sun); 
45 Moon *miranda = new Moon("Miranda", 130, 236, uranus); 

See Also


Submit feedback on this help topic

Copyright © 1996-2010, Intel Corporation. All rights reserved.