blob: d4547ae9a6ce29d91aef23813a8b8724cd438771 [file] [log] [blame]
Bram Moolenaar543b7ef2013-06-01 14:50:56 +02001" Language: gprof
2" Maintainer: Dominique Pelle <dominique.pelle@gmail.com>
Bram Moolenaar56994d22021-04-17 16:31:09 +02003" Last Change: 2021 Apr 08
Bram Moolenaar543b7ef2013-06-01 14:50:56 +02004
5" When cursor is on one line of the gprof call graph,
6" calling this function jumps to this function in the call graph.
7if exists("b:did_ftplugin")
8 finish
9endif
10let b:did_ftplugin=1
11
12fun! <SID>GprofJumpToFunctionIndex()
13 let l:line = getline('.')
14 if l:line =~ '[\d\+\]$'
15 " We're in a line in the call graph.
Bram Moolenaarec7944a2013-06-12 21:29:15 +020016 norm! $y%
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020017 call search('^' . escape(@", '[]'), 'sw')
Bram Moolenaarec7944a2013-06-12 21:29:15 +020018 norm! zz
Bram Moolenaar56994d22021-04-17 16:31:09 +020019 elseif l:line =~ '^\(\s*[0-9\.]\+\)\{3}\s\+'
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020020 " We're in line in the flat profile.
Bram Moolenaarec7944a2013-06-12 21:29:15 +020021 norm! 55|eby$
22 call search('^\[\d\+\].*\d\s\+' . escape(@", '[]*.') . '\>', 'sW')
23 norm! zz
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020024 endif
25endfun
26
27" Pressing <C-]> on a line in the gprof flat profile or in
28" the call graph, jumps to the corresponding function inside
29" the flat profile.
Bram Moolenaarec7944a2013-06-12 21:29:15 +020030map <buffer> <silent> <C-]> :call <SID>GprofJumpToFunctionIndex()<CR>
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020031
32" vim:sw=2 fdm=indent