Nemiver  0.3
nmv-debugger-utils.h
Go to the documentation of this file.
1 // Author: Dodji Seketeli
2 /*
3  *This file is part of the Nemiver project
4  *
5  *Nemiver is free software; you can redistribute
6  *it and/or modify it under the terms of
7  *the GNU General Public License as published by the
8  *Free Software Foundation; either version 2,
9  *or (at your option) any later version.
10  *
11  *Nemiver is distributed in the hope that it will
12  *be useful, but WITHOUT ANY WARRANTY;
13  *without even the implied warranty of
14  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *See the GNU General Public License for more details.
16  *
17  *You should have received a copy of the
18  *GNU General Public License along with Nemiver;
19  *see the file COPYING.
20  *If not, write to the Free Software Foundation,
21  *Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  *See COPYRIGHT file copyright information.
24  */
25 
26 #ifndef __NMV_DEBUGGER_UTILS_H__
27 #define __NMV_DEBUGGER_UTILS_H__
28 
29 #include <sstream>
30 #include "nmv-i-debugger.h"
31 
32 NEMIVER_BEGIN_NAMESPACE (nemiver)
33 NEMIVER_BEGIN_NAMESPACE (debugger_utils)
34 
38 void null_const_variable_slot (const IDebugger::VariableSafePtr &);
39 
40 void null_const_variable_list_slot (const IDebugger::VariableList &);
41 
42 void null_const_ustring_slot (const UString &);
43 
44 void null_frame_vector_slot (const vector<IDebugger::Frame> &);
45 
46 void null_frame_args_slot (const map<int, IDebugger::VariableList> &);
47 
48 void null_default_slot ();
49 
51  const std::list<common::Asm> &);
52 
53 void null_breakpoints_slot (const map<string, IDebugger::Breakpoint>&);
54 
56 
57 void gen_white_spaces (int a_nb_ws,
58  std::string &a_ws_str);
59 
60 template<class ostream_type>
61 void dump_variable_value (const IDebugger::Variable& a_var,
62  int a_indent_num,
63  ostream_type &a_os,
64  bool a_print_var_name);
65 
66 void dump_variable_value (const IDebugger::Variable& a_var,
67  int a_indent_num,
68  std::string &a_out_str);
69 
70 void dump_variable_value (const IDebugger::Variable& a_var);
71 
72 template<class ostream_type>
73 ostream_type&
74 operator<< (ostream_type &a_out, const IDebugger::Variable &a_var);
75 
77 
78 IDebugger::Variable::Format string_to_variable_format (const std::string &);
79 
80 std::string variable_format_to_string (IDebugger::Variable::Format);
81 
83 
84 // Template implementations.
85 
86 template<class ostream_type>
87 void
88 dump_variable_value (const IDebugger::Variable &a_var,
89  int a_indent_num,
90  ostream_type &a_os,
91  bool a_print_var_name)
92 {
93  LOG_FUNCTION_SCOPE_NORMAL_DD;
94 
95  std::string ws_string;
96 
97  if (a_indent_num)
98  gen_white_spaces (a_indent_num, ws_string);
99 
100  if (a_print_var_name)
101  a_os << ws_string << a_var.name ();
102 
103  if (!a_var.members ().empty ()) {
104  a_os << "\n" << ws_string << "{";
105  IDebugger::VariableList::const_iterator it;
106  for (it = a_var.members ().begin ();
107  it != a_var.members ().end ();
108  ++it) {
109  a_os << "\n";
110  dump_variable_value (**it, a_indent_num + 2, a_os, true);
111  }
112  a_os << "\n" << ws_string << "}";
113  } else {
114  if (a_print_var_name)
115  a_os << " = ";
116  a_os << a_var.value ();
117  }
118 }
119 
120 template<class ostream_type>
121 ostream_type&
122 operator<< (ostream_type &a_out, const IDebugger::Variable &a_var)
123 {
124  dump_variable_value (a_var, 4, a_out, /*print_var_name*/true);
125  return a_out;
126 }
127 
128 NEMIVER_END_NAMESPACE (debugger_utils)
129 NEMIVER_END_NAMESPACE (nemiver)
130 
131 #endif // __NMV_DEBUGGER_UTILS_H__
132 
nemiver::common::DisassembleInfo
Definition: nmv-asm-instr.h:201
nemiver::debugger_utils::null_default_slot
void null_default_slot()
nemiver
Definition: nmv-address.h:31
nemiver::common::Asm
Definition: nmv-asm-instr.h:127
nemiver::debugger_utils::operator<<
ostream_type & operator<<(ostream_type &a_out, const IDebugger::Variable &a_var)
Definition: nmv-debugger-utils.h:122
nemiver::debugger_utils::null_const_ustring_slot
void null_const_ustring_slot(const UString &)
nemiver::debugger_utils::null_disass_slot
void null_disass_slot(const common::DisassembleInfo &, const std::list< common::Asm > &)
nemiver::common::UString
Definition: nmv-ustring.h:45
nemiver::debugger_utils::dump_variable_value
void dump_variable_value(const IDebugger::Variable &a_var)
nemiver::debugger_utils::null_const_variable_list_slot
void null_const_variable_list_slot(const IDebugger::VariableList &)
nemiver::debugger_utils::variable_format_to_string
std::string variable_format_to_string(IDebugger::Variable::Format)
nemiver::debugger_utils::load_debugger_iface_with_confmgr
IDebuggerSafePtr load_debugger_iface_with_confmgr()
nemiver::debugger_utils::null_breakpoints_slot
void null_breakpoints_slot(const map< string, IDebugger::Breakpoint > &)
nemiver::IDebugger::Variable
Definition: nmv-i-debugger.h:465
nemiver::debugger_utils::null_frame_vector_slot
void null_frame_vector_slot(const vector< IDebugger::Frame > &)
nemiver::IDebugger
a debugger engine.
Definition: nmv-i-debugger.h:74
nmv-i-debugger.h
nemiver::debugger_utils::gen_white_spaces
void gen_white_spaces(int a_nb_ws, std::string &a_ws_str)
nemiver::debugger_utils::null_const_variable_slot
void null_const_variable_slot(const IDebugger::VariableSafePtr &)
nemiver::debugger_utils::null_frame_args_slot
void null_frame_args_slot(const map< int, IDebugger::VariableList > &)
nemiver::common::SafePtr
Definition: nmv-safe-ptr.h:71
nemiver::debugger_utils::load_debugger_iface_with_gconf
IDebuggerSafePtr load_debugger_iface_with_gconf()
common
Definition: nmv-proc-list-dialog.h:32
nemiver::debugger_utils::string_to_variable_format
IDebugger::Variable::Format string_to_variable_format(const std::string &)