public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Improve "skip file X" behaviour to allow quiet adding of skip entries in .gdbinit
@ 2013-08-10 14:21 Richard Geary
  2013-08-13 15:13 ` Pedro Alves
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Geary @ 2013-08-10 14:21 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1672 bytes --]

Description :

Rationale : I want my gdb to always skip the system headers in
/usr/include. But adding (say) "skip file
/usr/include/c++/4.6/debug/safe_iterator.h" to the .gdbinit file will
be ignored as there's no symbols loaded at that point. This was not my
expectation. This patch changes this behaviour so the skip file entry
is added for future loads, and can be done quietly.

Observed Behaviour :
Adding "skip file /usr/include/c++/4.6/debug/safe_iterator.h" to the
.gdbinit produces this message when gdb loads :

No source file named /usr/include/c++/4.6/debug/safe_iterator.h
Ignore file pending future shared library load? (y or [n]) [answered
N; input not from terminal]

Using "server skip file /usr/include/c++/4.6/debug/safe_iterator.h" in
the .gdbinit file produces :
No source file named /usr/include/c++/4.6/debug/safe_iterator.h

For both commands, no skip file entry is added as the default answer is N.

Expected Behaviour :
Add the skip file entry quietly for pending future library loads.

Change :
 - Change the default answer to the "Ignore..." question to Y.
 - When run as a server command, hide the "No source file named "...
message to allow the user to quietly add skip entries

Testing :
 Behaviour observed on Ubuntu 12.04 and Fedora 17
 Reproduce with
   find /usr/include/c++/ -type f | awk '{ print "server skip file "$1
}' > ~/.gdbskip
   echo "source ~/.gdbskip" >> ~/.gdbinit


Change Log
2013-08-10   Richard Geary  <tristram987@gmail.com>
 * skip.c : Change skip file default answer to Y (skip_file_command)
  Quietly add skip entries using "sever skip file X"
  (skip_file_command, skip_function_command)


Thanks,

Richard Geary

[-- Attachment #2: skip.patch --]
[-- Type: application/octet-stream, Size: 2129 bytes --]

--- ./gdb/skip.c.orig	2013-08-10 10:10:07.495989477 -0400
+++ ./gdb/skip.c	2013-08-10 10:10:13.508184797 -0400
@@ -34,6 +34,7 @@
 #include "breakpoint.h" /* for get_sal_arch () */
 #include "source.h"
 #include "filenames.h"
+#include "top.h"
 
 struct skiplist_entry
 {
@@ -91,9 +92,9 @@ skip_file_command (char *arg, int from_t
       symtab = lookup_symtab (arg);
       if (symtab == NULL)
 	{
-	  fprintf_filtered (gdb_stderr, _("No source file named %s.\n"), arg);
-	  if (!nquery (_("\
-Ignore file pending future shared library load? ")))
+      if (!server_command)
+        fprintf_filtered (gdb_stderr, _("No source file named %s.\n"), arg);
+      if (!yquery (_("Ignore file pending future shared library load? ")))
 	    return;
 	}
       /* Do not use SYMTAB's filename, later loaded shared libraries may match
@@ -107,7 +108,8 @@ Ignore file pending future shared librar
 
   add_skiplist_entry (e);
 
-  printf_filtered (_("File %s will be skipped when stepping.\n"), filename);
+  if (!server_command)
+    printf_filtered (_("File %s will be skipped when stepping.\n"), filename);
 }
 
 static void
@@ -135,17 +137,16 @@ skip_function_command (char *arg, int fr
     {
       if (lookup_symbol (arg, NULL, VAR_DOMAIN, NULL) == NULL)
         {
-	  fprintf_filtered (gdb_stderr,
-			    _("No function found named %s.\n"), arg);
+          if (!server_command)
+            fprintf_filtered (gdb_stderr, _("No function found named %s.\n"), arg);
 
-	  if (nquery (_("\
-Ignore function pending future shared library load? ")))
+	  if (yquery (_("Ignore function pending future shared library load? ")))
 	    {
 	      /* Add the unverified skiplist entry.  */
 	      skip_function (arg);
 	    }
 	  return;
-	}
+	      }
 
       skip_function (arg);
     }
@@ -302,7 +303,8 @@ skip_function (const char *name)
 
   add_skiplist_entry (e);
 
-  printf_filtered (_("Function %s will be skipped when stepping.\n"), name);
+  if (!server_command)
+    printf_filtered (_("Function %s will be skipped when stepping.\n"), name);
 }
 
 /* Add the given skiplist entry to our list, and set the entry's number.  */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Improve "skip file X" behaviour to allow quiet adding of skip entries in .gdbinit
  2013-08-10 14:21 [PATCH] Improve "skip file X" behaviour to allow quiet adding of skip entries in .gdbinit Richard Geary
@ 2013-08-13 15:13 ` Pedro Alves
  0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2013-08-13 15:13 UTC (permalink / raw)
  To: Richard Geary; +Cc: gdb-patches

First off, thanks.

On 08/10/2013 03:21 PM, Richard Geary wrote:

>  - Change the default answer to the "Ignore..." question to Y.
>  - When run as a server command, hide the "No source file named "...
> message to allow the user to quietly add skip entries

Unfortunately, this conflates more than one orthogonal change.  Each
should be driven by their own rationale, as separate patches/posts.

For the first change, you'll need to argue why "y" is a better default.
Please note also <http://sourceware.org/bugzilla/show_bug.cgi?id=15800>.

For the second change, you'll need to argue why "server" is the
proper fit here.  Suppressing output is not how "server" behaves
in any other case, AFAICS.  A frontend using it does want to see
the sub command's output to be able to know what happened.

From the code:

/* Nonzero if the current command is modified by "server ".  This
   affects things like recording into the command history, commands
   repeating on RETURN, etc.  This is so a user interface (emacs, GUI,
   whatever) can issue its own commands and also send along commands
   from the user, and have the user not notice that the user interface
   is issuing commands too.  */

and from the manual:

 To issue a command to @value{GDBN} without affecting certain aspects of
 the state which is seen by users, prefix it with @samp{server }
 (@pxref{Server Prefix}).  This
 means that this command will not affect the command history, nor will it
 affect @value{GDBN}'s notion of which command to repeat if @key{RET} is
 pressed on a line by itself.

(Naturally, the frontend will hide the command's output from the user
somehow.)

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-13 15:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-10 14:21 [PATCH] Improve "skip file X" behaviour to allow quiet adding of skip entries in .gdbinit Richard Geary
2013-08-13 15:13 ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).