public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-pmuldoon-python-backtrace: Remove stand-alone example
@ 2012-03-12 13:40 pmuldoon
  0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2012-03-12 13:40 UTC (permalink / raw)
  To: archer-commits

The branch, archer-pmuldoon-python-backtrace has been updated
       via  7972a7490fd571409b7b2910e6ebc316619eb09e (commit)
       via  7d7558af9eb6cbab758ca420feac972f0181c537 (commit)
      from  c300a80104d86c41d254429fb0e94fa94e93b8ae (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 7972a7490fd571409b7b2910e6ebc316619eb09e
Author: Phil Muldoon <pmuldoon@redhat.com>
Date:   Mon Mar 12 13:39:33 2012 +0000

    Remove stand-alone example

commit 7d7558af9eb6cbab758ca420feac972f0181c537
Author: Phil Muldoon <pmuldoon@redhat.com>
Date:   Mon Mar 12 13:38:22 2012 +0000

    Add basic test

-----------------------------------------------------------------------

Summary of changes:
 gdb/frame_ex.py                             |   43 -------------
 gdb/testsuite/gdb.python/py-framefilter.c   |   86 +++++++++++++++++++++++++++
 gdb/testsuite/gdb.python/py-framefilter.exp |   45 ++++++++++++++
 gdb/testsuite/gdb.python/py-framefilter.py  |   61 +++++++++++++++++++
 4 files changed, 192 insertions(+), 43 deletions(-)
 delete mode 100644 gdb/frame_ex.py
 create mode 100644 gdb/testsuite/gdb.python/py-framefilter.c
 create mode 100644 gdb/testsuite/gdb.python/py-framefilter.exp
 create mode 100644 gdb/testsuite/gdb.python/py-framefilter.py

First 500 lines of diff:
diff --git a/gdb/frame_ex.py b/gdb/frame_ex.py
deleted file mode 100644
index fe809eb..0000000
--- a/gdb/frame_ex.py
+++ /dev/null
@@ -1,43 +0,0 @@
-flevel = 0
-
-class Main_filter:
-    "Example main () filter"
-
-    def __init__ (self, frame, what, level, args):
-        self.frame = frame
-        self.what = what
-        self.lvl = level
-        self.args = args
-        
-
-    def function (self):
-        return str (self.frame.function())
-
-    def level (self):
-        global flevel
-        rlevel = flevel
-        flevel = flevel + 1
-        return rlevel
-
-    def address (self):
-        return self.frame.pc()
-
-    def filename (self):
-        sal = self.frame.find_sal()
-        if (sal):
-            return sal.symtab.filename
-        else:
-            return "unknown"
-
-    def line (self):
-        sal = self.frame.find_sal()
-        if (sal):
-            return sal.line        
-        else:
-            return "<unknown line>"
-
-def register_frame_filters (frame, what, level, args):
-
-#    if (frame.name() == "main"):
-        x = Main_filter (frame, what, level, args)
-        return x
diff --git a/gdb/testsuite/gdb.python/py-framefilter.c b/gdb/testsuite/gdb.python/py-framefilter.c
new file mode 100644
index 0000000..26f561f
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-framefilter.c
@@ -0,0 +1,86 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2008-2012 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
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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 <http://www.gnu.org/licenses/>.  */
+
+
+void funca(void);
+int count = 0;
+
+void end_func (void)
+{
+  return; /* Backtrace end breakpoint */
+}
+
+void funcb(int j)
+{
+  funca();
+  return;
+}
+
+void funca(void)
+{
+  if (count < 10)
+    {
+      count++;
+      funcb(count);
+    }
+  
+  end_func();
+  return;
+}
+
+
+void func1(void)
+{
+  funca();
+  return;
+}
+
+int func2(void)
+{  
+  
+  func1();
+  return 1;
+}
+
+void func3(int i)
+{
+  func2();
+
+  return;
+}
+
+int func4(int j)
+{
+  func3(j);
+
+  return 2;
+}
+
+int func5(int f)
+{
+  int i = 0;
+  i=i+f;
+  
+  func4(i);
+  return i;
+}
+    
+main()
+{
+  func5(3);
+}
+
diff --git a/gdb/testsuite/gdb.python/py-framefilter.exp b/gdb/testsuite/gdb.python/py-framefilter.exp
new file mode 100644
index 0000000..73c1ba5
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-framefilter.exp
@@ -0,0 +1,45 @@
+# Copyright (C) 2012 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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# 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 <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite.  It tests Python-based
+# frame-filters.
+
+load_lib gdb-python.exp
+
+set testfile "py-framefilter"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+    return -1
+}
+
+# Skip all tests if Python scripting is not enabled.
+if { [skip_python_tests] } { continue }
+
+set nl "\[\r\n\]+"
+
+if ![runto_main ] then {
+    perror "couldn't run to breakpoint"
+    return
+}
+
+set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
+gdb_test_no_output "python execfile ('${remote_python_file}')"
+gdb_test_no_output "python gdb.frame_filters.append(register_frame_filters)"
+gdb_breakpoint [gdb_get_line_number "Backtrace end breakpoint"]
+gdb_continue_to_breakpoint "Bactrace end breakpoint"
+gdb_test "bt" "#1.*in end_func.*#23.*in func1.*#27.*in main ().*"
+remote_file host delete ${remote_python_file}
diff --git a/gdb/testsuite/gdb.python/py-framefilter.py b/gdb/testsuite/gdb.python/py-framefilter.py
new file mode 100644
index 0000000..b7ee5c5
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-framefilter.py
@@ -0,0 +1,61 @@
+# Copyright (C) 2012 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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# 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 <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite.  It tests Python-based
+# frame-filters.
+
+flevel = 0
+
+class Main_filter:
+    "Example main () filter"
+
+    def __init__ (self, frame, what, level, args):
+        self.frame = frame
+        self.what = what
+        self.lvl = level
+        self.args = args
+        
+
+    def function (self):
+        return str (self.frame.function())
+
+    def level (self):
+        global flevel
+        rlevel = flevel
+        flevel = flevel + 1
+        return rlevel
+
+    def address (self):
+        return self.frame.pc()
+
+    def filename (self):
+        sal = self.frame.find_sal()
+        if (sal):
+            return sal.symtab.filename
+        else:
+            return "unknown"
+
+    def line (self):
+        sal = self.frame.find_sal()
+        if (sal):
+            return sal.line        
+        else:
+            return "<unknown line>"
+
+def register_frame_filters (frame, what, level, args):
+
+#    if (frame.name() == "main"):
+        x = Main_filter (frame, what, level, args)
+        return x


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-03-12 13:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-12 13:40 [SCM] archer-pmuldoon-python-backtrace: Remove stand-alone example pmuldoon

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).