On Thu, Dec 04, 2025 at 08:37:19AM -0800, Y Song via Dwarf-discuss wrote:
> Motivation
> ==========
> 
> My particular use case is for bpf-based linux kernel
> tracing. When tracing a kernel function, the user would like
> to know the actual signature. This is critical.
> 
> For example, if the actual signature is
>   static int foo(int a, int c) { ... }
> and the source signature is
>   static int foo(int a, int b, int c) { ... }

That is pretty normal function cloning.
__attribute__((noinline)) static int foo (int a, int b, int c) { return a + c; }
int bar (int a, int c)
{
  return foo (a, 0, c) + foo (1, 1, 2) + foo (2, 2, 3) + foo (a, 3, 4) + foo 
(5, 4, c);
}

You can just normally emit
DW_TAG_subprogram
  DW_AT_name "foo"
  DW_AT_inline 1
...
  DW_TAG_formal_parameter
    DW_AT_name "a"
...
  DW_TAG_formal_parameter
    DW_AT_name "b"
...
  DW_TAG_formal_parameter
    DW_AT_name "c"
for the original user function (if it isn't emitted in that shape,
without DW_AT_low_pc/DW_AT_high_pc/DW_AT_ranges etc.
Then
DW_TAG_subprogram
  DW_AT_abstract_origin <above foo DW_TAG_subprogram>
  DW_AT_low_pc ...
  DW_AT_high_pc ...
...
  DW_TAG_formal_parameter
    DW_AT_abstract_origin <above a DW_TAG_formal_parameter>
    DW_AT_location ...
  DW_TAG_formal_parameter
    DW_AT_abstract_origin <above b DW_TAG_formal_parameter>
    DW_AT_location DW_OP_GNU_parameter_ref <reference to 
DW_TAG_call_site_parameter>
  DW_TAG_formal_parameter
    DW_AT_abstract_origin <above c DW_TAG_formal_parameter>
    DW_AT_location ...

DW_OP_GNU_parameter_ref is an extension, see 
https://dwarfstd.org/issues/230109.1.html
In any case, I don't see why you need something like
DW_TAG_inlined_subroutine at DW_TAG_compile_unit scope, you can't inline a
function into a translation unit.

        Jakub

-- 
Dwarf-discuss mailing list
[email protected]
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

Reply via email to