bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help needed with setting up GDB


From: J. Sloan
Subject: Help needed with setting up GDB
Date: Thu, 4 Jan 2001 16:05:59 -0800 (PST)

Hello,

I have a pretty basic question.  We have installed gdb-4.18 under Redhat
Linux 6.1.  When I start gdb, this banner is displayed:

GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i686-pc-linux-gnu"...


I will now describe the problem.  I have a test program in a working
directory called "/home/jsloan/dev/test/".  The program source code is:

#include <iostream.h>
#include <fstream.h>

int main()
{
  ifstream file;

  file.open("example");
  if (!file)
    cout << "Can't open\n" << endl;
  else
  {
    cout << "Opened successfully\n" << endl;
    file.close();
  }
}


In the same directory is the file "example".

If I run the executable, it opens the file as expected and displays:
Opened successfully

However if I run the program within gdb, the file is not opened, as shown
here:

(gdb) b 9
Breakpoint 1 at 0x8048a1a: file tt.cpp, line 9.
(gdb) r
Starting program: /home/jsloan/dev/test/tt 

Breakpoint 1, main () at tt.cpp:9
9         file.open("example");
(gdb) n
11        if (!file)
(gdb) n
12          cout << "Can't open\n" << endl;
(gdb) 
Can't open

19      }

If I check the working directory, I get the expected result:

(gdb) pwd
Working directory /home/jsloan/dev/test.


If in the "file.open" line of the source code, I specify the full path,
(i.e. file.open("/home/jsloan/dev/test/example"); ), then the file opens
successfully within gdb.

Also, if I have the line "file.open("example"); and put the file
"example" in my home director (i.e. "/home/jsloan"), then the file opens
successfully within gdb.

What can I do to get gdb to open files withing my working directory?

Regards,
Jim





reply via email to

[Prev in Thread] Current Thread [Next in Thread]