fgraph: Format error pointers as signed errno values
PATCH 1/1 fgraph: Format error pointers as signed errno values
From: pengdonglin <[email protected]>
The BTF-aware funcgraph-retval formatter currently treats all pointer returns as hexadecimal values. Error pointers returned with ERR_PTR() therefore appear as high unsigned addresses in smart mode, obscuring the underlying errno.
Recognize error-pointer values for pointer return types in btf_trim_retval() and select signed decimal formatting.
Before:
trim_retval_ptr_error(); /* ret=0xffffffffffffffea */
After:
trim_retval_ptr_error(); /* ret=-22 */
Users who need to inspect the raw encoded value can enable funcgraph-retval-hex, which produces:
trim_retval_ptr_error(); /* ret=0xffffffffffffffea */
Signed-off-by pengdonglin <[email protected]>
--- kernel/trace/trace_btf.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/trace/trace_btf.c +7 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/btf.h> +#include <linux/err.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/kallsyms.h>
@@ -197,6 +198,12 @@ void btf_trim_retval(unsigned long func, unsigned long *retval, bool *print_retvif (signed_type && !hex) *retval =sign_extend64 (*retval, msb);break ; +case BTF_KIND_PTR : +if (!hex &&IS_ERR_VALUE (*retval)) + *fmt =RETVAL_FMT_DEC ; +else + *fmt =RETVAL_FMT_HEX ; +break ;default : *fmt =RETVAL_FMT_HEX ;break ;
Signature · 1 line
2.34.1