This is the mail archive of the gdb@sources.redhat.com 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]

Re: DOS/Windows-specific code: source.c


> Date: Tue, 8 May 2001 14:12:46 -0400
> From: Christopher Faylor <cgf@redhat.com>
> 
> On Tue, May 08, 2001 at 02:49:19PM +0300, Eli Zaretskii wrote:
> >
> >    * source.c:openp()
> >
> >    #ifdef _WIN32
> >      mode |= O_BINARY;
> >    #endif
> >
> >I think this is obsolete and should be removed: defining
> >CRLF_SOURCE_FILES in xm-whatever should solve the underlying problem.
> >
> >For those who don't know: the problem here is that find_source_lines
> >creates a table which records the byte position of each line in a
> >source file, but many DOS/Windows libraries don't DTRT with byte
> >offsets unless the file is open in binary mode.  So this issue is
> >limited to source files, and CRLF_SOURCE_FILES should provide the
> >solution there for Windows systems.
> >
> >(Code which wants to open binary files, like in exec.c, already uses
> >O_BINARY when it calls openp.  Hmm, perhaps solib.c should be fixed to
> >use O_BINARY when it looks for the libraries.)
> 
> Actually, why not always just use O_BINARY in this file without the
> conditional and remove the use of O_BINARY everywhere else?

Because it's wrong to read source files in binary mode.

This function is used for opening all kinds of files that GDB needs to
search for.  That includes binaries, libraries, and sources.  You
don't want to see those pesky ^M characters and the trailing ^Z when
ou list the source file inside GDB.


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