[nemiver/better-variable-format: 2/8] Enable GDB pretty printers by default



commit 5a56fed080e95e9ee24be952fcf26b2a68b86dda
Author: Dodji Seketeli <dodji gnome org>
Date:   Sun Sep 12 11:42:21 2010 +0200

    Enable GDB pretty printers by default
    
    	* src/dbgengine/nmv-i-debugger.h
    	(IDebugger::disable_pretty_printing)
    	(IDebugger::set_variable_vizualizer): New ifaces.
    	* src/dbgengine/nmv-gdb-engine.h
    	(GDBEngine::disable_pretty_printing)
    	(GDBEngine::set_variable_vizualizer): Likewise.
    	* src/dbgengine/nmv-gdb-engine.cc
    	(GDBEngine::Priv::disable_pretty_printing): New member.
    	(GDBEngine::Priv::Priv): Initialize
    	GDBEngine::Priv::disable_pretty_printing if
    	NMV_DISABLE_PRETTY_PRINTING is set.
    	(GDBengine::disable_pretty_printing)
    	(GDBEngine::set_variable_vizualizer): Implement new interfaces.
    	(GDBEngine::load_program): Enable GDB pretty printers by default.
    	* tests/test-breakpoint.cc (test_main): Disable GDB pretty
    	printers to keep this test working as before.
    	* tests/test-var-path-expr.cc (test_main): Likewise.
    	* tests/test-vars.cc (test_main): Likewise.
    	* tests/test-types.cc (test_main): Likewise.

 src/dbgengine/nmv-gdb-engine.cc |   43 ++++++++++++++++++++++++++++++++++++++-
 src/dbgengine/nmv-gdb-engine.h  |    6 +++++
 src/dbgengine/nmv-i-debugger.h  |    6 +++++
 tests/test-breakpoint.cc        |    1 +
 tests/test-types.cc             |    2 +-
 tests/test-var-path-expr.cc     |    1 +
 tests/test-vars.cc              |    1 +
 7 files changed, 58 insertions(+), 2 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index b34e2a5..39e7e8d 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -132,6 +132,7 @@ public:
     UString debugger_full_path;
     UString follow_fork_mode;
     GDBMIParser gdbmi_parser;
+    bool disable_pretty_printing;
     sigc::signal<void> gdb_died_signal;
     sigc::signal<void, const UString& > master_pty_signal;
     sigc::signal<void, const UString& > gdb_stdout_signal;
@@ -449,8 +450,12 @@ public:
         cur_frame_level (0),
         cur_thread_num (1),
         follow_fork_mode ("parent"),
-        gdbmi_parser (GDBMIParser::BROKEN_MODE)
+        gdbmi_parser (GDBMIParser::BROKEN_MODE),
+        disable_pretty_printing (false)
     {
+        disable_pretty_printing =
+            g_getenv ("NMV_DISABLE_PRETTY_PRINTING") != 0;
+
         gdb_stdout_signal.connect (sigc::mem_fun
                 (*this, &Priv::on_gdb_stdout_signal));
         master_pty_signal.connect (sigc::mem_fun
@@ -2759,6 +2764,8 @@ GDBEngine::load_program (const UString &a_prog,
         } else {
             LOG_DD ("not setting LD_BIND_NOW environment variable ");
         }
+        if (!m_priv->disable_pretty_printing)
+            queue_command (Command ("-enable-pretty-printing"));
     } else {
         Command command ("load-program",
                          UString ("-file-exec-and-symbols ") + a_prog);
@@ -5123,6 +5130,40 @@ GDBEngine::set_variable_format (const VariableSafePtr a_var,
     queue_command (command);
 }
 
+void
+GDBEngine::disable_pretty_printing ()
+{
+    m_priv->disable_pretty_printing = true;
+}
+
+/// Set the variable vizualizer used by the GDB Pretty Printing system
+/// to print the value of a given variable.
+/// \param a_var the variable to set the vizualizer for.
+/// \param a_vizualizer a string representing the vizualizer to set
+/// for this variable. If you don't want any vizualizer to be set,
+/// then set this variableto "None". If you want the default
+/// vizualizer for this type to be set, then set this variable to
+/// "gdb.default_visualizer".
+void
+GDBEngine::set_variable_vizualizer (const VariableSafePtr a_var,
+				    const std::string &a_vizualizer,
+				    const UString &a_cookie)
+{
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+    THROW_IF_FAIL (a_var);
+    THROW_IF_FAIL (!a_var->internal_name ().empty ());
+
+    UString cmd_str = "-var-set-vizualizer ";
+    cmd_str += a_var->internal_name () + " ";
+    cmd_str += a_vizualizer;
+
+    Command command ("set-variable-vizualizer",
+                     cmd_str, a_cookie);
+    command.variable (a_var);
+    queue_command (command);
+}
+
 //****************************
 //</GDBEngine methods>
 //****************************
diff --git a/src/dbgengine/nmv-gdb-engine.h b/src/dbgengine/nmv-gdb-engine.h
index 0ba717c..3ff7206 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -556,6 +556,12 @@ public:
     void set_variable_format (const VariableSafePtr a_var,
 			      const Variable::Format a_format,
 			      const UString &a_cookie);
+
+    void disable_pretty_printing ();
+
+    void set_variable_vizualizer (const VariableSafePtr a_var,
+				  const std::string &a_vizualizer,
+				  const UString &a_cookie);
 };//end class GDBEngine
 
 NEMIVER_END_NAMESPACE (nemiver)
diff --git a/src/dbgengine/nmv-i-debugger.h b/src/dbgengine/nmv-i-debugger.h
index d1803bc..489b460 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -1338,6 +1338,12 @@ public:
     virtual void set_variable_format (const VariableSafePtr a_var,
                                       const Variable::Format a_format,
                                       const UString &a_cookie = "") = 0;
+
+    virtual void disable_pretty_printing () = 0;
+
+    virtual void set_variable_vizualizer (const VariableSafePtr a_var,
+                                          const std::string &a_vizualizer,
+                                          const UString &a_cookie = "") = 0;
 };//end IDebugger
 
 NEMIVER_END_NAMESPACE (nemiver)
diff --git a/tests/test-breakpoint.cc b/tests/test-breakpoint.cc
index a244143..f0a19a2 100644
--- a/tests/test-breakpoint.cc
+++ b/tests/test-breakpoint.cc
@@ -240,6 +240,7 @@ test_main (int argc, char *argv[])
     //*****************************
 
     std::vector<UString> args, source_search_dir;
+    debugger->disable_pretty_printing ();
     source_search_dir.push_back (".");
     debugger->load_program ("fooprog", args, ".", source_search_dir);
     debugger->set_breakpoint ("main");
diff --git a/tests/test-types.cc b/tests/test-types.cc
index b855764..6fe53f2 100644
--- a/tests/test-types.cc
+++ b/tests/test-types.cc
@@ -96,9 +96,9 @@ test_main (int, char **)
 
     debugger->variable_value_signal ().connect (&on_variable_value_signal);
 
+    debugger->disable_pretty_printing ();
     std::vector<UString> args, source_search_dir;
     source_search_dir.push_back (".");
-
     debugger->load_program ("fooprog", args, ".", source_search_dir);
     debugger->set_breakpoint ("func1");
     debugger->run ();
diff --git a/tests/test-var-path-expr.cc b/tests/test-var-path-expr.cc
index 8dda71d..4ab9f86 100644
--- a/tests/test-var-path-expr.cc
+++ b/tests/test-var-path-expr.cc
@@ -139,6 +139,7 @@ test_main (int argc, char *argv[])
                                                      debugger));
 
     std::vector<UString> args, source_search_dir;
+    debugger->disable_pretty_printing ();
     source_search_dir.push_back (".");
     debugger->load_program ("fooprog", args, ".", source_search_dir);
     debugger->set_breakpoint ("main");
diff --git a/tests/test-vars.cc b/tests/test-vars.cc
index 11e1285..9fc4097 100644
--- a/tests/test-vars.cc
+++ b/tests/test-vars.cc
@@ -274,6 +274,7 @@ test_main (int argc __attribute__((unused)),
     //</connect to IDebugger events>
     //******************************
     vector<UString> args;
+    debugger->disable_pretty_printing ();
     debugger->load_program ("fooprog", args, ".");
     debugger->set_breakpoint ("main");
     debugger->set_breakpoint ("func4");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]