* Rename remote-es1800.c to remote-es.c
[deliverable/binutils-gdb.git] / gdb / printcmd.c
index b5bf3d8d06da6dba88befafc3d5519807a82e7fd..c6d4a6c29d9856d4dcc4ceaef1faa7d097c2ccce 100644 (file)
@@ -73,6 +73,10 @@ static value last_examine_value;
 
 static unsigned int max_symbolic_offset = UINT_MAX;
 
+/* Append the source filename and linenumber of the symbol when
+   printing a symbolic value as `<symbol at filename:linenum>' if set.  */
+static int print_symbol_filename = 0;
+
 /* Number of auto-display expression currently being displayed.
    So that we can disable it if we get an error or a signal within it.
    -1 when not doing one.  */
@@ -582,9 +586,18 @@ print_address_symbolic (addr, stream, do_demangle, leadin)
   fputs_filtered ("<", stream);
   fputs_filtered (name, stream);
   if (addr != name_location)
-    fprintf_filtered (stream, "+%u>", (unsigned int)(addr - name_location));
-  else
-    fputs_filtered (">", stream);
+    fprintf_filtered (stream, "+%u", (unsigned int)(addr - name_location));
+
+  /* Append source filename and line number if desired.  */
+  if (symbol && print_symbol_filename)
+    {
+      struct symtab_and_line sal;
+
+      sal = find_pc_line (addr, 0);
+      if (sal.symtab)
+       fprintf_filtered (stream, " at %s:%d", sal.symtab->filename, sal.line);
+    }
+  fputs_filtered (">", stream);
 }
 
 /* Print address ADDR symbolically on STREAM.
@@ -2070,4 +2083,10 @@ environment, the value is printed in its own window.");
        "Set the largest offset that will be printed in <symbol+1234> form.",
                   &setprintlist),
       &showprintlist);
+  add_show_from_set (
+      add_set_cmd ("symbol-filename", no_class, var_boolean,
+                  (char *)&print_symbol_filename,
+       "Set printing of source filename and line number with <symbol>.",
+                  &setprintlist),
+      &showprintlist);
 }
This page took 0.022817 seconds and 4 git commands to generate.