1. 13 12月, 2013 1 次提交
  2. 14 10月, 2013 3 次提交
    • C
      perf symbols: Fix a mmap and munmap mismatched bug · 784f3390
      Chenggang Qin 提交于
      In function filename__read_debuglink(), while the ELF file is opend and
      mmapped in elf_begin(), but if this file is considered to not be usable
      during the following code, we will goto the close(fd) directly. The
      elf_end() is skipped.  So, the mmaped ELF file cannot be munmapped. The
      mmapped areas exist during the life of perf.
      
      This is a memory leak.  This patch fixed this bug.
      Reviewed-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NChenggang Qin <chenggang.qcg@taobao.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Chenggang Qin <chenggang.qcg@taobao.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wu Fengguang <fengguang.wu@intel.com>
      Cc: Yanmin Zhang <yanmin.zhang@intel.com>
      Link: http://lkml.kernel.org/r/1381451279-4109-1-git-send-email-chenggang.qin@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      784f3390
    • A
      perf buildid-cache: Add ability to add kcore to the cache · fc1b691d
      Adrian Hunter 提交于
      kcore can be used to view the running kernel object code.  However,
      kcore changes as modules are loaded and unloaded, and when the kernel
      decides to modify its own code.  Consequently it is useful to create a
      copy of kcore at a particular time.  Unlike vmlinux, kcore is not unique
      for a given build-id.  And in addition, the kallsyms and modules files
      are also needed.  The tool therefore creates a directory:
      
      	~/.debug/[kernel.kcore]/<build-id>/<YYYYmmddHHMMSShh>
      
      which contains: kcore, kallsyms and modules.
      
      Note that the copied kcore contains only code sections.  See the
      kcore_copy() function for how that is determined.
      
      The tool will not make additional copies of kcore if there is already
      one with the same modules at the same addresses.
      
      Currently, perf tools will not look for kcore in the cache.  That is
      addressed in another patch.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/525BF849.5030405@intel.com
      [ renamed 'index' to 'idx' to avoid shadowing string.h symbol in f12,
        use at least one member initializer when initializing a struct to
        zeros, also to fix the build on f12 ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fc1b691d
    • A
      perf symbols: Workaround objdump difficulties with kcore · afba19d9
      Adrian Hunter 提交于
      The objdump tool fails to annotate module symbols when looking at kcore.
      
      Workaround this by extracting object code from kcore and putting it in a
      temporary file for objdump to use instead.
      
      The temporary file is created to look like kcore but contains only the
      function being disassembled.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1381320078-16497-3-git-send-email-adrian.hunter@intel.com
      [ Renamed 'index' to 'idx' to avoid shadowing string.h's 'index' in Fedora 12,
        Replace local with variable length with malloc/free to fix build in Fedora 12 ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      afba19d9
  3. 09 10月, 2013 1 次提交
  4. 29 9月, 2013 1 次提交
    • I
      Revert "perf symbols: Demangle cloned functions" · 14951f22
      Ingo Molnar 提交于
      This reverts commit de95ab53.
      
      Markus Trippelsdorf reported that this commit broke 'perf top':
      
       > I just see a gray screen with no text at all. Sometimes the
       > following error messages are printed:
       >
       >  *** Error in `perf': invalid fastbin entry (free): 0x00000000029b18c0
       >  ***
       >  *** Error in `perf': malloc(): memory corruption (fast): 0x0000000000ee0b10 ***
      
      While this code is fixable, the commit itself fails on several levels:
      
       - it should have been a separate helper function
       - why the heck does it do strchr() twice
       - it casts a const char * over into char *
       - sloppy style
       - it's not even a regression fix!
      
      So lets revert it and re-try the patch in v3.13.
      Reported-by: NMarkus Trippelsdorf <markus@trippelsdorf.de>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      14951f22
  5. 25 9月, 2013 1 次提交
  6. 19 9月, 2013 1 次提交
  7. 08 8月, 2013 3 次提交
    • A
      perf symbols: Add support for reading from /proc/kcore · 8e0cf965
      Adrian Hunter 提交于
      In the absence of vmlinux, perf tools uses kallsyms for symbols.  If the
      user has access, now also map to /proc/kcore.
      
      The dso data_type is now set to either DSO_BINARY_TYPE__KCORE or
      DSO_BINARY_TYPE__GUEST_KCORE as approprite.
      
      This patch breaks the "vmlinux symtab matches kallsyms" test.  That is
      fixed in a following patch.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1375875537-4509-8-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8e0cf965
    • A
      perf tools: Make it possible to read object code from kernel modules · 0131c4ec
      Adrian Hunter 提交于
      The new "object code reading" test shows that it is not possible to read
      object code from kernel modules.  That is because the mappings do not
      map to the dsos.  This patch fixes that.
      
      This involves identifying and flagging relocatable (ELF type ET_REL)
      files (e.g. kernel modules) for symbol adjustment and updating
      map__rip_2objdump() accordingly.  The kmodule parameter of
      dso__load_sym() is taken into use and the module map altered to map to
      the dso.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1375875537-4509-7-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0131c4ec
    • A
      perf tools: Make it possible to read object code from vmlinux · 39b12f78
      Adrian Hunter 提交于
      The new "object code reading" test shows that it is not possible to read
      object code from vmlinux.  That is because the mappings do not map to
      the dso.  This patch fixes that.
      
      A side-effect of changing the kernel map is that the "reloc" offset must
      be taken into account.  As a result of that separate map functions for
      relocation are no longer needed.
      
      Also fixing up the maps to match the symbols no longer makes sense and
      so is not done.
      
      The vmlinux dso data_type is now set to either DSO_BINARY_TYPE__VMLINUX
      or DSO_BINARY_TYPE__GUEST_VMLINUX as approprite, which enables the
      correct file name to be determined by dso__binary_type_file().
      
      This patch breaks the "vmlinux symtab matches kallsyms" test.  That is
      fixed in a following patch.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1375875537-4509-4-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      39b12f78
  8. 27 3月, 2013 1 次提交
  9. 25 1月, 2013 1 次提交
  10. 09 12月, 2012 1 次提交
  11. 20 8月, 2012 1 次提交
    • D
      perf symbols: Fix builds with NO_LIBELF set · f47b58b7
      David Ahern 提交于
      Build currently fails:
        $ make -C tools/perf O=/tmp/pbuild NO_LIBELF=1
      
        util/symbol.c: In function ‘dso__load’:
        util/symbol.c:1128:27: error: ‘struct symsrc’ has no member named ‘dynsym’
            CC /tmp/pbuild/util/pager.o
        make: *** [/tmp/pbuild/util/symbol.o] Error 1
        make: *** Waiting for unfinished jobs....
      
      Moving the dynsym reference to symbol-elf.c reveals that NO_LIBELF requires
      NO_LIBUNWIND:
      
        $ make -C tools/perf O=/tmp/pbuild NO_LIBELF=1
      
            LINK /tmp/pbuild/perf
        /tmp/pbuild/libperf.a(unwind.o): In function `elf_section_offset':
        /opt/sw/ahern/perf.git/tools/perf/util/unwind.c:176: undefined reference to `elf_begin'
        /opt/sw/ahern/perf.git/tools/perf/util/unwind.c:181: undefined reference to `gelf_getehdr'
        /tmp/pbuild/libperf.a(unwind.o): In function `elf_section_by_name':
        /opt/sw/ahern/perf.git/tools/perf/util/unwind.c:157: undefined reference to `elf_nextscn'
        /opt/sw/ahern/perf.git/tools/perf/util/unwind.c:160: undefined reference to `gelf_getshdr'
        /opt/sw/ahern/perf.git/tools/perf/util/unwind.c:161: undefined reference to `elf_strptr'
        /tmp/pbuild/libperf.a(unwind.o): In function `elf_section_offset':
        /opt/sw/ahern/perf.git/tools/perf/util/unwind.c:190: undefined reference to `elf_end'
        /tmp/pbuild/libperf.a(unwind.o): In function `read_unwind_spec':
        /opt/sw/ahern/perf.git/tools/perf/util/unwind.c:190: undefined reference to `elf_end'
        collect2: ld returned 1 exit status
        make: *** [/tmp/pbuild/perf] Error 1
        make: Leaving directory `/opt/sw/ahern/perf.git/tools/perf'
      
      This patch fixes both.
      Reviewed-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NDavid Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1345391234-71906-1-git-send-email-dsahern@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f47b58b7
  12. 14 8月, 2012 7 次提交
    • C
      perf symbols: Use both runtime and debug images · 3aafe5ae
      Cody P Schafer 提交于
      We keep both a 'runtime' elf image as well as a 'debug' elf image around
      and generate symbols by looking at both of these.
      
      This eliminates the need for the want_symtab/goto restart mechanism
      combined with iterating over and reopening the elf images a second time.
      
      Also give dso__synthsize_plt_symbols() the runtime image (which has
      dynsyms) instead of the symbol image (which may only have a symtab and
      no dynsyms).
      
      Previously if a debug image was found all runtime images were ignored.
      
      This fixes 2 issues:
      
       - Symbol resolution to failure on PowerPC systems with debug symbols
         installed, as the debug images lack a '.opd' section which contains
         function descriptors.
      
       - On all archs, plt synthesis failed when a debug image was loaded and
         that debug image lacks a dynsym section while a runtime image has a
         dynsym section.
      
      Assumptions:
      
       - If a .opd section exists, it is contained in the highest priority
         image with a dynsym section.
      
       - This generally implies that the debug image lacks a dynsym section
         (ie: it is marked as NO_BITS).
      Signed-off-by: NCody P Schafer <cody@linux.vnet.ibm.com>
      Cc: David Hansen <dave@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Matt Hellsley <matthltc@us.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1344637382-22789-17-git-send-email-cody@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3aafe5ae
    • C
      perf symbols: Convert dso__load_syms to take 2 symsrc's · 261360b6
      Cody P Schafer 提交于
      To properly handle platforms with an opd section, both a runtime image
      (which contains the opd section but possibly lacks symbols) and a symbol
      image (which probably lacks an opd section but has symbols).
      
      The next patch ("perf symbol: use both runtime and debug images")
      adjusts the callsite in dso__load() to take advantage of being able to
      pass both runtime & debug images.
      
      Assumptions made here:
      
       - The opd section, if it exists in the runtime image, has headers in
         both the runtime image and the debug/syms image.
      
       - The index of the opd section (again, only if it exists in the runtime
         image) is the same in both the runtime and debug/symbols image.
      
      Both of these are true on RHEL, but it is unclear how accurate they are
      in general (on platforms with function descriptors in opd sections).
      Signed-off-by: NCody P Schafer <cody@linux.vnet.ibm.com>
      Cc: David Hansen <dave@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Matt Hellsley <matthltc@us.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1344637382-22789-16-git-send-email-cody@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      261360b6
    • C
      perf symbols: Factor want_symtab out of dso__load_sym() · d26cd12b
      Cody P Schafer 提交于
      Only one callsite of dso__load_sym() uses the want_symtab functionality,
      so place the logic at the callsite instead of within dso__load_sym().
      
      This sets us up for removal of want_symtab completely once we keep
      multiple elf handles (within symsrc's) around.
      
      Setup for the later patch
      
      "perf symbols: Use both runtime and debug images"
      Signed-off-by: NCody P Schafer <cody@linux.vnet.ibm.com>
      Cc: David Hansen <dave@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Matt Hellsley <matthltc@us.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1344637382-22789-15-git-send-email-cody@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d26cd12b
    • C
      perf symbols: Switch dso__synthesize_plt_symbols() to use symsrc · a44f605b
      Cody P Schafer 提交于
      Previously dso__synthesize_plt_symbols() was reopening the elf file to
      obtain dynsyms from it. Rather than reopen the file, use the already
      opened reference within the symsrc to access it.
      
      Setup for the later patch
      
      "perf symbols: Use both runtime and debug images"
      Signed-off-by: NCody P Schafer <cody@linux.vnet.ibm.com>
      Cc: David Hansen <dave@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Matt Hellsley <matthltc@us.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1344637382-22789-14-git-send-email-cody@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a44f605b
    • C
      perf symbols: Set symtab_type in dso__load_sym · 005f9294
      Cody P Schafer 提交于
      In certain cases, dso__load requires dso->symbol_type to be set prior to
      calling it. With the introduction of symsrc*, the symtab_type is now
      stored in a symsrc which is then passed to dso__load_sym().
      
      Change dso__load_sym() to use the symtab_type from them symsrc (setting
      dso->symtab_type as well).
      
      Setup for later patch
      
      "perf symbols: Use both runtime and debug images"
      Signed-off-by: NCody P Schafer <cody@linux.vnet.ibm.com>
      Cc: David Hansen <dave@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Matt Hellsley <matthltc@us.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1344637382-22789-13-git-send-email-cody@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      005f9294
    • C
      perf symbols: Introduce symsrc structure. · b68e2f91
      Cody P Schafer 提交于
      Factors opening of certain sections & tracking certain elf info into an
      external structure.
      
      The goal here is to keep multiple elfs (and their looked up
      sections/indexes) around during the symbol generation process (in
      dso__load()).
      
      We need this to properly resolve symbols on PPC due to the use of
      function descriptors & the .opd section (ie: symbols which are functions
      don't point to their actual location, they point to their function
      descriptor in .opd which contains their actual location.
      
      It would be possible to just keep the (Elf *) around, but then we'd end
      up with duplicate code for looking up the same sections and checking for
      the existence of an important section wouldn't be as clean (and we need
      to keep the Elf stuff confined to symtab-elf.c).
      
      Utilized by the later patch
      "perf symbols: Use both runtime and debug images"
      Signed-off-by: NCody P Schafer <cody@linux.vnet.ibm.com>
      Cc: David Hansen <dave@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Matt Hellsley <matthltc@us.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1344637382-22789-12-git-send-email-cody@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b68e2f91
    • C
      perf symbols: Avoid segfault in elf_strptr · 49274654
      Cody P Schafer 提交于
      If we call elf_section_by_name() with a truncated elf image (ie: the
      file header indicates that the section headers are placed past the end
      of the file), elf_strptr() causes a segfault within libelf.
      
      Avoid this by checking that we can access the section string table
      properly.
      
      Should really be fixed in libelf/elfutils.
      Signed-off-by: NCody P Schafer <cody@linux.vnet.ibm.com>
      Cc: David Hansen <dave@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Matt Hellsley <matthltc@us.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1344637382-22789-10-git-send-email-cody@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      49274654
  13. 13 8月, 2012 2 次提交
  14. 10 8月, 2012 1 次提交