Hi, The following program, when compiled with -O0 -g3 (x86_64 target, but doesn't seem to matter), shows wrong values for p (function parameter) when debugging.
[saaadhu@jaguar scratch]$ cat test.c int func(int p) { p = 20; p = 30; } int main() { int local = 42; func(local); } The assembly generated looks like this func: pushq %rbp movq %rsp, %rbp movl %edi, -20(%rbp) movl $20, -4(%rbp) movl $30, -4(%rbp) popq %rbp ret I guess the DWARF debug information generated specifies -20(%rbp) as the offset to look for p, and that's why the debugger keeps showing the passed value (42) instead of 20 and 30 (see gdb session dump below). The same behavior occurs for the avr target as well, and debugging cc1 showed that the initial move happens from gimple_expand_cfg's expand_function_start, when it eventually calls assign_parm_setup_stack. That in itself is ok I guess, but the frame offset doesn't match other reads from and writes to the same variable. Debugging further, I found that that the offset is bumped up because expand_vars, called earlier from gimple_expand_cfg, allocates space on the frame for p as well. Specifically, expand_used_vars, when looping through SA.map->num_partitions, sees that SA.partition_has_default_def is false for the partition corresponding to p, and calls expand_one_var to allocate space for it. remove_ssa_form sets partition_has_default_def, but looping over num_ssa_names does not include the tree node for the parameter. Before investigating further, I wanted to know if this actually is a bug and if I'm debugging it right. Shouldn't function parameters be defined by default on entry into the function? Regards Senthil [saaadhu@jaguar scratch]$ gcc -g3 -O0 test.c [saaadhu@jaguar scratch]$ gdb a.out GNU gdb (GDB) 7.4.1 ... (gdb) b func Breakpoint 1 at 0x4004b3: file test.c, line 3. (gdb) start Temporary breakpoint 2 at 0x4004cb: file test.c, line 9. Starting program: /home/saaadhu/scratch/a.out Temporary breakpoint 2, main () at test.c:9 9 int local = 42; (gdb) c Continuing. Breakpoint 1, func (p=42) at test.c:3 3 p = 20; (gdb) n 4 p = 30; (gdb) print p $1 = 42 (gdb)