[Lldb-commits] [lldb] r232068 - Avoid a failing test case by fixing things so the compiler generates a line table entry for line the very start of the printf() before any values have been loaded into registers.

Greg Clayton gclayton at apple.com
Thu Mar 12 10:42:16 PDT 2015


Author: gclayton
Date: Thu Mar 12 12:42:15 2015
New Revision: 232068

URL: http://llvm.org/viewvc/llvm-project?rev=232068&view=rev
Log:
Avoid a failing test case by fixing things so the compiler generates a line table entry for line the very start of the printf() before any values have been loaded into registers.

The issue was the previous code tried to stop on the following code in main.c:

21    // Stop here and set values
22    printf ("Val - %d Mine - %d, %d, %llu. Ptr - %d, %d, %llu\n", 
23            val, 
24            mine.first_val, mine.second_val, mine.third_val,
25            ptr->first_val, ptr->second_val, ptr->third_val); 

We we set a source regex breakpoint on "// Stop here and set values" we would set a breakpoint on line 22 as expected. 

The problem is the most recent clang compiler generates a line table like this


0x1000: main.c:23 // Loading of "val" into a register
0x1010: main.c:24 // Load mine.first_val, mine.second_val, mine.third_val values into registers or on the stack
0x1020: main.c:25 // Load ptr->first_val, ptr->second_val, ptr->third_val values into registers or on the stack
0x1030: main.c:22 // Call to printf

In this test, we run to line 22, then we use python to modify the value of "val" and then continue to another breakpoint and try to read the STDOUT from the printf to verify the values changed correctly.

With the above line table the value for "val" had already been loaded into a register so the string from printf would be incorrect.

Doing an easy fix for now by changing the code to:

21    // Stop here and set values
22  printf ("Val - %d Mine - %d, %d, %llu. Ptr - %d, %d, %llu\n", val, 
23          mine.first_val, mine.second_val, mine.third_val,
24          ptr->first_val, ptr->second_val, ptr->third_val); 


Now we get a line table entry for line 22 that is before any locals are read from the stack into registers.

I need to follow up with the compiler guys and see if we can get a fix for this as anyone setting file + line breeakpoints might be very surprised to have code from lines below the current line already have had their code run.


Modified:
    lldb/trunk/test/python_api/value/change_values/main.c

Modified: lldb/trunk/test/python_api/value/change_values/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/change_values/main.c?rev=232068&r1=232067&r2=232068&view=diff
==============================================================================
--- lldb/trunk/test/python_api/value/change_values/main.c (original)
+++ lldb/trunk/test/python_api/value/change_values/main.c Thu Mar 12 12:42:15 2015
@@ -19,8 +19,7 @@ int main ()
   ptr->third_val = 66666666;
 
   // Stop here and set values
-  printf ("Val - %d Mine - %d, %d, %llu. Ptr - %d, %d, %llu\n", 
-          val, 
+  printf ("Val - %d Mine - %d, %d, %llu. Ptr - %d, %d, %llu\n", val, 
           mine.first_val, mine.second_val, mine.third_val,
           ptr->first_val, ptr->second_val, ptr->third_val); 
 





More information about the lldb-commits mailing list