diff -rup gdb-7.2-orig/gdb/frame.c gdb-7.2/gdb/frame.c --- gdb-7.2-orig/gdb/frame.c 2010-07-01 19:36:15.000000000 +0400 +++ gdb-7.2/gdb/frame.c 2011-07-24 23:33:44.297616001 +0400 @@ -205,6 +205,15 @@ An upper bound on the number of backtrac value); } +static int backtrace_skip_compile; +static void +show_backtrace_skip_compile (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("\ +Whether compile path should be skipped in backtraces is %s.\n"), + value); +} static void fprint_field (struct ui_file *file, const char *name, int p, CORE_ADDR addr) @@ -1900,6 +1909,22 @@ find_frame_sal (struct frame_info *frame (*sal) = find_pc_line (get_frame_pc (frame), notcurrent); } +char * +get_display_filename_from_sal (struct symtab_and_line *sal) +{ + const char *filename = sal->symtab->filename; + const char *dirname = sal->symtab->dirname; + + if (backtrace_skip_compile && filename && dirname + && strstr(filename, dirname)) + { + /* +1 means skip directory separator */ + return filename + strlen(dirname) + 1; + } + + return filename; +} + /* Per "frame.h", return the ``address'' of the frame. Code should really be using get_frame_id(). */ CORE_ADDR @@ -2270,6 +2295,16 @@ Zero is unlimited."), &set_backtrace_cmdlist, &show_backtrace_cmdlist); + add_setshow_boolean_cmd ("skip-compile-dir", class_obscure, + &backtrace_skip_compile, _("\ +Set whether compile path should be skipped in backtraces."), _("\ +Show whether compile path should be skipped in backtraces."), _("\ +Normally compile path is displayed if it's exists."), + NULL, + show_backtrace_skip_compile, + &set_backtrace_cmdlist, + &show_backtrace_cmdlist); + /* Debug this files internals. */ add_setshow_zinteger_cmd ("frame", class_maintenance, &frame_debug, _("\ Set frame debugging."), _("\ diff -rup gdb-7.2-orig/gdb/frame.h gdb-7.2/gdb/frame.h --- gdb-7.2-orig/gdb/frame.h 2010-01-01 10:31:32.000000000 +0300 +++ gdb-7.2/gdb/frame.h 2011-07-24 23:33:36.827616001 +0400 @@ -327,6 +327,11 @@ extern CORE_ADDR get_frame_func (struct extern void find_frame_sal (struct frame_info *frame, struct symtab_and_line *sal); +/* Returns filename with or without compile path. + It depends on 'set backtrace skip-compile-dir'. */ + +extern char *get_display_filename_from_sal (struct symtab_and_line *sal); + /* Set the current source and line to the location given by frame FRAME, if possible. When CENTER is true, adjust so the relevant line is in the center of the next 'list'. */ diff -rup gdb-7.2-orig/gdb/stack.c gdb-7.2/gdb/stack.c --- gdb-7.2-orig/gdb/stack.c 2010-07-01 19:36:17.000000000 +0400 +++ gdb-7.2/gdb/stack.c 2011-07-24 23:33:44.437616001 +0400 @@ -810,11 +810,15 @@ print_frame (struct frame_info *frame, i ui_out_text (uiout, ")"); if (sal.symtab && sal.symtab->filename) { + const char *display_filename = get_display_filename_from_sal(&sal); + if (display_filename == NULL) + display_filename = sal.symtab->filename; + annotate_frame_source_begin (); ui_out_wrap_hint (uiout, " "); ui_out_text (uiout, " at "); annotate_frame_source_file (); - ui_out_field_string (uiout, "file", sal.symtab->filename); + ui_out_field_string (uiout, "file", display_filename); if (ui_out_is_mi_like_p (uiout)) { const char *fullname = symtab_to_fullname (sal.symtab);