This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GDB/Cygwin source path problem fix suggestion

For the records:

This may be a fix to an almost non-existing problem, refer
to mail thread "GDB/ELF/Cygwin source path problem". However, the
problem is very real for me....

I found out that the problem is probably related to that
source paths are stored in Windows format (i.e. "c:\..." in the
ELF file I end up with (I use an old GCC binary (1998) made for DOS
usage). GCC made for Cygwin would probably use "/cygdrive/c/..."
format, although I haven't checked that.

When trying to open the source file in gdb/source.c, GDB starts with
looking for source using the "$cdir:$cwd" which is sort
of expanded in at least two places. It will first expand
the compilation directory ($cdir) and pass to openp() function in
source.c something like: "c:/mydir/:$cwd".

However, openp() will also search for the ':' sourcepath delimiter in
order to possibly find $cwd. And since the delimiter is part of the
Windows style path, things start going wrong.

Rather than trying to fix the problem in openp(), I applied the following
in buildsym.c in order to fix paths when building the symbol table.
The below fix worked for me, but I have no clue how GDB actually works,
so I don't know if there are any sideeffects.

Best regards

/* Start recording information about source code that came from an
   included (or otherwise merged-in) source file with a different
   name.  NAME is the name of the file (cannot be NULL), DIRNAME is
   the directory in which it resides (or NULL if not known).  */

/* START FIX by Kristian Otnes, 2003-09-28, see details below */
#ifdef __CYGWIN__
#include <windows.h>	    	/* For MAX_PATH...  */
#include <sys/cygwin.h>		/* For cygwin_conv_to_...  */
/* END FIX by Kristian Otnes, 2003-09-28 */

start_subfile (char *name, char *dirname)
  struct subfile *subfile;

  /* START FIX by Kristian Otnes, 2003-09-28 */
  /* In case the symbol info contained Windows type paths (c:\...) we */
  /* should convert to Posix style path. Otherwise there might be */
  /* problems later with opening source files in the debugger. */
#ifdef __CYGWIN__
  char *_dirname;
  char *_name;

  /* 'name' will typically not be a full path, but it doesn't hurt to */
  /* convert it to Posix style... */
  if (name)
     _name = alloca(MAX_PATH);
     cygwin_conv_to_posix_path(name, _name);
     name = _name;

  if (dirname)
     _dirname = alloca(MAX_PATH);
     cygwin_conv_to_posix_path(dirname, _dirname);
     dirname = _dirname;
  /* END FIX by Kristian Otnes, 2003-09-28 */

  /* See if this subfile is already known as a subfile of the current
     main source file.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]