• Namhyung Kim's avatar
    perf annotate-data: Improve debug message with location info · 2bc3cf57
    Namhyung Kim authored
    To verify it found the correct variable, let's add the location
    expression to the debug message.
    
      $ perf --debug type-profile annotate --data-type
      ...
      -----------------------------------------------------------
      find data type for 0xaf0(reg15) at schedule+0xeb
      CU for kernel/sched/core.c (die:0x1180523)
      frame base: cfa=0 fbreg=6
      found "rq" in scope=3/4 (die: 0x11b6a00) type_offset=0xaf0
       variable location: reg15
       type='struct rq' size=0xfc0 (die:0x11892e2)
      -----------------------------------------------------------
      find data type for 0x7bc(reg3) at tcp_get_info+0x62
      CU for net/ipv4/tcp.c (die:0x7b5f516)
      frame base: cfa=0 fbreg=6
      offset: 1980 is bigger than size: 760
      check variable "sk" failed (die: 0x7b92b2c)
       variable location: reg3
       type='struct sock' size=0x2f8 (die:0x7b63c3ab)
      -----------------------------------------------------------
      ...
    
    The first case is fine.  It looked up a data type in r15 with offset of
    0xaf0 at schedule+0xeb.  It found the CU die and the frame base info and
    the variable "rq" was found in the scope 3/4.  Its location is the r15
    register and the type size is 0xfc0 which includes 0xaf0.
    
    But the second case is not good.  It looked up a data type in rbx (reg3)
    with offset 0x7bc.  It found a CU and the frame base which is good so
    far.  And it also found a variable "sk" but the access offset is bigger
    than the type size (1980 vs. 760 or 0x7bc vs. 0x2f8).  The variable has
    the right location (reg3) but I need to figure out why it accesses
    beyond what it's supposed to.
    Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: https://lore.kernel.org/r/20240412183310.2518474-2-namhyung@kernel.org
    [ Fix the build on 32-bit by casting Dwarf_Word to (long) in pr_debug_location() ]
    Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    2bc3cf57
annotate-data.c 48.4 KB