This is the mail archive of the mailing list for the Archer 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]

[python] Add the script.

I didn't test this patch, I hope it's ok. :-)
Do I need to make install to be able to use the require facility?

Is there a way to make GDB use the python library from the build
directory? Perhaps by putting some code in $BUILD/gdb/.gdbinit?

Also, the other scripts have an "import gdb" line. Is it necessary when
the script is loaded from the library dir? I added it to this script,
just in case.

2008-11-24  Thiago Jung Bauermann  <>

	* (PY_FILES): Add
	* python/lib/gdb/function/ New file.

diff --git a/gdb/ b/gdb/
index 6ef02bf..497e26e 100644
--- a/gdb/
+++ b/gdb/
@@ -1923,8 +1923,8 @@ PY_DIRS = gdb gdb/command gdb/function gdb/libstdcxx gdb/libstdcxx/v6
 # Note that we should only install files in the "gdb" module.
 PY_FILES = gdb/ gdb/command/ \
     gdb/command/ gdb/command/ \
-    gdb/function/ gdb/ \
-    gdb/ gdb/libstdcxx/v6/
+    gdb/function/ gdb/function/ \
+    gdb/ gdb/ gdb/libstdcxx/v6/
 # Install the Python library.  Python library files go under
 # $(GDB_DATADIR_PATH)/python.  We create a dummy for
diff --git a/gdb/python/lib/gdb/function/ b/gdb/python/lib/gdb/function/
new file mode 100644
index 0000000..f110b6a
--- /dev/null
+++ b/gdb/python/lib/gdb/function/
@@ -0,0 +1,43 @@
+# In-scope function.
+# Copyright (C) 2008 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <>.
+import gdb
+class InScope (gdb.Function):
+    """Check if all the given variables or macros are in scope.
+Receives as argument a list of names separated by whitespace."""
+    def __init__ (self):
+	super (InScope, self).__init__ ("in_scope")
+    def invoke (self, var):
+	vars = set (var.string().split())
+	found = set ()
+	block = gdb.get_block_for_pc (gdb.get_selected_frame ().get_pc ())
+	while block:
+	    for sym in block:
+		if (sym.is_argument () or sym.is_constant ()
+		      or sym.is_function () or sym.is_variable ()):
+		    sym_name = sym.get_print_name ()
+		    if sym_name in vars:
+			found.add (sym_name)
+	    block = block.get_superblock ()
+	return vars == found
+InScope ()

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