[nemiver] Add debugger utilities to dump variable values
- From: Dodji Seketeli <dodji src gnome org>
- To: svn-commits-list gnome org
- Subject: [nemiver] Add debugger utilities to dump variable values
- Date: Tue, 2 Jun 2009 17:03:34 -0400 (EDT)
commit e2c45db067ee23284883f654ba4b2a9df05ff091
Author: Dodji Seketeli <dodji redhat com>
Date: Tue Jun 2 21:36:13 2009 +0200
Add debugger utilities to dump variable values
* src/dbgengine/nmv-debugger-utils.cc,h:
(gen_white_spaces, dump_variable_value): New functions.
* src/dbgengine/Makefile.am: Add nmv-debugger-utils.cc,h to the build
system. It's build into a static library, libdebuggerutils.la.
---
src/dbgengine/Makefile.am | 7 +++
src/dbgengine/nmv-debugger-utils.cc | 89 +++++++++++++++++++++++++++++++++++
src/dbgengine/nmv-debugger-utils.h | 48 +++++++++++++++++++
3 files changed, 144 insertions(+), 0 deletions(-)
diff --git a/src/dbgengine/Makefile.am b/src/dbgengine/Makefile.am
index 06050d1..c4e73cd 100644
--- a/src/dbgengine/Makefile.am
+++ b/src/dbgengine/Makefile.am
@@ -19,6 +19,7 @@ cpptraitmoddir= NEMIVER_MODULES_DIR@
noinst_LTLIBRARIES=\
libgdbmiparser.la \
libdbgcommon.la \
+libdebuggerutils.la \
libgdbengine.la
idebuggerheaders= \
@@ -76,6 +77,12 @@ nmv-dbg-common.h
libdbgcommon_la_CFLAGS=-fPIC -DPIC
+libdebuggerutils_la_SOURCES= \
+nmv-debugger-utils.h \
+nmv-debugger-utils.cc
+
+libdebuggerutils_la_CFLAGS=-fPIC -DPIC
+
libgdbengine_la_SOURCES= \
nmv-gdb-engine.cc \
nmv-gdb-engine.h
diff --git a/src/dbgengine/nmv-debugger-utils.cc b/src/dbgengine/nmv-debugger-utils.cc
new file mode 100644
index 0000000..5970a76
--- /dev/null
+++ b/src/dbgengine/nmv-debugger-utils.cc
@@ -0,0 +1,89 @@
+// Author: Dodji Seketeli
+/*
+ *This file is part of the Nemiver project
+ *
+ *Nemiver is free software; you can redistribute
+ *it and/or modify it under the terms of
+ *the GNU General Public License as published by the
+ *Free Software Foundation; either version 2,
+ *or (at your option) any later version.
+ *
+ *Nemiver is distributed in the hope that it will
+ *be useful, but WITHOUT ANY WARRANTY;
+ *without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *See the GNU General Public License for more details.
+ *
+ *You should have received a copy of the
+ *GNU General Public License along with Nemiver;
+ *see the file COPYING.
+ *If not, write to the Free Software Foundation,
+ *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *See COPYRIGHT file copyright information.
+ */
+
+#include "nmv-debugger-utils.h"
+#include "common/nmv-exception.h"
+
+NEMIVER_BEGIN_NAMESPACE (nemiver)
+NEMIVER_BEGIN_NAMESPACE (debugger_utils)
+
+void
+gen_white_spaces (int a_nb_ws,
+ std::string &a_ws_str)
+{
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+ for (int i = 0; i < a_nb_ws; i++) {
+ a_ws_str += ' ';
+ }
+}
+
+void
+dump_variable_value (IDebugger::VariableSafePtr a_var,
+ int a_indent_num,
+ std::ostringstream &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 ();
+ }
+}
+
+void
+dump_variable_value (IDebugger::VariableSafePtr a_var,
+ int a_indent_num,
+ std::string &a_out_str)
+{
+ std::ostringstream os;
+ dump_variable_value (a_var, a_indent_num, os);
+ a_out_str = os.str ();
+}
+
+NEMIVER_END_NAMESPACE (debugger_utils)
+NEMIVER_END_NAMESPACE (nemiver)
diff --git a/src/dbgengine/nmv-debugger-utils.h b/src/dbgengine/nmv-debugger-utils.h
new file mode 100644
index 0000000..125368c
--- /dev/null
+++ b/src/dbgengine/nmv-debugger-utils.h
@@ -0,0 +1,48 @@
+// Author: Dodji Seketeli
+/*
+ *This file is part of the Nemiver project
+ *
+ *Nemiver is free software; you can redistribute
+ *it and/or modify it under the terms of
+ *the GNU General Public License as published by the
+ *Free Software Foundation; either version 2,
+ *or (at your option) any later version.
+ *
+ *Nemiver is distributed in the hope that it will
+ *be useful, but WITHOUT ANY WARRANTY;
+ *without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *See the GNU General Public License for more details.
+ *
+ *You should have received a copy of the
+ *GNU General Public License along with Nemiver;
+ *see the file COPYING.
+ *If not, write to the Free Software Foundation,
+ *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *See COPYRIGHT file copyright information.
+ */
+
+#ifndef __NMV_DEBUGGER_UTILS_H__
+#define __NMV_DEBUGGER_UTILS_H__
+
+#include <sstream>
+#include "nmv-i-debugger.h"
+
+NEMIVER_BEGIN_NAMESPACE (nemiver)
+NEMIVER_BEGIN_NAMESPACE (debugger_utils)
+
+void dump_variable_value (IDebugger::VariableSafePtr a_var,
+ int a_indent_num,
+ std::ostringstream &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);
+
+NEMIVER_END_NAMESPACE (debugger_utils)
+NEMIVER_END_NAMESPACE (nemiver)
+
+#endif // __NMV_DEBUGGER_UTILS_H__
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]