[PATCH 2/3] Dump variable value to stderr



Hello,

While hacking on Nemiver lately, I have felt the need to add a new
dump_variable_value function that would serialize an instance of
IDebugger::Variable out to stderr for debugging purposes.

Tested and applying this to master.

	* src/dbgengine/nmv-debugger-utils.h (dump_variable_value):
	Declare new overload.  Make the existing overload take an
	std::ostream instead of an std::ostringstream.
	* src/dbgengine/nmv-debugger-utils.cc (dump_variable_value):
	Define new overload.  Make the existing overload take an
	std::ostream instead of an std::ostringstream.
---
 src/dbgengine/nmv-debugger-utils.cc |   16 ++++++++++++++--
 src/dbgengine/nmv-debugger-utils.h  |    4 +++-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/dbgengine/nmv-debugger-utils.cc b/src/dbgengine/nmv-debugger-utils.cc
index 7a0bc4f..cbc2a79 100644
--- a/src/dbgengine/nmv-debugger-utils.cc
+++ b/src/dbgengine/nmv-debugger-utils.cc
@@ -22,7 +22,6 @@
  *
  *See COPYRIGHT file copyright information.
  */
-
 #include "nmv-debugger-utils.h"
 #include "common/nmv-exception.h"
 
@@ -91,6 +90,7 @@ 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.
@@ -99,7 +99,7 @@ gen_white_spaces (int a_nb_ws,
 void
 dump_variable_value (IDebugger::VariableSafePtr a_var,
                      int a_indent_num,
-                     std::ostringstream &a_os,
+                     std::ostream &a_os,
                      bool a_print_var_name)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
@@ -132,6 +132,7 @@ dump_variable_value (IDebugger::VariableSafePtr a_var,
 }
 
 /// Serialize a variable and its value into a string.
+///
 /// \param a_var the variable to serialize.
 /// \param a_indent_num the number of spaces to indent to before
 /// serializing the variable.
@@ -146,6 +147,17 @@ dump_variable_value (IDebugger::VariableSafePtr a_var,
     a_out_str = os.str ();
 }
 
+/// Serialize a variable and its value out to the standard error
+/// output stream.
+///
+/// \param a_var the variable to serialize.
+void
+dump_variable_value (IDebugger::VariableSafePtr a_var)
+{
+    dump_variable_value (a_var, 4, std::cerr,
+                         /*print_var_name=*/true);
+}
+
 /// Load the debugger interface using the default
 /// DynamicModuleManager, and initialize it with the configuration
 /// manager.
diff --git a/src/dbgengine/nmv-debugger-utils.h b/src/dbgengine/nmv-debugger-utils.h
index 01aa9e5..a9647d1 100644
--- a/src/dbgengine/nmv-debugger-utils.h
+++ b/src/dbgengine/nmv-debugger-utils.h
@@ -56,13 +56,15 @@ void null_breakpoints_slot (const map<int, IDebugger::Breakpoint>&);
 
 void dump_variable_value (IDebugger::VariableSafePtr a_var,
                           int a_indent_num,
-                          std::ostringstream &a_os,
+                          std::ostream &a_os,
                           bool a_print_var_name = false);
 
 void dump_variable_value (IDebugger::VariableSafePtr a_var,
                           int a_indent_num,
                           std::string &a_out_str);
 
+void dump_variable_value (IDebugger::VariableSafePtr a_var);
+
 IDebuggerSafePtr load_debugger_iface_with_confmgr ();
 
 IDebugger::Variable::Format string_to_variable_format (const std::string &);
-- 
1.7.6.4


-- 
		Dodji


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