Bug 559940 - skip_function_prologue fails if the function size attribute not available
Summary: skip_function_prologue fails if the function size attribute not available
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: 1.6   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 1.7   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-08 04:36 EST by Jian Xu CLA
Modified: 2021-06-25 16:23 EDT (History)
0 users

See Also:


Attachments
dwarf info of application (60.25 KB, text/plain)
2020-02-08 04:36 EST, Jian Xu CLA
no flags Details
application (230.44 KB, application/octet-stream)
2020-02-08 04:37 EST, Jian Xu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jian Xu CLA 2020-02-08 04:36:38 EST
Created attachment 281751 [details]
dwarf info of application

On ppc64 or ppc32, build an application(it call printf) with compiler option -mlongcall and linked with a c language lib that without debug info. We can get a special debug info for symbol printf. We can find printf in debug info, but it doesn't have location info. It fails when plant a breakpoint for printf. From logs, we know two symbol infos are found(R 216) , the first one is dwarf symbol, the second one is elf symbol. By dwarf symbol, we get some info about printf(R 218). It doesn't have size info of printf, such as "Size":168. So planting breakpoint fails. In this case, elf info should be the first one.

TCF 06:20:10.019: 1: <--- C 216 Symbols findByName "P18446603336304974432" 0 "printf" <eom>
TCF 06:20:10.019: 1: ---> R 216  ["@S3%FD01.3304EFA.5E390CE4.D.C78+2.P18446603336304974432","@S3%FD01.3304EFA.5E390CE4.0.0-13+2=133.P18446603336304974432"] <eom>

TCF 06:20:10.020: 1: <--- C 218 Symbols getContext "@S3%FD01.3304EFA.5E390CE4.D.C78+2.P18446603336304974432" <eom>
TCF 06:20:10.020: 1: ---> R 218  {"ID":"@S3%FD01.3304EFA.5E390CE4.D.C78+2.P18446603336304974432","OwnerID":"P18446603336304974432","UpdatePolicy":0,"Name":"printf","TypeClass":8,"TypeID":"@P4+2.0.0.@S3%FD01.3304EFA.5E390CE4.D.C78+2.P18446603336304974432","BaseTypeID":"@S4%FD01.3304EFA.5E390CE4.D.FFFFFFFFFFFFFFFF+2.P18446603336304974432","ContainerID":"@S5%FD01.3304EFA.5E390CE4.D.B+2.P18446603336304974432","Address":67123360,"Flags":32768,"LocalEntryOffset":8,"Class":3} <eom>

I analyzed the code and found that it's caused by the modification of function symbol_has_location at commit 9e3405f457e32baf268d90ddc6fcbf3e3f0886a2. Before modification, symbol_has_location return 0 for dwarf symbol, after modification symbol_has_location return 1 for dwarf symbol.
Comment 1 Jian Xu CLA 2020-02-08 04:37:01 EST
Created attachment 281752 [details]
application
Comment 2 Eugene Tarassov CLA 2020-02-12 11:37:29 EST
Why do you need "Size" to plant a function breakpoint?
This looks like a bug on your side.

Size of a function is not a well-defined concept.
C/C++ standards do not allow getting size of a function.
Expecting "Size" to be always available is very bad idea.
Comment 3 Jian Xu CLA 2020-02-28 03:26:55 EST
Error is returned by function skip_function_prologue (at breakpoints.c).
Not our code. If I delete the use of get_symbol_size at skip_function_prologue. It will be ok, breakpoint can be planted successfully.
Comment 4 Eugene Tarassov CLA 2020-03-04 11:58:01 EST
skip_function_prologue should check size only when size is available.
The size check is optional anyway, it is not needed unless debug info is severely malformed.

Fixed.
Thanks!