[nemiver/varobjs-support] Factorize the implementation of varobjs related entry points



commit c9d627d32ddd8ed31f6319c552231a0077188e93
Author: Dodji Seketeli <dodji redhat com>
Date:   Sat Apr 25 10:12:39 2009 +0200

    Factorize the implementation of varobjs related entry points
    
    	* src/dbgengine/nmv-i-debugger.h:
    	(IDebugger::create_variable): Modify signature so that we can
    	share the implementation between the two overloads.
    	(IDebugger::delete_variable): Likewise.
    	(IDebugger::unfold_variable): Likewise.
    	(IDebugger::assign_variable): Likewise.
    	(IDebugger::evaluate_variable_expr): Likewise.
    	* src/dbgengine/nmv-gdb-engine.h:
    	(GDBEngine::create_variable): Adjust.
    	(GDBEngine::delete_variable): Likewise.
    	(GDBEngine::unfold_variable): Likewise.
    	(GDBEngine::assign_variable): Likewise.
    	(GDBEngine::evaluate_variable_expr): Likewise.
    	(GDBEngine::list_changed_variables): Likewise.
    	(GDBEngine::list_register_names): Remove default variable value
    	from the function declaration.
    	(GDBEngine::list_register_values): Likewise.
    	(GDBEngine::list_changed_registers): Likewise.
    	(GDBEngine::set_memory): Likewise.
    	* src/dbgengine/nmv-gdb-engine.cc:
    	(null_const_variable_slot, null_const_variable_list_slot): New
    	functions.
    	(GDBEngine::create_variable): Factorize the implementation
    	between the two overloads.
    	(GDBEngine::delete_variable): Likewise.
    	(GDBEngine::unfold_variable): Likewise.
    	(GDBEngine::assign_variable): Likewise.
    	(evaluate_variable_expr): Likewise.
    	(GDBEngine::list_changed_variables): Likewise.
---
 src/dbgengine/nmv-gdb-engine.cc |  132 ++++++++++++++++----------------------
 src/dbgengine/nmv-gdb-engine.h  |   30 +++++----
 src/dbgengine/nmv-i-debugger.h  |   27 ++++++---
 3 files changed, 93 insertions(+), 96 deletions(-)

diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 01165ad..c268489 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -3994,29 +3994,29 @@ GDBEngine::set_memory (size_t a_addr,
 }
 
 void
+null_const_variable_slot (const IDebugger::VariableSafePtr &)
+{
+}
+
+void
+null_const_variable_list_slot (const IDebugger::VariableList &)
+{
+}
+
+void
 GDBEngine::create_variable (const UString &a_name,
                             const UString &a_cookie)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
-
-    if (a_name.empty ()) {
-        LOG ("got empty name");
-        return;
-    }
-
-    Command command ("create-variable",
-                     "-var-create - * " + a_name,
+    create_variable (a_name,
+                     &null_const_variable_slot,
                      a_cookie);
-    command.tag0 (a_name);
-
-    queue_command (Command ("create-variable",
-                            "-var-create - * " + a_name,
-                            a_cookie));
 }
 
 void
 GDBEngine::create_variable (const UString &a_name ,
-                            const sigc::slot<void, const VariableSafePtr> &a_slot)
+                            const ConstVariableSlot &a_slot,
+                            const UString &a_cookie)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
 
@@ -4026,10 +4026,10 @@ GDBEngine::create_variable (const UString &a_name ,
     }
 
     Command command ("create-variable",
-                     "-var-create - * " + a_name);
+                     "-var-create - * " + a_name,
+                     a_cookie);
     command.tag0 (a_name);
     command.set_slot (a_slot);
-
     queue_command (command);
 }
 
@@ -4038,20 +4038,15 @@ GDBEngine::delete_variable (const VariableSafePtr a_var,
                             const UString &a_cookie)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
-
-    THROW_IF_FAIL (a_var);
-    THROW_IF_FAIL (!a_var->internal_name ().empty ());
-
-    Command command ("delete-variable",
-                     "-var-delete " + a_var->internal_name (),
+    delete_variable (a_var,
+                     &null_const_variable_slot,
                      a_cookie);
-    command.variable (a_var);
-    queue_command (command);
 }
 
 void
 GDBEngine::delete_variable (const VariableSafePtr a_var,
-                            const sigc::slot<void,const VariableSafePtr> &a_slot)
+                            const ConstVariableSlot &a_slot,
+                            const UString &a_cookie)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
 
@@ -4059,10 +4054,10 @@ GDBEngine::delete_variable (const VariableSafePtr a_var,
     THROW_IF_FAIL (!a_var->internal_name ().empty ());
 
     Command command ("delete-variable",
-                     "-var-delete " + a_var->internal_name ());
+                     "-var-delete " + a_var->internal_name (),
+                     a_cookie);
     command.variable (a_var);
     command.set_slot (a_slot);
-
     queue_command (command);
 }
 
@@ -4071,27 +4066,15 @@ GDBEngine::unfold_variable (const VariableSafePtr a_var,
                             const UString &a_cookie)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
-
-    THROW_IF_FAIL (a_var);
-    if (a_var->internal_name ().empty ()) {
-        UString qname;
-        a_var->build_qualified_internal_name (qname);
-        a_var->internal_name (qname);
-    }
-    THROW_IF_FAIL (!a_var->internal_name ().empty ());
-
-    Command command ("unfold-variable",
-                     "-var-list-children --all-values "
-                         + a_var->internal_name (),
+    unfold_variable (a_var,
+                     &null_const_variable_slot,
                      a_cookie);
-    command.variable (a_var);
-
-    queue_command (command);
 }
 
 void
 GDBEngine::unfold_variable (const VariableSafePtr a_var,
-                            const sigc::slot<void, const VariableSafePtr> &a_slot)
+                            const ConstVariableSlot &a_slot,
+                            const UString &a_cookie)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
 
@@ -4104,10 +4087,10 @@ GDBEngine::unfold_variable (const VariableSafePtr a_var,
     THROW_IF_FAIL (!a_var->internal_name ().empty ());
 
     Command command ("unfold-variable",
-                     "-var-list-children --all-values " + a_var->internal_name ());
+                     "-var-list-children --all-values " + a_var->internal_name (),
+                     a_cookie);
     command.variable (a_var);
     command.set_slot (a_slot);
-
     queue_command (command);
 }
 
@@ -4116,24 +4099,19 @@ GDBEngine::assign_variable (const VariableSafePtr a_var,
                             const UString &a_expression,
                             const UString &a_cookie)
 {
-    THROW_IF_FAIL (a_var);
-    THROW_IF_FAIL (!a_var->internal_name ().empty ());
-    THROW_IF_FAIL (!a_expression.empty ());
-
-    Command command ("assign-variable",
-                     "-var-assign "
-                      + a_var->internal_name () + " " + a_expression,
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
+    assign_variable (a_var,
+                     a_expression,
+                     &null_const_variable_slot,
                      a_cookie);
-    command.variable (a_var);
-    queue_command (command);
-
 }
 
 void
 GDBEngine::assign_variable
                     (const VariableSafePtr a_var,
                      const UString &a_expression,
-                     const sigc::slot<void, const VariableSafePtr>& a_slot)
+                     const ConstVariableSlot &a_slot,
+                     const UString &a_cookie)
 {
     THROW_IF_FAIL (a_var);
     THROW_IF_FAIL (!a_var->internal_name ().empty ());
@@ -4141,7 +4119,8 @@ GDBEngine::assign_variable
 
     Command command ("assign-variable",
                      "-var-assign "
-                         + a_var->internal_name () + " " + a_expression);
+                         + a_var->internal_name () + " " + a_expression,
+                     a_cookie);
     command.variable (a_var);
     command.set_slot (a_slot);
     queue_command (command);
@@ -4151,26 +4130,27 @@ void
 GDBEngine::evaluate_variable_expr (const VariableSafePtr a_var,
                                    const UString &a_cookie)
 {
-    THROW_IF_FAIL (a_var);
-    THROW_IF_FAIL (!a_var->internal_name ().empty ());
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
 
-    Command command ("evaluate-expression",
-                     "-var-evaluate-expression " + a_var->internal_name (),
-                     a_cookie);
-    command.variable (a_var);
-    queue_command (command);
+    evaluate_variable_expr (a_var,
+                            &null_const_variable_slot,
+                            a_cookie);
 }
 
 void
 GDBEngine::evaluate_variable_expr
                         (const VariableSafePtr a_var,
-                         const sigc::slot<void, const VariableSafePtr> &a_slot)
+                         const ConstVariableSlot &a_slot,
+                         const UString &a_cookie)
 {
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
+
     THROW_IF_FAIL (a_var);
     THROW_IF_FAIL (!a_var->internal_name ().empty ());
 
     Command command ("evaluate-expression",
-                     "-var-evaluate-expression " + a_var->internal_name ());
+                     "-var-evaluate-expression " + a_var->internal_name (),
+                     a_cookie);
     command.variable (a_var);
     command.set_slot (a_slot);
     queue_command (command);
@@ -4180,28 +4160,28 @@ void
 GDBEngine::list_changed_variables (VariableSafePtr a_var,
                                    const UString &a_cookie)
 {
-    THROW_IF_FAIL (a_var);
-    THROW_IF_FAIL (!a_var->internal_name ().empty ());
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
 
-    Command command ("list-changed-variables",
-                     "-var-update --all-values "
-                         + a_var->internal_name (),
-                     a_cookie);
-    command.variable (a_var);
-    queue_command (command);
+    list_changed_variables (a_var,
+                            &null_const_variable_list_slot,
+                            a_cookie);
 }
 
 void
 GDBEngine::list_changed_variables
                 (VariableSafePtr a_var,
-                 const sigc::slot<void, const list<VariableSafePtr>& > &a_slot)
+                 const ConstVariableListSlot &a_slot,
+                 const UString &a_cookie)
 {
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
+
     THROW_IF_FAIL (a_var);
     THROW_IF_FAIL (!a_var->internal_name ().empty ());
 
     Command command ("list-changed-variables",
                      "-var-update --all-values "
-                         + a_var->internal_name ());
+                         + a_var->internal_name (),
+                     a_cookie);
     command.variable (a_var);
     command.set_slot (a_slot);
     queue_command (command);
diff --git a/src/dbgengine/nmv-gdb-engine.h b/src/dbgengine/nmv-gdb-engine.h
index e9ea846..55a44e5 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -389,41 +389,44 @@ public:
     bool extract_global_variable_list (Output &a_output,
                                        VarsPerFilesMap &a_vars) ;
 
-    void list_register_names (const UString &a_cookie="");
+    void list_register_names (const UString &a_cookie);
 
     void list_register_values (std::list<register_id_t> a_registers,
-                               const UString &a_cookie="");
+                               const UString &a_cookie);
 
     virtual void set_register_value (const UString& a_reg_name,
                                      const UString& a_value,
                                      const UString& a_cookie);
 
-    void list_changed_registers (const UString &a_cookie="");
+    void list_changed_registers (const UString &a_cookie);
 
-    void list_register_values (const UString &a_cookie="");
+    void list_register_values (const UString &a_cookie);
 
     void read_memory (size_t a_start_addr,
                       size_t a_num_bytes,
-                      const UString& a_cookie="") ;
+                      const UString& a_cookie) ;
     void set_memory (size_t a_addr,
                      const std::vector<uint8_t>& a_bytes,
-                     const UString& a_cookie="");
+                     const UString& a_cookie);
 
     void create_variable (const UString &a_name,
                           const UString &a_cookie="");
     void create_variable (const UString &a_name,
-                          const sigc::slot<void, const VariableSafePtr>&);
+                          const ConstVariableSlot &a_s,
+                          const UString &a_cookie="");
 
     void delete_variable (const VariableSafePtr a_var,
                           const UString &a_cookie);
 
     void delete_variable (const VariableSafePtr a_var,
-                          const sigc::slot<void,const VariableSafePtr>&);
+                          const ConstVariableSlot &a_s,
+                          const UString &a_cookie);
 
     void unfold_variable (VariableSafePtr a_var,
                           const UString &a_cookie);
     void unfold_variable (VariableSafePtr a_var,
-                          const sigc::slot<void, const VariableSafePtr> &);
+                          const ConstVariableSlot &a_s,
+                          const UString &a_cookie);
 
     void assign_variable (const VariableSafePtr a_var,
                           const UString &a_expression,
@@ -432,20 +435,23 @@ public:
     void assign_variable
                         (const VariableSafePtr a_var,
                          const UString &a_expression,
-                         const sigc::slot<void, const VariableSafePtr>& a_slot);
+                         const ConstVariableSlot &a_slot,
+                         const UString &a_cookie);
 
     void evaluate_variable_expr (const VariableSafePtr a_var,
                                  const UString &a_cookie);
     void evaluate_variable_expr
             (const VariableSafePtr a_var,
-             const sigc::slot<void, const VariableSafePtr> &a_slot);
+             const ConstVariableSlot &a_slot,
+             const UString &a_cookie);
 
     void list_changed_variables (VariableSafePtr a_root,
                                  const UString &a_cookie);
 
     void list_changed_variables
                 (VariableSafePtr a_root,
-                 const sigc::slot<void, const list<VariableSafePtr>& > &a_slot);
+                 const ConstVariableListSlot &a_slot,
+                 const UString &a_cookie);
 };//end class GDBEngine
 
 NEMIVER_END_NAMESPACE (nemiver)
diff --git a/src/dbgengine/nmv-i-debugger.h b/src/dbgengine/nmv-i-debugger.h
index d1edcc4..2a60058 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -1076,21 +1076,29 @@ public:
             const std::vector<uint8_t>& a_bytes,
             const UString& a_cookie="") = 0;
 
+    typedef sigc::slot<void, const VariableSafePtr> ConstVariableSlot;
+    typedef sigc::slot<void, const VariableList> ConstVariableListSlot;
+
     virtual void create_variable (const UString &a_name,
                                   const UString &a_cookie="") = 0;
+
     virtual void create_variable (const UString &a_name,
-                                  const sigc::slot<void,
-                                                   const VariableSafePtr>&) = 0;
+                                  const ConstVariableSlot &a_slot,
+                                  const UString &a_cookie="") = 0;
+
     virtual void delete_variable (const VariableSafePtr a_var,
                                   const UString &a_cookie="") = 0;
+
     virtual void delete_variable (const VariableSafePtr a_var,
-                                  const sigc::slot<void,
-                                                   const VariableSafePtr>&) = 0;
+                                  const ConstVariableSlot&,
+                                  const UString &a_cookie="") = 0;
+
     virtual void unfold_variable (VariableSafePtr a_var,
                                   const UString &a_cookie) = 0;
     virtual void unfold_variable
                 (VariableSafePtr a_var,
-                 const sigc::slot<void, const VariableSafePtr> &) = 0;
+                 const ConstVariableSlot&,
+                 const UString &a_cookie="") = 0;
 
     virtual void assign_variable (const VariableSafePtr a_var,
                                   const UString &a_expression,
@@ -1099,19 +1107,22 @@ public:
     virtual void assign_variable
                     (const VariableSafePtr a_var,
                      const UString &a_expression,
-                     const sigc::slot<void, const VariableSafePtr>& a_slot) = 0;
+                     const ConstVariableSlot &a_slot,
+                     const UString &a_cookie="") = 0;
 
     virtual void evaluate_variable_expr (const VariableSafePtr a_var,
                                          const UString &a_cookie) = 0;
     virtual void evaluate_variable_expr
             (const VariableSafePtr a_var,
-             const sigc::slot<void, const VariableSafePtr> &a_slot)= 0;
+             const ConstVariableSlot &a_slot,
+             const UString &a_cookie="")= 0;
 
     virtual void list_changed_variables (VariableSafePtr a_root,
                                          const UString &a_cookie) = 0;
     virtual void list_changed_variables
             (VariableSafePtr a_root,
-             const sigc::slot<void, const VariableList&> &a_slot) = 0;
+             const ConstVariableListSlot &a_slot,
+             const UString &a_cookie="") = 0;
 };//end IDebugger
 
 NEMIVER_END_NAMESPACE (nemiver)



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