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 */
--- 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
Just a quick ping on this patch.
Thanks,
Donglin
Quoted 54 lines · Donglin Peng
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
-1@@ -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 ; --2.34.1
Steven Rostedt
maintainerQuoted 2 lines · On Tue, 24 Nov 2026 19:07:55 +0800 Donglin Peng <[email protected]> wrote:
Just a quick ping on this patch.
It's in queue. I have 153 patches in my todo list and unfortunately, fixes always preempt enhancements. This patch is more of an enhancement than a fix. But I'll get to it.
-- Steve
Quoted 10 lines · Steven Rostedt
Quoted 2 lines · On Tue, 24 Nov 2026 19:07:55 +0800 Donglin Peng <[email protected]> wrote:
Just a quick ping on this patch.
It's in queue. I have 153 patches in my todo list and unfortunately, fixes always preempt enhancements. This patch is more of an enhancement than a fix. But I'll get to it.
Understood, thanks for the update!
-- Donglin
Quoted 2 lines
-- Steve