[nemiver] Allow compound variable detection
- From: Dodji Seketeli <dodji src gnome org>
- To: svn-commits-list gnome org
- Subject: [nemiver] Allow compound variable detection
- Date: Tue, 2 Jun 2009 17:03:39 -0400 (EDT)
commit 5600f6d5e5c526598547c6f8df8148535ef3a5e7
Author: Dodji Seketeli <dodji redhat com>
Date: Tue Jun 2 21:38:03 2009 +0200
Allow compound variable detection
* src/dbgengine/nmv-i-lang-trait.h (ILangTrait::is_variable_compound):
New abstract interface.
* src/dbgengine/nmv-cpp-trait.cc:
(CPPTrait::is_variable_compound): New iface implementation.
* src/dbgengine/nmv-i-debugger.h:
(IDebugger::get_language_trait): Return a reference, not a pointer.
* src/dbgengine/nmv-gdb-engine.cc (GDBEngine::get_language_trait,
GDBEngine::dereference_variable): Adjust.
* tests/test-cpptrait.cc (test_debugger): Adjust use of
IDebugger::get_language_trait.
* tests/test-deref.cc (on_variable_type_set_signal): Likewise.
---
src/dbgengine/nmv-cpp-trait.cc | 11 +++++++++++
src/dbgengine/nmv-gdb-engine.cc | 13 +++++++------
src/dbgengine/nmv-gdb-engine.h | 3 ++-
src/dbgengine/nmv-i-debugger.h | 4 ++--
src/dbgengine/nmv-i-lang-trait.h | 3 +++
tests/test-cpptrait.cc | 9 +++------
tests/test-deref.cc | 9 +++++----
7 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/src/dbgengine/nmv-cpp-trait.cc b/src/dbgengine/nmv-cpp-trait.cc
index b656d2e..771c3d3 100644
--- a/src/dbgengine/nmv-cpp-trait.cc
+++ b/src/dbgengine/nmv-cpp-trait.cc
@@ -46,6 +46,7 @@ public:
const UString& get_name () const ;
bool has_pointers () const ;
bool is_type_a_pointer (const UString &a_type) const ;
+ bool is_variable_compound (const IDebugger::VariableSafePtr a_var) const ;
};//end class CPPTrait
CPPTrait::CPPTrait (DynamicModule *a_dynmod):
@@ -94,6 +95,16 @@ CPPTrait::is_type_a_pointer (const UString &a_type) const
return false ;
}
+bool
+CPPTrait::is_variable_compound (const IDebugger::VariableSafePtr a_var) const
+{
+ if (a_var
+ && (a_var->value () == "{...}"
+ || a_var->value ().empty ()))
+ return true;
+ return false;
+}
+
class CPPTraitModule : public DynamicModule {
public:
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 5471f36..4b2e82e 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -43,6 +43,7 @@
#include "nmv-gdb-engine.h"
#include "langs/nmv-cpp-parser.h"
#include "langs/nmv-cpp-ast-utils.h"
+#include "nmv-i-lang-trait.h"
using namespace std;
using namespace nemiver::common;
@@ -3143,7 +3144,7 @@ GDBEngine::create_language_trait ()
return trait;
}
-ILangTraitSafePtr
+ILangTrait&
GDBEngine::get_language_trait ()
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
@@ -3151,7 +3152,8 @@ GDBEngine::get_language_trait ()
if (!m_priv->lang_trait) {
m_priv->lang_trait = create_language_trait ();
}
- return m_priv->lang_trait;
+ THROW_IF_FAIL (m_priv->lang_trait);
+ return *m_priv->lang_trait;
}
/// Dectect if the variable should be editable or not.
@@ -3679,16 +3681,15 @@ GDBEngine::dereference_variable (const VariableSafePtr &a_var,
THROW_IF_FAIL (a_var);
THROW_IF_FAIL (!a_var->name ().empty ());
- ILangTraitSafePtr lang_trait = get_language_trait ();
- THROW_IF_FAIL (lang_trait);
+ ILangTrait &lang_trait = get_language_trait ();
- if (!lang_trait->has_pointers ()) {
+ if (!lang_trait.has_pointers ()) {
LOG_ERROR ("current language does not support pointers");
return false;
}
if (!a_var->type ().empty () &&
- !lang_trait->is_type_a_pointer (a_var->type ())) {
+ !lang_trait.is_type_a_pointer (a_var->type ())) {
LOG_ERROR ("The variable you want to dereference is not a pointer:"
"name: " << a_var->name ()
<< ":type: " << a_var->type ());
diff --git a/src/dbgengine/nmv-gdb-engine.h b/src/dbgengine/nmv-gdb-engine.h
index 64c56d7..a5a1c6b 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -27,6 +27,7 @@
#include "nmv-dbg-common.h"
#include "nmv-gdbmi-parser.h"
+#include "nmv-i-lang-trait.h"
NEMIVER_BEGIN_NAMESPACE (nemiver)
@@ -279,7 +280,7 @@ public:
ILangTraitSafePtr create_language_trait () ;
- ILangTraitSafePtr get_language_trait () ;
+ ILangTrait& get_language_trait () ;
bool is_variable_editable (const VariableSafePtr) const;
diff --git a/src/dbgengine/nmv-i-debugger.h b/src/dbgengine/nmv-i-debugger.h
index dd1ebdf..f2b2818 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -36,7 +36,6 @@
#include "common/nmv-dynamic-module.h"
#include "common/nmv-safe-ptr-utils.h"
#include "nmv-i-conf-mgr.h"
-#include "nmv-i-lang-trait.h"
NEMIVER_BEGIN_NAMESPACE (nemiver)
@@ -53,6 +52,7 @@ using std::string;
using std::map;
using std::list;
+class ILangTrait;
class IDebugger;
typedef SafePtr<IDebugger, ObjectRef, ObjectUnref> IDebuggerSafePtr;
@@ -988,7 +988,7 @@ public:
virtual void get_target_info (const UString &a_cookie="") = 0;
- virtual ILangTraitSafePtr get_language_trait () = 0;
+ virtual ILangTrait& get_language_trait () = 0;
virtual bool is_variable_editable (const VariableSafePtr a_var) const = 0;
diff --git a/src/dbgengine/nmv-i-lang-trait.h b/src/dbgengine/nmv-i-lang-trait.h
index 69baaa7..d0ad0f4 100644
--- a/src/dbgengine/nmv-i-lang-trait.h
+++ b/src/dbgengine/nmv-i-lang-trait.h
@@ -27,6 +27,7 @@
#include "common/nmv-ustring.h"
#include "common/nmv-dynamic-module.h"
+#include "nmv-i-debugger.h"
using nemiver::common::UString ;
using nemiver::common::DynModIface ;
@@ -64,6 +65,8 @@ public:
/// \name language features
/// @{
virtual bool is_type_a_pointer (const UString &a_type) const = 0 ;
+ virtual bool is_variable_compound
+ (const nemiver::IDebugger::VariableSafePtr) const = 0;
/// @}
};//end class ILangTrait
diff --git a/tests/test-cpptrait.cc b/tests/test-cpptrait.cc
index a7253de..083727d 100644
--- a/tests/test-cpptrait.cc
+++ b/tests/test-cpptrait.cc
@@ -48,18 +48,15 @@ void test_debugger ()
DynamicModuleManager::load_iface_with_default_manager<IDebugger>
("gdbengine", "IDebugger") ;
BOOST_REQUIRE (debugger) ;
- ILangTraitSafePtr trait = debugger->get_language_trait () ;
- BOOST_REQUIRE (trait) ;
- BOOST_REQUIRE (trait->get_name () == "cpptrait") ;
+ ILangTrait &trait = debugger->get_language_trait () ;
+ BOOST_REQUIRE (trait.get_name () == "cpptrait") ;
}
using boost::unit_test::test_suite ;
NEMIVER_API test_suite*
-init_unit_test_suite (int argc, char **argv)
+init_unit_test_suite (int, char **)
{
- if (argc || argv) {/*keep compiler happy*/}
-
NEMIVER_TRY
Initializer::do_init () ;
diff --git a/tests/test-deref.cc b/tests/test-deref.cc
index adabf2b..fecfc7b 100644
--- a/tests/test-deref.cc
+++ b/tests/test-deref.cc
@@ -2,6 +2,7 @@
#include <boost/test/minimal.hpp>
#include <glibmm.h>
#include "nmv-i-debugger.h"
+#include "nmv-i-lang-trait.h"
#include "common/nmv-initializer.h"
using namespace nemiver ;
@@ -81,10 +82,10 @@ on_variable_type_set_signal (const IDebugger::VariableSafePtr &a_var,
if (a_var->name () == "foo_ptr" ||
a_var->name () == "bar_ptr" ||
a_var->name () == "baz_ptr") {
- ILangTraitSafePtr lang_trait = a_debugger->get_language_trait () ;
- BOOST_REQUIRE (lang_trait->get_name () == "cpptrait") ;
- BOOST_REQUIRE (lang_trait->has_pointers ()) ;
- BOOST_REQUIRE (lang_trait->is_type_a_pointer (a_var->type ())) ;
+ ILangTrait &lang_trait = a_debugger->get_language_trait () ;
+ BOOST_REQUIRE (lang_trait.get_name () == "cpptrait") ;
+ BOOST_REQUIRE (lang_trait.has_pointers ()) ;
+ BOOST_REQUIRE (lang_trait.is_type_a_pointer (a_var->type ())) ;
a_debugger->dereference_variable (a_var) ;
} else {
UString msg = "Got variable name: "+ a_var->name ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]