[nemiver/better-variable-format: 5/8] Add preferences for GDB pretty printing
- From: Dodji Seketeli <dodji src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver/better-variable-format: 5/8] Add preferences for GDB pretty printing
- Date: Tue, 30 Aug 2011 15:33:35 +0000 (UTC)
commit 50a1babf465752c6cfd276bdf97d6a45ed05e2e2
Author: Dodji Seketeli <dodji seketeli org>
Date: Sun Jan 23 01:09:08 2011 +0100
Add preferences for GDB pretty printing
* src/confmgr/nmv-conf-keys.h (CONF_KEY_PRETTY_PRINTING): Declare
new conf key.
* src/confmgr/nmv-conf-keys.cc (CONF_KEY_PRETTY_PRINTING): Define
it.
* src/dbgengine/nmv-gdb-engine.cc
(GDBEngine::Priv::enable_pretty_printing): Rename
GDBEngine::Priv::disable_pretty_printing into this.
(GDBEngine::Priv::Priv, GDBEngine::load_program): Adjust.
(GDB::Engine::Priv::read_default_config): Read the value of key
CONF_KEY_PRETTY_PRINTING as well.
(GDB::Engine::Priv::on_conf_key_changed_signal): Update
GDB::Engine::Priv::enable_pretty_printing.
(GDBEngine::disable_pretty_printing): Update remote conf setting.
* src/persp/dbgperspective/nmv-preferences-dialog.cc
(PreferencesDialog::Priv::pretty_printing_check_button): New check
button.
(PreferencesDialog::Priv::on_pretty_printing_toggled_signal)
(PreferencesDialog::Priv::update_pretty_printing_key): New
functions.
(PreferencesDialog::Priv::init): Deserialize the new
PreferencesDialog::Priv::pretty_printing_check_button.
(PreferencesDialog::Priv::update_widget_from_debugger_keys): Read
the new CONF_KEY_PRETTY_PRINTING key.
* src/persp/dbgperspective/schemas/nemiver-dbgperspective.schemas:
Add new schema for key
/schemas/apps/nemiver/dbgperspective/pretty-printing.
* src/persp/dbgperspective/ui/preferencesdialog.ui: Add a check
button to enable pretty printing in the debugger preference tab.
data/schemas/gconf/nemiver-dbgperspective.schemas | 13 +++
data/schemas/gsettings/org.nemiver.gschema.xml | 6 +
src/confmgr/nmv-conf-keys.h | 1 +
src/confmgr/nmv-gconf-keys-defs.cc | 3 +
src/confmgr/nmv-gsettings-keys-defs.cc | 1 +
src/dbgengine/nmv-gdb-engine.cc | 38 +++++---
src/persp/dbgperspective/nmv-preferences-dialog.cc | 36 +++++++-
src/persp/dbgperspective/ui/preferencesdialog.ui | 105 ++++++++++++++------
tests/test-vars.cc | 4 +-
9 files changed, 160 insertions(+), 47 deletions(-)
---
diff --git a/data/schemas/gconf/nemiver-dbgperspective.schemas b/data/schemas/gconf/nemiver-dbgperspective.schemas
index a0a357c..05d3c06 100644
--- a/data/schemas/gconf/nemiver-dbgperspective.schemas
+++ b/data/schemas/gconf/nemiver-dbgperspective.schemas
@@ -268,6 +268,19 @@
</locale>
</schema>
<schema>
+ <key>/schemas/apps/nemiver/dbgperspective/pretty-printing</key>
+ <applyto>/apps/nemiver/dbgperspective/pretty-printing</applyto>
+ <owner>nemiver</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Activate GDB pretty printing</short>
+ <long>Activate the GDB printing feature. Under that mode the
+content of many types of containers is displayed in a human friendly
+manner</long>
+ </locale>
+ </schema>
+ <schema>
<key>/schemas/apps/nemiver/dbgperspective/callstack-expansion-chunk</key>
<applyto>/apps/nemiver/dbgperspective/callstack-expansion-chunk</applyto>
<owner>nemiver</owner>
diff --git a/data/schemas/gsettings/org.nemiver.gschema.xml b/data/schemas/gsettings/org.nemiver.gschema.xml
index 603d87b..fb02098 100644
--- a/data/schemas/gsettings/org.nemiver.gschema.xml
+++ b/data/schemas/gsettings/org.nemiver.gschema.xml
@@ -144,6 +144,12 @@
<description>Can be either att or intel (Apply only for the x86 family CPU)</description>
</key>
+ <key name ="pretty-printing" type="b">
+ <default>true</default>
+ <summary>Activate GDB pretty printing</summary>
+ <description>Activate the GDB pretty printing feature. Under that mode the content of many types of containers is displayed in a human friendly manner</description>
+ </key>
+
<key name="callstack-expansion-chunk" type="i">
<default>25</default>
<summary>The size of the call stack to display</summary>
diff --git a/src/confmgr/nmv-conf-keys.h b/src/confmgr/nmv-conf-keys.h
index ba33f1d..0d01639 100644
--- a/src/confmgr/nmv-conf-keys.h
+++ b/src/confmgr/nmv-conf-keys.h
@@ -59,6 +59,7 @@ extern const char* CONF_KEY_GDB_BINARY;
extern const char* CONF_KEY_DEFAULT_NUM_ASM_INSTRS;
extern const char* CONF_KEY_FOLLOW_FORK_MODE;
extern const char* CONF_KEY_DISASSEMBLY_FLAVOR;
+extern const char* CONF_KEY_PRETTY_PRINTING;
extern const char* CONF_KEY_CONTEXT_PANE_LOCATION;
extern const char* CONF_KEY_NEMIVER_CALLSTACK_EXPANSION_CHUNK;
extern const char* CONF_KEY_DBG_PERSPECTIVE_LAYOUT;
diff --git a/src/confmgr/nmv-gconf-keys-defs.cc b/src/confmgr/nmv-gconf-keys-defs.cc
index 2df0e8d..950526c 100644
--- a/src/confmgr/nmv-gconf-keys-defs.cc
+++ b/src/confmgr/nmv-gconf-keys-defs.cc
@@ -82,6 +82,9 @@ const char* CONF_KEY_FOLLOW_FORK_MODE =
"/apps/nemiver/dbgperspective/follow-fork-mode";
const char* CONF_KEY_DISASSEMBLY_FLAVOR =
"/apps/nemiver/dbgperspective/disassembly-flavor";
+const char* CONF_KEY_PRETTY_PRINTING =
+ "/apps/nemiver/dbgperspective/pretty-printing";
+
const char* CONF_KEY_CONTEXT_PANE_LOCATION =
"/apps/nemiver/dbgperspective/context-pane-location";
const char* CONF_KEY_NEMIVER_CALLSTACK_EXPANSION_CHUNK =
diff --git a/src/confmgr/nmv-gsettings-keys-defs.cc b/src/confmgr/nmv-gsettings-keys-defs.cc
index 1ce2756..1bc7ec2 100644
--- a/src/confmgr/nmv-gsettings-keys-defs.cc
+++ b/src/confmgr/nmv-gsettings-keys-defs.cc
@@ -64,6 +64,7 @@ const char* CONF_KEY_DEFAULT_NUM_ASM_INSTRS = "default-num-asm-instrs";
const char* CONF_KEY_GDB_BINARY = "gdb-binary";
const char* CONF_KEY_FOLLOW_FORK_MODE = "follow-fork-mode";
const char* CONF_KEY_DISASSEMBLY_FLAVOR = "disassembly-flavor";
+const char* CONF_KEY_PRETTY_PRINTING = "pretty-printing";
const char* CONF_KEY_CONTEXT_PANE_LOCATION = "context-pane-location";
const char* CONF_KEY_NEMIVER_CALLSTACK_EXPANSION_CHUNK =
"callstack-expansion-chunk";
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 8f0735e..cfc380e 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -65,6 +65,7 @@ NEMIVER_BEGIN_NAMESPACE (nemiver)
extern const char* CONF_KEY_GDB_BINARY;
extern const char* CONF_KEY_FOLLOW_FORK_MODE;
extern const char* CONF_KEY_DISASSEMBLY_FLAVOR;
+extern const char* CONF_KEY_PRETTY_PRINTING;
// Helper function to handle escaping the arguments
static UString
@@ -219,7 +220,7 @@ public:
UString follow_fork_mode;
UString disassembly_flavor;
GDBMIParser gdbmi_parser;
- bool disable_pretty_printing;
+ bool enable_pretty_printing;
sigc::signal<void> gdb_died_signal;
sigc::signal<void, const UString& > master_pty_signal;
sigc::signal<void, const UString& > gdb_stdout_signal;
@@ -543,10 +544,11 @@ public:
follow_fork_mode ("parent"),
disassembly_flavor ("att"),
gdbmi_parser (GDBMIParser::BROKEN_MODE),
- disable_pretty_printing (false)
+ enable_pretty_printing (true)
{
- disable_pretty_printing =
- g_getenv ("NMV_DISABLE_PRETTY_PRINTING") != 0;
+
+ enable_pretty_printing =
+ g_getenv ("NMV_DISABLE_PRETTY_PRINTING") == 0;
gdb_stdout_signal.connect (sigc::mem_fun
(*this, &Priv::on_gdb_stdout_signal));
@@ -899,6 +901,8 @@ public:
follow_fork_mode);
get_conf_mgr ()->get_key_value (CONF_KEY_DISASSEMBLY_FLAVOR,
disassembly_flavor);
+ get_conf_mgr ()->get_key_value (CONF_KEY_PRETTY_PRINTING,
+ enable_pretty_printing);
}
/// Lists the frames which numbers are in a given range.
@@ -1162,11 +1166,19 @@ public:
NEMIVER_TRY
if (a_key == CONF_KEY_FOLLOW_FORK_MODE
- && conf_mgr->get_key_value (a_key, follow_fork_mode, a_namespace)) {
+ && conf_mgr->get_key_value (a_key,
+ follow_fork_mode,
+ a_namespace)) {
set_debugger_parameter ("follow-fork-mode", follow_fork_mode);
- }
- else if (a_key == CONF_KEY_DISASSEMBLY_FLAVOR && conf_mgr->get_key_value
- (a_key, disassembly_flavor, a_namespace)) {
+ } else if (a_key == CONF_KEY_PRETTY_PRINTING
+ && conf_mgr->get_key_value (a_key,
+ enable_pretty_printing,
+ a_namespace)) {
+ ;
+ } else if (a_key == CONF_KEY_DISASSEMBLY_FLAVOR
+ && conf_mgr->get_key_value (a_key,
+ disassembly_flavor,
+ a_namespace)) {
set_debugger_parameter ("disassembly-flavor", disassembly_flavor);
}
@@ -2987,7 +2999,7 @@ GDBEngine::load_program (const UString &a_prog,
} else {
LOG_DD ("not setting LD_BIND_NOW environment variable ");
}
- if (!m_priv->disable_pretty_printing)
+ if (m_priv->enable_pretty_printing)
queue_command (Command ("-enable-pretty-printing"));
} else {
Command command ("load-program",
@@ -3708,8 +3720,6 @@ GDBEngine::do_init (IConfMgrSafePtr a_conf_mgr)
IConfMgr&
GDBEngine::get_conf_mgr ()
{
-
-
return *m_priv->get_conf_mgr ();
}
@@ -5553,7 +5563,11 @@ GDBEngine::set_variable_format (const VariableSafePtr a_var,
void
GDBEngine::disable_pretty_printing ()
{
- m_priv->disable_pretty_printing = true;
+ // Doing it this way for now b/c you can't change this in GDB on
+ // the fly at the moment.
+ m_priv->enable_pretty_printing = false;
+ get_conf_mgr ().get_key_value (CONF_KEY_PRETTY_PRINTING,
+ m_priv->enable_pretty_printing);
}
/// Set the variable vizualizer used by the GDB Pretty Printing system
diff --git a/src/persp/dbgperspective/nmv-preferences-dialog.cc b/src/persp/dbgperspective/nmv-preferences-dialog.cc
index c66719a..de9b874 100644
--- a/src/persp/dbgperspective/nmv-preferences-dialog.cc
+++ b/src/persp/dbgperspective/nmv-preferences-dialog.cc
@@ -98,6 +98,7 @@ public:
Gtk::RadioButton *follow_child_radio_button;
Gtk::SpinButton *default_num_asm_instrs_spin_button;
Gtk::FileChooserButton *gdb_binary_path_chooser_button;
+ Gtk::CheckButton *pretty_printing_check_button;
Glib::RefPtr<Gtk::Builder> gtkbuilder;
SafePtr<LayoutSelector> layout_selector;
@@ -124,6 +125,7 @@ public:
follow_child_radio_button (0),
default_num_asm_instrs_spin_button (0),
gdb_binary_path_chooser_button (0),
+ pretty_printing_check_button (0),
gtkbuilder (a_gtkbuilder)
{
init ();
@@ -240,6 +242,11 @@ public:
update_follow_fork_mode_key ();
}
+ void on_pretty_printing_toggled_signal ()
+ {
+ update_pretty_printing_key ();
+ }
+
void init ()
{
@@ -460,6 +467,17 @@ public:
(*this,
&PreferencesDialog::Priv::on_follow_fork_mode_toggle_signal));
+ pretty_printing_check_button =
+ ui_utils::get_widget_from_gtkbuilder<Gtk::CheckButton>
+ (gtkbuilder,
+ "prettyprintingcheckbutton");
+ THROW_IF_FAIL (pretty_printing_check_button);
+ pretty_printing_check_button->signal_toggled ().connect
+ (sigc::mem_fun
+ (*this,
+ &PreferencesDialog::Priv::on_pretty_printing_toggled_signal));
+
+
// *************************************
// Handle the "Layout" preferences tab
// *************************************
@@ -470,7 +488,7 @@ public:
layout_selector.reset (new LayoutSelector (layout_manager, perspective));
layout_box->pack_start (layout_selector->widget ());
- layout_box->show_all_children ();
+ layout_box->show_all_children ();
}
void collect_source_dirs ()
@@ -664,6 +682,14 @@ public:
conf_manager ().set_key_value (CONF_KEY_FOLLOW_FORK_MODE, mode);
}
+ void update_pretty_printing_key ()
+ {
+ THROW_IF_FAIL (pretty_printing_check_button);
+
+ bool is_on = pretty_printing_check_button->get_active ();
+ conf_manager ().set_key_value (CONF_KEY_PRETTY_PRINTING, is_on);
+ }
+
void update_widget_from_editor_keys ()
{
THROW_IF_FAIL (show_lines_check_button);
@@ -803,6 +829,14 @@ public:
} else if (follow_fork_mode == "child") {
follow_child_radio_button->set_active (true);
}
+
+ bool is_on = true;
+ if (!conf_manager ().get_key_value (CONF_KEY_PRETTY_PRINTING,
+ is_on)) {
+ LOG_ERROR ("failed to get gconf key "
+ << CONF_KEY_PRETTY_PRINTING);
+ }
+ pretty_printing_check_button->set_active (is_on);
}
void update_widget_from_conf ()
diff --git a/src/persp/dbgperspective/ui/preferencesdialog.ui b/src/persp/dbgperspective/ui/preferencesdialog.ui
index 7c60e03..cc70286 100644
--- a/src/persp/dbgperspective/ui/preferencesdialog.ui
+++ b/src/persp/dbgperspective/ui/preferencesdialog.ui
@@ -602,7 +602,7 @@
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame11">
+ <object class="GtkFrame" id="frame8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
@@ -634,43 +634,42 @@
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame8">
+ <object class="GtkFrame" id="frame9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
- <object class="GtkAlignment" id="alignment9">
+ <object class="GtkAlignment" id="alignment10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkTable" id="table1">
+ <object class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
- <object class="GtkSpinButton" id="defaultnumasmspin">
+ <object class="GtkFileChooserButton" id="pathtogdbfilechooser">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="climb_rate">1</property>
- <property name="numeric">True</property>
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Choose a file</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="y_options"></property>
+ <property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label14">
+ <object class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Number of instructions to disassemble by default</property>
+ <property name="label" translatable="yes">Path to the GDB binary used</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@@ -682,10 +681,10 @@
</object>
</child>
<child type="label">
- <object class="GtkLabel" id="label13">
+ <object class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes"><b>Instructions</b></property>
+ <property name="label" translatable="yes"><b>GDB binary</b></property>
<property name="use_markup">True</property>
</object>
</child>
@@ -697,42 +696,43 @@
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame9">
+ <object class="GtkFrame" id="frame12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
- <object class="GtkAlignment" id="alignment10">
+ <object class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkTable" id="table2">
+ <object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
- <object class="GtkFileChooserButton" id="pathtogdbfilechooser">
+ <object class="GtkSpinButton" id="defaultnumasmspin">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="title" translatable="yes">Choose a file</property>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="y_options"></property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="label16">
+ <object class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Path to the GDB binary used</property>
+ <property name="label" translatable="yes">Number of instructions to disassemble by default</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@@ -744,18 +744,58 @@
</object>
</child>
<child type="label">
- <object class="GtkLabel" id="label15">
+ <object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes"><b>GDB binary</b></property>
+ <property name="label" translatable="yes"><b>Instructions</b></property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">3</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment12">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkCheckButton" id="prettyprintingcheckbutton">
+ <property name="label" translatable="yes">Enable pretty printing (requires debugger restart)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>GDB pretty printing</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -821,8 +861,8 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
@@ -832,7 +872,7 @@
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label11">
+ <object class="GtkLabel" id="label19">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Debugger</property>
@@ -845,8 +885,8 @@
<child>
<object class="GtkVBox" id="layoutbox">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="border_width">6</property>
- <property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
@@ -856,8 +896,9 @@
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label19">
+ <object class="GtkLabel" id="label20">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="label" translatable="yes">Layout</property>
</object>
<packing>
diff --git a/tests/test-vars.cc b/tests/test-vars.cc
index d3db5fa..b33fbc7 100644
--- a/tests/test-vars.cc
+++ b/tests/test-vars.cc
@@ -157,7 +157,7 @@ on_changed_variables_listed_signal
int nb_elems = a_vars.size ();
// We can't know for sure how many elemens got changed, as that
// depend on the version of stl we are testing against.
- BOOST_REQUIRE (nb_elems >= 3);
+ BOOST_REQUIRE (nb_elems >= 2);
MESSAGE ("The changed members are: ");
for (list<IDebugger::VariableSafePtr>::const_iterator it = a_vars.begin ();
it != a_vars.end ();
@@ -279,7 +279,7 @@ test_main (int, char **)
debugger->set_breakpoint ("func4");
// Set a breakpoint right after the person variable members get
// modified
- debugger->set_breakpoint ("fooprog.cc", 98);
+ debugger->set_breakpoint ("fooprog.cc", 105);
debugger->run ();
//****************************************
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]