Date: Tue, 13 Jun 2000 21:39:40 +0530 Message-Id: <200006131609.VAA04537@midpec.com> From: Prashant TR To: eliz AT is DOT elta DOT co DOT il CC: djgpp-workers AT delorie DOT com In-reply-to: (message from Eli Zaretskii on Tue, 13 Jun 2000 13:40:09 +0300 (IDT)) Subject: Re: Patches for FSDB to look for .exe files References: Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > This is IMHO not robust enough: the file could exist, but be a > directory, or something that is not a DJGPP program. I suggest using > _check_v2_prog instead of __file_exists. > > Please also provide a short entry for wc204.txi. Changed. Does it look better now? Prashant --- djgpp/src/debug/fsdb/ed.c~0 Tue Jun 13 09:14:45 2000 +++ djgpp/src/debug/fsdb/ed.c Tue Jun 13 21:23:04 2000 @@ -1,3 +1,4 @@ +/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include @@ -10,6 +11,7 @@ #include "go32.h" #include "dos.h" #include +#include #include /* Workaround for stderr bug below */ extern char *source_path; @@ -67,6 +69,9 @@ int main(int argc, char **argv) { int i; + char *dotptr; + char *fname; + const _v2_prog_type *prog; char cmdline[128]; jmp_buf start_state; int argno; @@ -116,7 +121,27 @@ exit (1); } - syms_init(argv[argno]); + /* Try adding the .exe extension to it and try again. */ + fname = alloca(strlen(argv[argno] + 5)); + strcpy(fname,argv[argno]); + + prog = _check_v2_prog(fname,-1); + if (!prog->valid) + { + dotptr = rindex(fname,'.'); + if (_USE_LFN || dotptr == NULL) + strcat(fname,".exe"); + else + if (dotptr < rindex(fname,'/') || dotptr < rindex(fname,'\\')) + strcat(fname,".exe"); + } + prog = _check_v2_prog(fname,-1); + if (!prog->valid || prog->object_format!=_V2_OBJECT_FORMAT_COFF) + { + printf("Load failed for image %s\n",argv[1]); + exit(1); + } + syms_init(fname); cmdline[1] = 0; for (i = argno + 1; argv[i]; i++) { @@ -126,10 +151,11 @@ i = strlen(cmdline+1); cmdline[0] = i; cmdline[i+1] = 13; - if(v2loadimage(argv[argno],cmdline,start_state)) { - printf("Load failed for image %s\n",argv[1]); - exit(1); - } + if (v2loadimage(fname,cmdline,start_state)) + { + printf("Load failed for image %s\n",argv[1]); + exit(1); + } edi_init(start_state); stdout->_file = dup(fileno(stdout)); --- djgpp/src/docs/kb/wc204.txi~0 Tue Jun 13 21:14:25 2000 +++ djgpp/src/docs/kb/wc204.txi Tue Jun 13 21:32:44 2000 @@ -5,3 +5,7 @@ @findex uname AT r{, CPU type detection} Ability to report the exact CPU type in @code{uname}. + +@findex fsdb, check for EXEs +@code{fsdb} checks for executables and loads them even if +the extension ``.EXE'' isn't given in the command line.