This is the mail archive of the gdb-patches@sourceware.org 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]

Re: new feature for "backtrace" that cuts path to file (remain filename)


This topic has discussed some months ago, see:

http://sourceware.org/ml/gdb-patches/2011-12/msg00207.html
and
http://sourceware.org/ml/gdb-patches/2011-08/msg00036.html

Consider Jan's suggestion, I think a modified version get_filename_display_from_sal() which use symtab_to_fullname looks like below:

/* See commentary in frame.h. */

const char *
get_filename_display_from_sal (struct symtab_and_line *sal)
{
  const char *filename = sal->symtab->filename;
  const char *dirname = sal->symtab->dirname;
  size_t dlen = dirname ? strlen (dirname) : 0;

  if (filename == NULL)
    {
      return NULL;
    }
  else if (filename_display_string == filename_display_basename)
    {
      return lbasename (filename);
    }
  else if (filename_display_string == filename_display_without_comp_directory
&& dirname && dlen && dlen <= strlen (filename)
&& !filename_ncmp (filename, dirname, dlen))
    {
      const char *start = filename + dlen;
      const char *result = start;
      while (IS_DIR_SEPARATOR (*result))
    result++;

      if (IS_DIR_SEPARATOR (dirname[dlen - 1]))
    return result;
      else
    return result == start ? filename : result;
    }
  else if (filename_display_string == filename_display_full)
    {
       const char *fullname = symtab_to_fullname (sal->symtab);
       if (fullname!=NULL)
          return fullname;
       else
          return filename;
    }

  return filename;
}

BTW: It works fine under Windows mingw gdb, and I think showing a fullname in the backtrace has some good reasons, because the front end of gdb like (Codeblocks IDE) can quickly locate/navigate the source, but it may failed when bt command show some relative paths.


Zhang Yuanhui ollydbg from codeblocks' forum



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