[nemiver/better-variable-format: 2/8] Enable GDB pretty printers by default
- From: Dodji Seketeli <dodji src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver/better-variable-format: 2/8] Enable GDB pretty printers by default
- Date: Tue, 30 Aug 2011 15:33:20 +0000 (UTC)
commit 56f8706931f6aaf2da2ca52cb964783d7c3d945c
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, 59 insertions(+), 1 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index ce03eb9..8f0735e 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -219,6 +219,7 @@ public:
UString follow_fork_mode;
UString disassembly_flavor;
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;
@@ -541,8 +542,12 @@ public:
cur_thread_num (1),
follow_fork_mode ("parent"),
disassembly_flavor ("att"),
- 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
@@ -2982,6 +2987,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);
@@ -5543,6 +5550,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 692a082..3d670bb 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -586,6 +586,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 47ef1e7..5f130de 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -1398,6 +1398,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 f30ec84..bce8753 100644
--- a/tests/test-breakpoint.cc
+++ b/tests/test-breakpoint.cc
@@ -239,6 +239,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, "",
diff --git a/tests/test-types.cc b/tests/test-types.cc
index 6b2e2a7..962a1be 100644
--- a/tests/test-types.cc
+++ b/tests/test-types.cc
@@ -96,11 +96,13 @@ 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, "", false);
debugger->set_breakpoint ("func1");
+
debugger->run ();
loop->run ();
diff --git a/tests/test-var-path-expr.cc b/tests/test-var-path-expr.cc
index 0d871be..2936144 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, "", false);
diff --git a/tests/test-vars.cc b/tests/test-vars.cc
index a45e312..d3db5fa 100644
--- a/tests/test-vars.cc
+++ b/tests/test-vars.cc
@@ -273,6 +273,7 @@ test_main (int, char **)
//</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]