Bug 440676 - Breakpoint relocation can lead to extremely confusing behavior
Summary: Breakpoint relocation can lead to extremely confusing behavior
Status: NEW
Alias: None
Product: TCF
Classification: Tools
Component: Debug (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-29 14:34 EDT by Martin Oberhuber CLA
Modified: 2014-08-21 04:06 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2014-07-29 14:34:21 EDT
CQ:WIND00-TCDIAB-12363

When debugging highly optimized code, instruction reordering or code that's optimized out can lead to very unexpected mappings between source numbers and actual addresses. 

In one case, it happened for a customer that he wanted to set a breakpoint in an initialization routine

  void init() {
     myGlobal = 0;
  }

but since the compiler had optimized out the assignment and replaced it with static BSS initialization, the breakpoint got relocated to a different function just beneath this. Such relocation behavior is extremely confusing and not acceptable.

I'm not sure if the concrete issue described here can be due to incorrect debug info (can it?) but I'm wondering what TCF can do to avoid such problems. What about a Preference to disable breakpoint relocation for instance, or limit it to 3 lines maximum ? Any other thoughts / ideas ?
Comment 1 Eugene Tarassov CLA 2014-07-30 12:31:22 EDT
It is ether compiler fault or a bug in TCF symbol info reader. To tell more, I would need the ELF file.
Comment 2 xavier pouyollon CLA 2014-08-21 04:06:42 EDT
Hi Eugene,

The only information I can provide is that:

- In the debug_infos, there are 2 compilation unit for the SAME C file.
The first compilation unit has NO AT_low_pc / AT_high_pc. 
The second compilation unit has AT_low_pc / AT_high_pc.

- In the debug_lines, there are 2 compilation unit for the SAME C file.
The first compilation unit has the searched line with an address. Perfect, this address is returned.
The second compilation unit hasn't the searched line, that will lead to the "wrong relocation".

However, should the TCF debugger go to the SECOND compilation unit since it could find a match in the debug_lines ?
One could say no.
However, a breakpoint can be spread at several @ so in a sense, it is normal to look in the second compilation unit, especially since AT_low_pc / AT_high_pc is provided...As said previously, the second compilation hasn't the exact line so the closest match is also provided.

So the customer ends-up with 2 addresses : the right one and a bogus one.

Very Best Regards,
Xavier.