public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* GDB/Cygwin source path problem fix suggestion
@ 2003-09-28  8:59 Kristian Otnes
  0 siblings, 0 replies; 2+ messages in thread
From: Kristian Otnes @ 2003-09-28  8:59 UTC (permalink / raw)
  To: gdb

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
Kris



/* 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_...  */
#endif
/* END FIX by Kristian Otnes, 2003-09-28 */

void
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;
  }
#endif
  /* END FIX by Kristian Otnes, 2003-09-28 */

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: GDB/Cygwin source path problem fix suggestion
@ 2003-09-28 15:50 Kristian Otnes
  0 siblings, 0 replies; 2+ messages in thread
From: Kristian Otnes @ 2003-09-28 15:50 UTC (permalink / raw)
  To: gdb

Eh, I guess one should use MAX_PATH + 1, so the fix would be:



/* 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_...  */
#endif
/* END FIX by Kristian Otnes, 2003-09-28 */

void
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 + 1);
     cygwin_conv_to_posix_path(name, _name);
     name = _name;
  }

  if (dirname)
  {
     _dirname = alloca(MAX_PATH + 1);
     cygwin_conv_to_posix_path(dirname, _dirname);
     dirname = _dirname;
  }
#endif
  /* END FIX by Kristian Otnes, 2003-09-28 */

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-09-28  8:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-28  8:59 GDB/Cygwin source path problem fix suggestion Kristian Otnes
2003-09-28 15:50 Kristian Otnes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).