nitesh.jain created this revision.
Herald added subscribers: arichardson, ki.stfu.

Call to s_MyFunction may not follow immediately after g_MyFunction. There might 
be some instructions in between to restore caller-saved registers. We need to 
get past these instructions with a step to reach call to s_MyFunction.


https://reviews.llvm.org/D32340

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
  packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp


Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
===================================================================
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
@@ -26,8 +26,8 @@
 main(int argc, char const *argv[])
 {
     printf("start");
-    g_MyFunction();
-    s_MyFunction();
+    g_MyFunction(); // function_line_1
+    s_MyFunction(); // function_line_2
     printf("exit");
     return 0;
 }
Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
===================================================================
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -284,6 +284,9 @@
         self.runCmd("-file-exec-and-symbols %s" % self.myexe)
         self.expect("\^done")
 
+        self.g_MyFunction_line_no = line_number('main.cpp', "function_line_1")
+        self.s_MyFunction_line_no = line_number('main.cpp', "function_line_2")
+
         # Run to main
         self.runCmd("-break-insert -f main")
         self.expect("\^done,bkpt={number=\"1\"")
@@ -320,7 +323,17 @@
         self.runCmd("-exec-finish --frame 0")
         self.expect("\^running")
         self.expect(
-            
"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+            
"\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(30|29)\"")
+
+        finish_status = self.child.after
+        string_to_match = 'line="{0}"'.format(self.g_MyFunction_line_no)
+
+        # Call to s_MyFunction may not follow immediately after g_MyFunction.
+        # There might be some instructions in between to restore caller-saved 
registers.
+        # We need to get past these instructions with a step to reach call to 
s_MyFunction.
+
+        if (finish_status.find(string_to_match) >= 0):
+            self.runCmd("-exec-step --thread 1")
 
         # Test that -exec-step steps into s_MyFunction
         # (and that --frame is optional)


Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
===================================================================
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/main.cpp
@@ -26,8 +26,8 @@
 main(int argc, char const *argv[])
 {
     printf("start");
-    g_MyFunction();
-    s_MyFunction();
+    g_MyFunction(); // function_line_1
+    s_MyFunction(); // function_line_2
     printf("exit");
     return 0;
 }
Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
===================================================================
--- packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py
@@ -284,6 +284,9 @@
         self.runCmd("-file-exec-and-symbols %s" % self.myexe)
         self.expect("\^done")
 
+        self.g_MyFunction_line_no = line_number('main.cpp', "function_line_1")
+        self.s_MyFunction_line_no = line_number('main.cpp', "function_line_2")
+
         # Run to main
         self.runCmd("-break-insert -f main")
         self.expect("\^done,bkpt={number=\"1\"")
@@ -320,7 +323,17 @@
         self.runCmd("-exec-finish --frame 0")
         self.expect("\^running")
         self.expect(
-            "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"30\"")
+            "\*stopped,reason=\"end-stepping-range\".+?main\.cpp\",line=\"(30|29)\"")
+
+        finish_status = self.child.after
+        string_to_match = 'line="{0}"'.format(self.g_MyFunction_line_no)
+
+        # Call to s_MyFunction may not follow immediately after g_MyFunction.
+        # There might be some instructions in between to restore caller-saved registers.
+        # We need to get past these instructions with a step to reach call to s_MyFunction.
+
+        if (finish_status.find(string_to_match) >= 0):
+            self.runCmd("-exec-step --thread 1")
 
         # Test that -exec-step steps into s_MyFunction
         # (and that --frame is optional)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to