From: Martin Hunt Date: Tue, 21 Jul 1998 18:40:06 +0000 (+0000) Subject: (gdb_listfiles): Fix comments and cleanup. X-Git-Tag: gdb-4_18~1563 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c56157ffa82ab988eadffc6abc51c061b6da742;p=external%2Fbinutils.git (gdb_listfiles): Fix comments and cleanup. --- diff --git a/gdb/gdbtk-cmds.c b/gdb/gdbtk-cmds.c index 221e3e6..4a7cd6f 100644 --- a/gdb/gdbtk-cmds.c +++ b/gdb/gdbtk-cmds.c @@ -1140,13 +1140,21 @@ gdb_find_file_command (clientData, interp, objc, objv) * * This lists all the files in the current executible. * + * Note that this currently pulls in all sorts of filenames + * that aren't really part of the executable. It would be + * best if we could check each file to see if it actually + * contains executable lines of code, but we can't do that + * with psymtabs. + * * Arguments: * ?pathname? - If provided, only files which match pathname - * (up to strlen(pathname)) are included. + * (up to strlen(pathname)) are included. THIS DOES NOT + * CURRENTLY WORK BECAUSE PARTIAL_SYMTABS DON'T SUPPLY + * THE FULL PATHNAME!!! + * * Tcl Result: * A list of all matching files. */ - static int gdb_listfiles (clientData, interp, objc, objv) ClientData clientData; @@ -1180,15 +1188,14 @@ gdb_listfiles (clientData, interp, objc, objv) files_size = files_size * 2; files = (char **) xrealloc (files, sizeof (char *) * files_size); } - if (len == 0) + if (psymtab->filename) { - if (psymtab->filename) - files[numfiles++] = basename(psymtab->filename); + if (!len || !strncmp(pathname, psymtab->filename,len) + || !strcmp(psymtab->filename, basename(psymtab->filename))) + { + files[numfiles++] = basename(psymtab->filename); + } } - else if (!strcmp(psymtab->filename,basename(psymtab->filename)) - || !strncmp(pathname,psymtab->filename,len)) - if (psymtab->filename) - files[numfiles++] = basename(psymtab->filename); } ALL_SYMTABS (objfile, symtab) @@ -1198,15 +1205,14 @@ gdb_listfiles (clientData, interp, objc, objv) files_size = files_size * 2; files = (char **) xrealloc (files, sizeof (char *) * files_size); } - if (len == 0) + if (symtab->filename && symtab->linetable && symtab->linetable->nitems) { - if (symtab->filename) - files[numfiles++] = basename(symtab->filename); + if (!len || !strncmp(pathname, symtab->filename,len) + || !strcmp(symtab->filename, basename(symtab->filename))) + { + files[numfiles++] = basename(symtab->filename); + } } - else if (!strcmp(symtab->filename,basename(symtab->filename)) - || !strncmp(pathname,symtab->filename,len)) - if (symtab->filename) - files[numfiles++] = basename(symtab->filename); } qsort (files, numfiles, sizeof(char *), comp_files);