[nemiver/varobjs-support] Add new IDebugger::get_current_frame_level abstract API and implementation



commit 3ffdf56f035b96acf9c3e9fb5049af2f649aed2f
Author: Dodji Seketeli <dodji redhat com>
Date:   Sun Apr 12 20:52:01 2009 +0200

    Add new IDebugger::get_current_frame_level abstract API and implementation
    
    	* src/dbgengine/nmv-i-debugger.h:
    	(IDebugger::get_current_frame_level): New abstract interface.
    	* src/dbgengine/nmv-gdb-engine.h:
    	(GDBEngine::get_current_frame_level,
    	 GDBEngine::set_current_frame_level): New concrete interfaces.
    	* src/dbgengine/nmv-gdb-engine.cc:
    	(OnStoppedHander::do_handle): Save the current frame level if we
    	have the information.
    	(OnCommandDoneHandler::do_handle): Once the 'select-frame'
    	command was successfully done, save the requested frame level as
    	the current frame level.
    	(GDBEngine::select_frame): Embed the requested frame level in the
    	Command as tag2.
    	(GDBEngine::get_current_frame_level): New implementation.
    	(GDBEngine::set_current_frame_level): Likewise.
---
 src/dbgengine/nmv-gdb-engine.cc |   39 +++++++++++++++++++++++++++++++++++----
 src/dbgengine/nmv-gdb-engine.h  |    4 ++++
 src/dbgengine/nmv-i-debugger.h  |    2 ++
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 4f9bfb5..82bad30 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -100,6 +100,7 @@ public:
 
     OutputHandlerList output_handler_list;
     IDebugger::State state;
+    int cur_frame_level;
     ILangTraitSafePtr lang_trait;
     UString debugger_full_path;
     GDBMIParser gdbmi_parser;
@@ -394,6 +395,7 @@ public:
         line_busy (false),
         error_buffer_status (DEFAULT),
         state (IDebugger::NOT_STARTED),
+        cur_frame_level (0),
         gdbmi_parser (GDBMIParser::BROKEN_MODE)
     {
         gdb_stdout_signal.connect (sigc::mem_fun
@@ -1125,6 +1127,10 @@ struct OnStoppedHandler: OutputHandler {
         if (reason == IDebugger::BREAKPOINT_HIT)
             breakpoint_number = m_out_of_band_record.breakpoint_number ();
 
+        if (m_out_of_band_record.has_frame ()) {
+            m_engine->set_current_frame_level
+                    (m_out_of_band_record.frame ().level ());
+        }
         m_engine->stopped_signal ().emit
                     (m_out_of_band_record.stop_reason (),
                      m_out_of_band_record.has_frame (),
@@ -1261,6 +1267,9 @@ struct OnCommandDoneHandler : OutputHandler {
         if (a_in.command ().name () == "attach-to-program") {
             m_engine->set_attached_to_target (true);
         }
+        if (a_in.command ().name () == "select-frame") {
+            m_engine->set_current_frame_level (a_in.command ().tag2 ());
+        }
         //TODO: this is not necessarily true. Before setting the state
         //to ready here, one must now which command exactly was fired so
         //that gdb returned the "DONE" status for it.
@@ -2496,6 +2505,25 @@ GDBEngine::get_state () const
     return m_priv->state;
 }
 
+int
+GDBEngine::get_current_frame_level () const
+{
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
+    THROW_IF_FAIL (m_priv);
+
+    LOG_DD ("state: " << m_priv->cur_frame_level);
+    return m_priv->cur_frame_level;
+}
+
+void
+GDBEngine::set_current_frame_level (int a_level)
+{
+    LOG_FUNCTION_SCOPE_NORMAL_DD;
+    THROW_IF_FAIL (m_priv);
+
+    m_priv->cur_frame_level = a_level;
+}
+
 void
 GDBEngine::init_output_handlers ()
 {
@@ -3382,10 +3410,13 @@ GDBEngine::select_frame (int a_frame_id,
                          const UString &a_cookie)
 {
     LOG_FUNCTION_SCOPE_NORMAL_DD;
-    queue_command (Command ("select-frame",
-                            "-stack-select-frame "
-                                    + UString::from_int (a_frame_id),
-                            a_cookie));
+    Command command ("select-frame",
+                     "-stack-select-frame "
+                        + UString::from_int (a_frame_id),
+                     a_cookie);
+    command.tag2 (a_frame_id);
+    queue_command (command);
+
 }
 
 void
diff --git a/src/dbgengine/nmv-gdb-engine.h b/src/dbgengine/nmv-gdb-engine.h
index 0e09638..0f1762d 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -283,6 +283,10 @@ public:
 
     IDebugger::State get_state () const ;
 
+    int get_current_frame_level () const;
+
+    void set_current_frame_level (int);
+
     void step_in (const UString &a_cookie) ;
 
     void step_out (const UString &a_cookie) ;
diff --git a/src/dbgengine/nmv-i-debugger.h b/src/dbgengine/nmv-i-debugger.h
index 4a10aee..c32ea64 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -890,6 +890,8 @@ public:
 
     virtual IDebugger::State get_state () const = 0;
 
+    virtual int get_current_frame_level () const = 0;
+
     virtual bool stop_target () = 0;
 
     virtual void exit_engine () = 0;



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