[nemiver/varobjs-support] Don't quote arguments of ptype and -data-evaluate-expression



commit 957a332a9b605de64c5cbc9612bb4a8b0fe1e1dd
Author: Dodji Seketeli <dodji redhat com>
Date:   Fri Apr 3 14:21:33 2009 +0200

    Don't quote arguments of ptype and -data-evaluate-expression
    
    	* src/dbgengine/nmv-gdb-engine.cc (GDBEngine::evaluate_expression,
    	GDBEngine::print_variable_value, GDBEngine::get_variable_value,
    	GDBEngine::print_pointed_variable_value, GDBEngine::print_variable_type,
    	GDBEngine::get_variable_type, GDBEngine::dereference_variable,
    	GDBEngine::set_register_value): Do not quote the arguments of
    	-data-evaluate-expression and ptype because that changes the type of
    	the expression. See comments at
    	http://bugzilla.gnome.org/show_bug.cgi?id=574212.
    	* tests/test-types.cc: New regression test file to make sure we don't
    	sure we don't regress again here.
    	* tests/Makefile.am: Integrate test-types.cc
---
 src/dbgengine/nmv-gdb-engine.cc |   16 +++---
 tests/Makefile.am               |    7 ++-
 tests/test-types.cc             |  112 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 9 deletions(-)

diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 76f8466..e9eb033 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -3433,7 +3433,7 @@ GDBEngine::evaluate_expression (const UString &a_expr,
     if (a_expr == "") {return;}
 
     Command command ("evaluate-expression",
-                     "-data-evaluate-expression '" + a_expr + "'",
+                     "-data-evaluate-expression " + a_expr,
                      a_cookie);
     queue_command (command);
 }
@@ -3462,7 +3462,7 @@ GDBEngine::print_variable_value (const UString &a_var_name,
     }
 
     Command command ("print-variable-value",
-                     "-data-evaluate-expression '" + a_var_name + "'",
+                     "-data-evaluate-expression " + a_var_name,
                      a_cookie);
     command.tag0 ("print-variable-value");
     command.tag1 (a_var_name);
@@ -3482,7 +3482,7 @@ GDBEngine::get_variable_value (const VariableSafePtr &a_var,
     a_var->build_qname (qname);
 
     Command command ("get-variable-value",
-                     "-data-evaluate-expression '" + qname + "'",
+                     "-data-evaluate-expression " + qname,
                      a_cookie);
     command.variable (a_var);
 
@@ -3500,7 +3500,7 @@ GDBEngine::print_pointed_variable_value (const UString &a_var_name,
     }
 
     Command command ("print-pointed-variable-value",
-                     "-data-evaluate-expression *'" + a_var_name + "'",
+                     "-data-evaluate-expression *" + a_var_name,
                      a_cookie);
     command.tag0 ("print-pointed-variable-value");
     command.tag1 (a_var_name);
@@ -3516,7 +3516,7 @@ GDBEngine::print_variable_type (const UString &a_var_name,
     if (a_var_name == "") {return;}
 
     Command command ("print-variable-type",
-                     "ptype '" + a_var_name + "'",
+                     "ptype " + a_var_name,
                      a_cookie);
     command.tag0 ("print-variable-type");
     command.tag1 (a_var_name);
@@ -3537,7 +3537,7 @@ GDBEngine::get_variable_type (const VariableSafePtr &a_var,
     a_var->build_qname (qname);
     LOG_DD ("variable qname: " << qname);
     Command command ("get-variable-type",
-                     "ptype '" + qname + "'",
+                     "ptype " + qname,
                      a_cookie);
     command.variable (a_var);
 
@@ -3572,7 +3572,7 @@ GDBEngine::dereference_variable (const VariableSafePtr &a_var,
     a_var->build_qname (var_qname);
     THROW_IF_FAIL (!var_qname.empty ());
     Command command ("dereference-variable",
-                     "-data-evaluate-expression *'" + var_qname + "'",
+                     "-data-evaluate-expression *" + var_qname,
                      a_cookie);
     command.variable (a_var);
 
@@ -3875,7 +3875,7 @@ GDBEngine::set_register_value (const UString& a_reg_name,
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
     UString command_str;
-    command_str.printf ("-data-evaluate-expression '$%s=%s'",
+    command_str.printf ("-data-evaluate-expression $%s=%s",
             a_reg_name.c_str (),
             a_value.c_str ());
     Command command ("set-register-value",
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 14e44e4..4c8784a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -12,7 +12,7 @@ runtestderef \
 runtestlocalvarslist runtestcpplexer \
 runtestcppparser  \
 runtestlibtoolwrapperdetection \
-runtestenv
+runtestenv runtesttypes
 
 
 else
@@ -118,6 +118,11 @@ runtestenv_LDADD= NEMIVERCOMMON_LIBS@ \
 @BOOST_UNIT_TEST_FRAMEWORK_STATIC_LIB@ \
 $(top_builddir)/src/common/libnemivercommon.la
 
+runtesttypes_SOURCES=test-types.cc
+runtesttypes_LDADD= NEMIVERCOMMON_LIBS@ \
+ BOOST_UNIT_TEST_FRAMEWORK_STATIC_LIB@ \
+$(top_builddir)/src/common/libnemivercommon.la
+
 docore_SOURCES=do-core.cc
 docore_LDADD= NEMIVERCOMMON_LIBS@ \
 $(top_builddir)/src/common/libnemivercommon.la
diff --git a/tests/test-types.cc b/tests/test-types.cc
new file mode 100644
index 0000000..94bc91a
--- /dev/null
+++ b/tests/test-types.cc
@@ -0,0 +1,112 @@
+#include <iostream>
+#include <boost/test/minimal.hpp>
+#include <glibmm.h>
+#include "common/nmv-initializer.h"
+#include "common/nmv-safe-ptr-utils.h"
+#include "nmv-i-debugger.h"
+
+using namespace nemiver;
+using namespace nemiver::common;
+
+Glib::RefPtr<Glib::MainLoop> loop =
+    Glib::MainLoop::create (Glib::MainContext::get_default ()) ;
+
+void
+on_engine_died_signal ()
+{
+    MESSAGE ("engine died") ;
+    loop->quit () ;
+}
+
+void
+on_program_finished_signal ()
+{
+    MESSAGE ("program finished") ;
+    loop->quit () ;
+}
+
+void
+on_variable_type_signal (const UString &a_variable_name,
+                         const UString &a_variable_type,
+                         const UString &/*a_cookie*/)
+{
+    MESSAGE ("variable name is: " << a_variable_name);
+    BOOST_REQUIRE (a_variable_name == "i");
+    MESSAGE ("the type of variable is: " << a_variable_type);
+    BOOST_REQUIRE (a_variable_type == "int");
+}
+
+void
+on_variable_value_signal (const UString &a_variable_name,
+                          const IDebugger::VariableSafePtr a_var,
+                          const UString&)
+{
+    MESSAGE ("name of variable is: " << a_variable_name);
+    BOOST_REQUIRE (a_variable_name == "i");
+    MESSAGE ("variable value: " << a_var->value ());
+    BOOST_REQUIRE (a_var && a_var->value () == "0");
+}
+
+void
+on_stopped_signal (IDebugger::StopReason,
+                   bool a_has_frame,
+                   const IDebugger::Frame &a_frame,
+                   int,
+                   int,
+                   const UString&,
+                   IDebuggerSafePtr a_debugger)
+{
+    THROW_IF_FAIL (a_debugger);
+
+    if (a_has_frame && a_frame.function_name () == "func1") {
+        static int nb_stops_in_func1 = 0;
+        nb_stops_in_func1++;
+        if (nb_stops_in_func1 == 2) {
+            a_debugger->print_variable_type ("i");
+            a_debugger->print_variable_value ("i");
+        }
+    }
+    a_debugger->step_over ();
+}
+
+NEMIVER_API int
+test_main (int, char **)
+{
+    NEMIVER_TRY
+
+    Initializer::do_init();
+    THROW_IF_FAIL (loop);
+
+    DynamicModuleManager module_manager ;
+    IDebuggerSafePtr debugger =
+            module_manager.load_iface<IDebugger> ("gdbengine", "IDebugger");
+
+    debugger->set_event_loop_context (loop->get_context ()) ;
+
+    debugger->engine_died_signal ().connect (&on_engine_died_signal) ;
+
+    debugger->program_finished_signal ().connect
+                                            (&on_program_finished_signal) ;
+
+    debugger->stopped_signal ().connect
+                            (sigc::bind (&on_stopped_signal, debugger)) ;
+
+    debugger->variable_type_signal ().connect
+                                            (&on_variable_type_signal) ;
+
+    debugger->variable_value_signal ().connect (&on_variable_value_signal);
+
+    std::vector<UString> args, source_search_dir ;
+    args.push_back ("fooprog") ;
+    source_search_dir.push_back (".") ;
+
+    debugger->load_program (args, "", source_search_dir);
+    debugger->set_breakpoint ("func1") ;
+    debugger->run () ;
+    loop->run () ;
+
+    NEMIVER_CATCH_NOX
+    return 0;
+}
+
+



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