指定したソースファイルに切り替えます。
このコマンドは、現在のファイルスコープを表示するか、ファイルスコープを切り替えます。ファイルスコープを変更して、現在実行中のファイルにはない関数のソースコードを表示したり、ブレークポイントを設定したりできます。
現在のファイルスコープを表示するには、filename を指定しないでください。
現在のファイルスコープの名前を変更するには、filename を指定します。
ファイル名がリテラルでない場合は、fileexpr コマンドを使用します。例えば、デバッガー変数でファイル名を算出するスクリプトや、ファイル名を文字列として返すルーチンがある場合、fileexpr を使用してファイルを設定できます。
次の例は、file コマンドを使用して、デバッガーのファイルスコープをメインプログラムとは異なるファイルに設定し、そのファイルの行番号 26 で停止します。この例では、現在のスコープを元のファイル solarSystem.cxx に戻す fileexpr コマンドの使用方法も示しています。
(idb) run [1] stopped at [int main(void):114 0x080569f8] 114 unsigned int j = 1; // スコープ例 (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);