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.
llvm-svn: 232068
30 lines
746 B
C
30 lines
746 B
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
struct foo
|
|
{
|
|
uint8_t first_val;
|
|
uint32_t second_val;
|
|
uint64_t third_val;
|
|
};
|
|
|
|
int main ()
|
|
{
|
|
int val = 100;
|
|
struct foo mine = {55, 5555, 55555555};
|
|
struct foo *ptr = (struct foo *) malloc (sizeof (struct foo));
|
|
ptr->first_val = 66;
|
|
ptr->second_val = 6666;
|
|
ptr->third_val = 66666666;
|
|
|
|
// Stop here and set values
|
|
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);
|
|
|
|
// Stop here and check values
|
|
printf ("This is just another call which we won't make it over %d.", val);
|
|
return 0; // Set a breakpoint here at the end
|
|
}
|