Why gdb switched to home directory? -
suppose current directory /home/xxx/test, there text file named "test.txt" contains single word "hello", , file named "test.cpp" following,
#include <iostream> #include <fstream> #include <unistd.h> using namespace std; int main () { char cwd[1024]; getcwd(cwd, 1024); cout << cwd << endl; string s; ifstream i("test.txt"); if (!i.good()) cout << "can't open test.txt" << endl; >> s; i.close(); cout << s << endl; return 0; } test> g++ test.cpp test> ./a.out /home/xxx/test hello test> gdb a.out gnu gdb (gdb) red hat enterprise linux (7.2-60.el6_4.1) copyright (c) 2010 free software foundation, inc. license gplv3+: gnu gpl version 3 or later <http://gnu.org/licenses/gpl.html> free software: free change , redistribute it. there no warranty, extent permitted law. type "show copying" , "show warranty" details. gdb configured "x86_64-redhat-linux-gnu". bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... reading symbols /home/xxx/test/a.out...(no debugging symbols found)...done. (gdb) run starting program: /home/xxx/test/a.out /home/xxx can't open test.txt program exited normally. (gdb) pwd working directory /home/xxx/test. (gdb) shell pwd /home/xxx
my question why gdb switched home directory yields 'test.txt' can't found? why 'pwd' , 'shell pwd' give different result?
thanks.
there 'cd ~' in .cshrc, root cause difference between 'shell pwd' , 'pwd'.
after remove it, problems resolved.
thanks.
Comments
Post a Comment