Bug 461737 - Function breakpoints are no longer valid with PPC64 ELFv2
Summary: Function breakpoints are no longer valid with PPC64 ELFv2
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: 1.3   Edit
Hardware: Power PC All
: P3 major (vote)
Target Milestone: 1.3   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-09 11:53 EDT by Vincent Hue CLA
Modified: 2015-06-16 03:17 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (8.34 KB, patch)
2015-05-05 03:44 EDT, xavier pouyollon CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Hue CLA 2015-03-09 11:53:03 EDT
A new version of PowerPC 64 ABI was recently released. 
With the previous version (1.9) of the ABI, using function descriptors, 
a function call was indirect, and the caller was setting the value of the 
TOC (Table of content) base pointer in register r2 prior to the call. 

The new ABI (v2) no longer uses function pointer. The callee has code 
to set the r2 register right after its entry point. This is described in the ABI : 

> All functions have a global entry point (GEP) available to any caller 
> and pointing to the beginning of the prologue. Some functions may have 
> a secondary entry point to optimize the cost of TOC pointer management. 
> In particular, functions within a common module sharing the same TOC base 
> value in r2 may be entered using a secondary entry point (the local 
> entry point or LEP) that may bypass the code that loads a suitable 
> TOC pointer value into the r2 register

> The OpenPOWER ABI uses the three most-significant bits in the symbol st_other
> field to specify the number of instructions between a function's
> global entry point and local entry point.

Here is an example of v2 code :

> void testRtn(void)
>     {
>  140:	3c 4c 00 00 	addis   r2,r12,0
> 			142: R_PPC64_REL16_HA	.TOC.+0x2
>  144:	38 42 00 00 	addi    r2,r2,0
> 			146: R_PPC64_REL16_LO	.TOC.+0x6
>  148:	7c 08 02 a6 	mflr    r0
>  14c:	f8 01 00 10 	std     r0,16(r1)
>  150:	fb e1 ff f8 	std     r31,-8(r1)
>  154:	f8 21 ff d1 	stdu    r1,-48(r1)
>  158:	7c 3f 0b 78 	mr      r31,r1

"external" call will go to 0x140. The compile may also permit functions 
in the same module (sharing same TOC) to go directly to 0x148. 

The issue for TCF agent is in the setting of function breakpoint. 
The current expression evaluator will use the GEP as function address. 
But setting a breakpoint at the GEP will work only when the call is not optimized. 

If we want to break for both optimized and non-optimized calls, the breakpoints 
need to be set on the LEP. 
A hook needs to be put in place to offset the BP location 
based on the ELF information for the function symbol.
Comment 1 xavier pouyollon CLA 2015-05-05 03:44:11 EDT
Created attachment 253157 [details]
Proposed patch
Comment 2 xavier pouyollon CLA 2015-05-05 03:47:51 EDT
Hi Eugene,

Attached a proposed patch. Sorry, I could not get the git push review to work.
(ssh: connect to host git.eclipse.org port 29418: Connection timed out)

Thanks !
Xavier.
Comment 3 xavier pouyollon CLA 2015-05-05 05:06:38 EDT
https://git.eclipse.org/r/#/c/47135/
Comment 4 Eugene Tarassov CLA 2015-05-05 21:06:02 EDT
(In reply to xavier pouyollon from comment #3)
> https://git.eclipse.org/r/#/c/47135/

Submitted.
Thanks!
Comment 5 Martin Oberhuber CLA 2015-05-22 11:30:57 EDT
Comment on attachment 253157 [details]
Proposed patch

Marking the patch as obsolete since it was actually submitted via Gerrit.