[nemiver/monitor-variable: 2/6] Add logging for variables in the monitor
- From: Dodji Seketeli <dodji src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver/monitor-variable: 2/6] Add logging for variables in the monitor
- Date: Mon, 28 May 2012 21:58:19 +0000 (UTC)
commit aece498a084843a7555548ac7954f091f7d85dee
Author: Dodji Seketeli <dodji seketeli org>
Date: Mon Mar 26 17:48:11 2012 +0200
Add logging for variables in the monitor
* src/dbgengine/nmv-debugger-utils.cc (dump_variable_value): Move
the core overload of this to nmv-debugger-utils.h, transform it
into a template. Change all overloads to take a const
IDebugger::Variable& instead of a pointer to variable. Adjust
them as necessary.
* src/dbgengine/nmv-debugger-utils.h (dump_variable_value): Move
the core overload in here, transform it into a template with a
generic output stream.
(operator<<): New streaming operator for IDebugger::Variable over
generic streams.
* src/dbgengine/nmv-i-debugger.h (IDebugger::Variable): Make the
constructor be explicit to avoid unexpected conversion during
stream operations.
* src/persp/dbgperspective/nmv-local-vars-inspector.cc
(LocalVarsInspector::Priv::on_visited_variable_signal): Adjust
use of dump_variable_value.
* src/persp/dbgperspective/nmv-var-inspector.cc
(VarInspector::Priv::on_visited_variable_signal): Likewise.
* src/persp/dbgperspective/nmv-variables-utils.cc
(update_a_variable_node): Log the name and content of the variable
we have changed.
* src/persp/dbgperspective/nmv-vars-monitor.cc
(VarsMonitor::Priv::update_vars_changed_at_prev_step): Add
logging.
(VarsMonitor::Priv::on_vars_changed): Log the content of the
variable we are about to update.
src/dbgengine/nmv-debugger-utils.cc | 48 +--------------
src/dbgengine/nmv-debugger-utils.h | 62 ++++++++++++++++++--
src/dbgengine/nmv-i-debugger.h | 24 ++++----
.../dbgperspective/nmv-local-vars-inspector.cc | 2 +-
src/persp/dbgperspective/nmv-var-inspector.cc | 2 +-
src/persp/dbgperspective/nmv-variables-utils.cc | 7 ++-
src/persp/dbgperspective/nmv-vars-monitor.cc | 6 ++
7 files changed, 86 insertions(+), 65 deletions(-)
---
diff --git a/src/dbgengine/nmv-debugger-utils.cc b/src/dbgengine/nmv-debugger-utils.cc
index 611a4c4..c3b1ad0 100644
--- a/src/dbgengine/nmv-debugger-utils.cc
+++ b/src/dbgengine/nmv-debugger-utils.cc
@@ -90,48 +90,6 @@ gen_white_spaces (int a_nb_ws,
}
}
-/// Serialize a variable and its value into an output stream.
-///
-/// \param a_var the variable to serialize.
-/// \param a_indent_num the number of spaces to indent to before
-/// serializing the variable.
-/// \param a_os the output stream to serialize into.
-/// \param a_print_var_name if true, serialize the variable name too.
-void
-dump_variable_value (IDebugger::VariableSafePtr a_var,
- int a_indent_num,
- std::ostream &a_os,
- bool a_print_var_name)
-{
- LOG_FUNCTION_SCOPE_NORMAL_DD;
-
- THROW_IF_FAIL (a_var);
-
- std::string ws_string;
-
- if (a_indent_num)
- gen_white_spaces (a_indent_num, ws_string);
-
- if (a_print_var_name)
- a_os << ws_string << a_var->name ();
-
- if (!a_var->members ().empty ()) {
- a_os << "\n" << ws_string << "{";
- IDebugger::VariableList::const_iterator it;
- for (it = a_var->members ().begin ();
- it != a_var->members ().end ();
- ++it) {
- a_os << "\n";
- dump_variable_value (*it, a_indent_num + 2, a_os, true);
- }
- a_os << "\n" << ws_string << "}";
- } else {
- if (a_print_var_name)
- a_os << " = ";
- a_os << a_var->value ();
- }
-}
-
/// Serialize a variable and its value into a string.
///
/// \param a_var the variable to serialize.
@@ -139,12 +97,12 @@ dump_variable_value (IDebugger::VariableSafePtr a_var,
/// serializing the variable.
/// \param a_out_str the string to serialize the variable into.
void
-dump_variable_value (IDebugger::VariableSafePtr a_var,
+dump_variable_value (const IDebugger::Variable &a_var,
int a_indent_num,
std::string &a_out_str)
{
std::ostringstream os;
- dump_variable_value (a_var, a_indent_num, os);
+ dump_variable_value (a_var, a_indent_num, os, /*print_var_name=*/false);
a_out_str = os.str ();
}
@@ -153,7 +111,7 @@ dump_variable_value (IDebugger::VariableSafePtr a_var,
///
/// \param a_var the variable to serialize.
void
-dump_variable_value (IDebugger::VariableSafePtr a_var)
+dump_variable_value (const IDebugger::Variable &a_var)
{
dump_variable_value (a_var, 4, std::cerr,
/*print_var_name=*/true);
diff --git a/src/dbgengine/nmv-debugger-utils.h b/src/dbgengine/nmv-debugger-utils.h
index a9647d1..ca21063 100644
--- a/src/dbgengine/nmv-debugger-utils.h
+++ b/src/dbgengine/nmv-debugger-utils.h
@@ -54,16 +54,24 @@ void null_breakpoints_slot (const map<int, IDebugger::Breakpoint>&);
/// @}
-void dump_variable_value (IDebugger::VariableSafePtr a_var,
+void gen_white_spaces (int a_nb_ws,
+ std::string &a_ws_str);
+
+template<class ostream_type>
+void dump_variable_value (const IDebugger::Variable& a_var,
int a_indent_num,
- std::ostream &a_os,
- bool a_print_var_name = false);
+ ostream_type &a_os,
+ bool a_print_var_name);
-void dump_variable_value (IDebugger::VariableSafePtr a_var,
+void dump_variable_value (IDebugger::Variable& a_var,
int a_indent_num,
std::string &a_out_str);
-void dump_variable_value (IDebugger::VariableSafePtr a_var);
+void dump_variable_value (IDebugger::Variable& a_var);
+
+template<class ostream_type>
+ostream_type&
+operator<< (ostream_type &a_out, const IDebugger::Variable &a_var);
IDebuggerSafePtr load_debugger_iface_with_confmgr ();
@@ -73,6 +81,50 @@ std::string variable_format_to_string (IDebugger::Variable::Format);
IDebuggerSafePtr load_debugger_iface_with_gconf ();
+// Template implementations.
+
+template<class ostream_type>
+void
+dump_variable_value (const IDebugger::Variable &a_var,
+ int a_indent_num,
+ ostream_type &a_os,
+ bool a_print_var_name)
+{
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+ std::string ws_string;
+
+ if (a_indent_num)
+ gen_white_spaces (a_indent_num, ws_string);
+
+ if (a_print_var_name)
+ a_os << ws_string << a_var.name ();
+
+ if (!a_var.members ().empty ()) {
+ a_os << "\n" << ws_string << "{";
+ IDebugger::VariableList::const_iterator it;
+ for (it = a_var.members ().begin ();
+ it != a_var.members ().end ();
+ ++it) {
+ a_os << "\n";
+ dump_variable_value (**it, a_indent_num + 2, a_os, true);
+ }
+ a_os << "\n" << ws_string << "}";
+ } else {
+ if (a_print_var_name)
+ a_os << " = ";
+ a_os << a_var.value ();
+ }
+}
+
+template<class ostream_type>
+ostream_type&
+operator<< (ostream_type &a_out, const IDebugger::Variable &a_var)
+{
+ dump_variable_value (a_var, 4, a_out, /*print_var_name*/true);
+ return a_out;
+}
+
NEMIVER_END_NAMESPACE (debugger_utils)
NEMIVER_END_NAMESPACE (nemiver)
diff --git a/src/dbgengine/nmv-i-debugger.h b/src/dbgengine/nmv-i-debugger.h
index b0a32fa..149b82e 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -431,12 +431,12 @@ public:
bool m_has_more_children;
public:
- Variable (const UString &a_internal_name,
- const UString &a_name,
- const UString &a_value,
- const UString &a_type,
- bool a_in_scope = true,
- IDebugger *a_dbg = 0)
+ explicit Variable (const UString &a_internal_name,
+ const UString &a_name,
+ const UString &a_value,
+ const UString &a_type,
+ bool a_in_scope = true,
+ IDebugger *a_dbg = 0)
: m_internal_name (a_internal_name),
m_debugger (a_dbg),
m_name (a_name),
@@ -452,10 +452,10 @@ public:
{
}
- Variable (const UString &a_name,
- const UString &a_value,
- const UString &a_type,
- bool a_in_scope = true,
+ explicit Variable (const UString &a_name,
+ const UString &a_value,
+ const UString &a_type,
+ bool a_in_scope = true,
IDebugger *a_dbg = 0)
: m_debugger (a_dbg),
m_name (a_name),
@@ -472,8 +472,8 @@ public:
{
}
- Variable (const UString &a_name,
- IDebugger *a_dbg = 0)
+ explicit Variable (const UString &a_name,
+ IDebugger *a_dbg = 0)
: m_debugger (a_dbg),
m_name (a_name),
m_parent (0),
diff --git a/src/persp/dbgperspective/nmv-local-vars-inspector.cc b/src/persp/dbgperspective/nmv-local-vars-inspector.cc
index 2a995df..a7018d1 100644
--- a/src/persp/dbgperspective/nmv-local-vars-inspector.cc
+++ b/src/persp/dbgperspective/nmv-local-vars-inspector.cc
@@ -976,7 +976,7 @@ public:
NEMIVER_TRY
std::string str;
- dutil::dump_variable_value (a_var, 0, str);
+ dutil::dump_variable_value (*a_var, 0, str);
if (!str.empty ())
Gtk::Clipboard::get ()->set_text (str);
diff --git a/src/persp/dbgperspective/nmv-var-inspector.cc b/src/persp/dbgperspective/nmv-var-inspector.cc
index 4e5e740..db178e7 100644
--- a/src/persp/dbgperspective/nmv-var-inspector.cc
+++ b/src/persp/dbgperspective/nmv-var-inspector.cc
@@ -388,7 +388,7 @@ class VarInspector::Priv : public sigc::trackable {
NEMIVER_TRY
std::string str;
- dutil::dump_variable_value (a_var, 0, str);
+ dutil::dump_variable_value (*a_var, 0, str);
if (!str.empty ())
Gtk::Clipboard::get ()->set_text (str);
diff --git a/src/persp/dbgperspective/nmv-variables-utils.cc b/src/persp/dbgperspective/nmv-variables-utils.cc
index c747bc9..4804485 100644
--- a/src/persp/dbgperspective/nmv-variables-utils.cc
+++ b/src/persp/dbgperspective/nmv-variables-utils.cc
@@ -170,9 +170,12 @@ update_a_variable_node (const IDebugger::VariableSafePtr a_var,
(Glib::ustring)(*a_iter)[get_variable_columns ().name];
LOG_DD ("Prev variable name: " << prev_var_name);
LOG_DD ("new variable name: " << var_name);
- LOG_DD ("Didn't update variable name");
+
if (prev_var_name.raw () == "") {
(*a_iter)[get_variable_columns ().name] = var_name;
+ LOG_DD ("Updated variable name");
+ } else {
+ LOG_DD ("Didn't update variable name");
}
(*a_iter) [get_variable_columns ().is_highlighted] = false;
bool do_highlight = false;
@@ -202,7 +205,9 @@ update_a_variable_node (const IDebugger::VariableSafePtr a_var,
}
(*a_iter)[get_variable_columns ().value] = a_var->value ();
+ LOG_DD ("Updated variable value to " << a_var->value ());
set_a_variable_node_type (a_iter, a_var->type (), a_truncate_type);
+ LOG_DD ("Updated variable type to " << a_var->type ());
}
diff --git a/src/persp/dbgperspective/nmv-vars-monitor.cc b/src/persp/dbgperspective/nmv-vars-monitor.cc
index 06eb469..d06e524 100644
--- a/src/persp/dbgperspective/nmv-vars-monitor.cc
+++ b/src/persp/dbgperspective/nmv-vars-monitor.cc
@@ -29,9 +29,13 @@
#include "common/nmv-exception.h"
#include "nmv-vars-treeview.h"
#include "nmv-variables-utils.h"
+#include "nmv-debugger-utils.h"
using namespace nemiver::common;
namespace vutils = nemiver::variables_utils2;
+namespace dutils = nemiver::debugger_utils;
+
+using namespace dutils;
NEMIVER_BEGIN_NAMESPACE (nemiver)
@@ -322,6 +326,7 @@ struct VarsMonitor::Priv
void
update_vars_changed_at_prev_step ()
{
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
Gtk::TreeModel::iterator in_scope_vars_it, oo_scope_vars_it;
@@ -458,6 +463,7 @@ struct VarsMonitor::Priv
// representation.
IDebugger::VariableList::const_iterator v = a_sub_vars.begin ();
for (; v != a_sub_vars.end (); ++v) {
+ LOG_DD ("Going to update variable " << (*v)->id () << ":" << **v);
vutils::update_a_variable (*v, *tree_view,
parent_it,
/*a_truncate_type=*/false,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]