[nemiver] Add new IDebugger::get_current_frame_level abstract API and implementation



commit 8da2f2ccd9ab062bf6d82f19c89d788bfabf4eba
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 0bcb95d..f0e42e5 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -117,6 +117,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
@@ -1116,6 +1118,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 (),
@@ -1252,6 +1258,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.
@@ -2240,6 +2249,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 ()
 {
@@ -3103,10 +3131,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 a1b2cd1..a6fbf72 100644
--- a/src/dbgengine/nmv-gdb-engine.h
+++ b/src/dbgengine/nmv-gdb-engine.h
@@ -264,6 +264,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 8b2c19f..99cc7f3 100644
--- a/src/dbgengine/nmv-i-debugger.h
+++ b/src/dbgengine/nmv-i-debugger.h
@@ -743,6 +743,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]