perf annotate: Fix s390 target function disassembly
PATCH 1/1 perf annotate: Fix s390 target function disassembly
Perf annotate displays function call assembler instructions with a right arrow. Hitting enter on this line/instruction causes the browser to disassemble this target function and show it on the screen. On s390 this results in an error message 'The called function was not found.'
The function call assembly line parsing does not handle the s390 bras and brasl instructions. Function call__parse expects the target as first operand:
callq e9140 <__fxstat> S390 has a register number as first operand: brasl %r14,41d60 <abort>
Therefore the target addresses on s390 are always zero which is an invalid address.
Fix this by skipping the first operand on s390.
--- tools/perf/util/annotate.c | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/perf/util/annotate.c +9 -0
@@ -192,6 +192,14 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map * }; ops->target.addr =strtoull (ops->raw, &endptr,16 ); +if (!strcmp (arch->name,"s390" )) { +/* s390 function call 1st operand is register */ + tok =strchr (ops->raw,',' ); +if (tok) + ops->target.addr =strtoull (tok +1 , &endptr,16 ); +else + ops->target.addr =0 ; + }else + ops->target.addr =strtoull (ops->raw, &endptr,16 ); name =strchr (endptr,'<' );
if (name == NULL)
Signature · 1 line
2.14.3
Arnaldo Carvalho de Melo
maintainerEm Tue, Mar 06, 2018 at 01:39:55PM +0100, Thomas Richter escreveu:
Quoted 31 lines
Perf annotate displays function call assembler instructions with a right arrow. Hitting enter on this line/instruction causes the browser to disassemble this target function and show it on the screen. On s390 this results in an error message 'The called function was not found.'
The function call assembly line parsing does not handle the s390 bras and brasl instructions. Function
call__parseexpects the target as first operand:callq e9140 <__fxstat> S390 has a register number as first operand: brasl %r14,41d60 <abort>Therefore the target addresses on s390 are always zero which is an invalid address.
Fix this by skipping the first operand on s390.
Signed-off-by Thomas Richter <[email protected]>Reviewed-by Hendrik Brueckner <[email protected]>--- tools/perf/util/annotate.c | 8 ++++++++ 1 file changed, 8 insertions(+)tools/perf/util/annotate.c +0
-0@@ -192,6 +192,14 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map * };
tools/perf/util/annotate.c static int call__parse(struct arch *arch, struct ins_operands *ops, struct map * · line 203
Quoted 10 lines
tools/perf/util/annotate.c +9
-0ops->target.addr =strtoull (ops->raw, &endptr,16 ); +if (!strcmp (arch->name,"s390" )) { +/* s390 function call 1st operand is register */ + tok =strchr (ops->raw,',' ); +if (tok) + ops->target.addr =strtoull (tok +1 , &endptr,16 ); +else + ops->target.addr =0 ; + }else + ops->target.addr =strtoull (ops->raw, &endptr,16 );
Do we have to do this here? Can't we have a s390_call__parse() and set that in the s/390 instructions?
We should avoid arch specific stuff in the common code, and we could even have a call_reg__parse() perhaps? One that knows that the first operand is a reg and it should _always_ skip te first one, be it on s/390 or elsewhere?
- Arnaldo
Quoted 4 lines
tools/perf/util/annotate.c +0
-0name =strchr (endptr,'<' );if (name ==NULL )Signature · 1 line
2.14.3
Quoted 32 lines · Arnaldo Carvalho de Melo
Em Tue, Mar 06, 2018 at 01:39:55PM +0100, Thomas Richter escreveu:
Quoted 31 lines
Perf annotate displays function call assembler instructions with a right arrow. Hitting enter on this line/instruction causes the browser to disassemble this target function and show it on the screen. On s390 this results in an error message 'The called function was not found.'
The function call assembly line parsing does not handle the s390 bras and brasl instructions. Function
call__parseexpects the target as first operand:callq e9140 <__fxstat> S390 has a register number as first operand: brasl %r14,41d60 <abort>Therefore the target addresses on s390 are always zero which is an invalid address.
Fix this by skipping the first operand on s390.
Signed-off-by Thomas Richter <[email protected]>Reviewed-by Hendrik Brueckner <[email protected]>--- tools/perf/util/annotate.c | 8 ++++++++ 1 file changed, 8 insertions(+)tools/perf/util/annotate.c +0
-0@@ -192,6 +192,14 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map * };
Quoted 13 lines
tools/perf/util/annotate.c static int call__parse(struct arch *arch, struct ins_operands *ops, struct map * · line 203
Quoted 10 lines
tools/perf/util/annotate.c +9
-0ops->target.addr =strtoull (ops->raw, &endptr,16 ); +if (!strcmp (arch->name,"s390" )) { +/* s390 function call 1st operand is register */ + tok =strchr (ops->raw,',' ); +if (tok) + ops->target.addr =strtoull (tok +1 , &endptr,16 ); +else + ops->target.addr =0 ; + }else + ops->target.addr =strtoull (ops->raw, &endptr,16 );Do we have to do this here? Can't we have a
s390_call__parse()and set that in the s/390 instructions?
Originally I wanted to add an architecture specific weak function to handle s390 This did not work because file util/annotate.c includes the architecture specific versions around line 100:
#include "arch/arm/annotate/instructions.c"
#include "arch/arm64/annotate/instructions.c"
#include "arch/x86/annotate/instructions.c"
#include "arch/powerpc/annotate/instructions.c"
#include "arch/s390/annotate/instructions.c"
This includes the C file for s390 so we end up having function call__parse defined twice, one with a weak definition and one without which results in a compiler error.
I will use a s390 specific call__parse function and sent another patch.
Quoted 7 lines
Quoted 2 lines
Signature · 1 line
2.14.3--
To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 5 lines
Thomas Richter, Dept 3303, IBM LTC Boeblingen Germany -- Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Arnaldo Carvalho de Melo
maintainerEm Tue, Mar 06, 2018 at 03:52:35PM +0100, Thomas-Mich Richter escreveu:
Quoted 58 lines · Arnaldo Carvalho de Melo
Quoted 32 lines
Em Tue, Mar 06, 2018 at 01:39:55PM +0100, Thomas Richter escreveu:
Quoted 31 lines
Perf annotate displays function call assembler instructions with a right arrow. Hitting enter on this line/instruction causes the browser to disassemble this target function and show it on the screen. On s390 this results in an error message 'The called function was not found.'
The function call assembly line parsing does not handle the s390 bras and brasl instructions. Function
call__parseexpects the target as first operand:callq e9140 <__fxstat> S390 has a register number as first operand: brasl %r14,41d60 <abort>Therefore the target addresses on s390 are always zero which is an invalid address.
Fix this by skipping the first operand on s390.
Signed-off-by Thomas Richter <[email protected]>Reviewed-by Hendrik Brueckner <[email protected]>--- tools/perf/util/annotate.c | 8 ++++++++ 1 file changed, 8 insertions(+)tools/perf/util/annotate.c +0
-0@@ -192,6 +192,14 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map * };Quoted 13 lines
tools/perf/util/annotate.c static int call__parse(struct arch *arch, struct ins_operands *ops, struct map * · line 203
Quoted 10 lines
tools/perf/util/annotate.c +9
-0ops->target.addr =strtoull (ops->raw, &endptr,16 ); +if (!strcmp (arch->name,"s390" )) { +/* s390 function call 1st operand is register */ + tok =strchr (ops->raw,',' ); +if (tok) + ops->target.addr =strtoull (tok +1 , &endptr,16 ); +else + ops->target.addr =0 ; + }else + ops->target.addr =strtoull (ops->raw, &endptr,16 );Do we have to do this here? Can't we have a
s390_call__parse()and set that in the s/390 instructions?Originally I wanted to add an architecture specific weak function to handle s390 This did not work because file
util/annotate.cincludes the architecture specific versions around line 100:#include "
arch/arm/annotate/instructions.c"
#include "arch/arm64/annotate/instructions.c"
#include "arch/x86/annotate/instructions.c"
#include "arch/powerpc/annotate/instructions.c"
#include "arch/s390/annotate/instructions.c"
Quoted 4 lines
This includes the C file for s390 so we end up having function
call__parsedefined twice, one with a weak definition and one without which results in a compiler error.I will use a s390 specific
call__parsefunction and sent another patch.
So, in tools/perf/arch/s390/annotate/instructions.c you have that function s390__associate_ins_ops() where it sets the handler for the "brasl" asm instruction to be 'call__ops', what I am proposing is that instead you provide a brasl__ops and use it, this ops knows that it is a 'call', but the target is not where call__ops expects it to be, thus we have a separate ops for that, got it?
- Arnaldo
Quoted 15 lines
Quoted 7 lines
Quoted 2 lines
Signature · 1 line
2.14.3--
To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 5 lines
Thomas Richter, Dept 3303, IBM LTC Boeblingen Germany -- Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294