Mercurial > vim
comparison src/debugger.c @ 23717:e3720756acdc v8.2.2400
patch 8.2.2400: Vim9: compiled functions are not profiled
Commit: https://github.com/vim/vim/commit/b204990346ca857802b174afe8a7fbb05e4f318e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 24 12:53:53 2021 +0100
patch 8.2.2400: Vim9: compiled functions are not profiled
Problem: Vim9: compiled functions are not profiled.
Solution: Add initial changes to profile compiled functions. Fix that a
script-local function was hard to debug.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 24 Jan 2021 13:00:06 +0100 |
parents | a607f02fd17a |
children | d12ef361d9de |
comparison
equal
deleted
inserted
replaced
23716:777aaba7c0ef | 23717:e3720756acdc |
---|---|
862 /* | 862 /* |
863 * Common code for dbg_find_breakpoint() and has_profiling(). | 863 * Common code for dbg_find_breakpoint() and has_profiling(). |
864 */ | 864 */ |
865 static linenr_T | 865 static linenr_T |
866 debuggy_find( | 866 debuggy_find( |
867 int file, // TRUE for a file, FALSE for a function | 867 int is_file, // TRUE for a file, FALSE for a function |
868 char_u *fname, // file or function name | 868 char_u *fname, // file or function name |
869 linenr_T after, // after this line number | 869 linenr_T after, // after this line number |
870 garray_T *gap, // either &dbg_breakp or &prof_ga | 870 garray_T *gap, // either &dbg_breakp or &prof_ga |
871 int *fp) // if not NULL: return forceit | 871 int *fp) // if not NULL: return forceit |
872 { | 872 { |
873 struct debuggy *bp; | 873 struct debuggy *bp; |
874 int i; | 874 int i; |
875 linenr_T lnum = 0; | 875 linenr_T lnum = 0; |
876 char_u *name = fname; | 876 char_u *name = NULL; |
877 char_u *short_name = fname; | |
877 int prev_got_int; | 878 int prev_got_int; |
878 | 879 |
879 // Return quickly when there are no breakpoints. | 880 // Return quickly when there are no breakpoints. |
880 if (gap->ga_len == 0) | 881 if (gap->ga_len == 0) |
881 return (linenr_T)0; | 882 return (linenr_T)0; |
882 | 883 |
883 // Replace K_SNR in function name with "<SNR>". | 884 // For a script-local function remove the prefix, so that |
884 if (!file && fname[0] == K_SPECIAL) | 885 // "profile func Func" matches "Func" in any script. Otherwise it's very |
885 { | 886 // difficult to profile/debug a script-local function. It may match a |
887 // function in the wrong script, but that is much better than not being | |
888 // able to profile/debug a function in a script with unknown ID. | |
889 // Also match a script-specific name. | |
890 if (!is_file && fname[0] == K_SPECIAL) | |
891 { | |
892 short_name = vim_strchr(fname, '_') + 1; | |
886 name = alloc(STRLEN(fname) + 3); | 893 name = alloc(STRLEN(fname) + 3); |
887 if (name == NULL) | 894 if (name != NULL) |
888 name = fname; | |
889 else | |
890 { | 895 { |
891 STRCPY(name, "<SNR>"); | 896 STRCPY(name, "<SNR>"); |
892 STRCPY(name + 5, fname + 3); | 897 STRCPY(name + 5, fname + 3); |
893 } | 898 } |
894 } | 899 } |
896 for (i = 0; i < gap->ga_len; ++i) | 901 for (i = 0; i < gap->ga_len; ++i) |
897 { | 902 { |
898 // Skip entries that are not useful or are for a line that is beyond | 903 // Skip entries that are not useful or are for a line that is beyond |
899 // an already found breakpoint. | 904 // an already found breakpoint. |
900 bp = &DEBUGGY(gap, i); | 905 bp = &DEBUGGY(gap, i); |
901 if (((bp->dbg_type == DBG_FILE) == file && | 906 if (((bp->dbg_type == DBG_FILE) == is_file |
902 bp->dbg_type != DBG_EXPR && ( | 907 && bp->dbg_type != DBG_EXPR && ( |
903 #ifdef FEAT_PROFILE | 908 #ifdef FEAT_PROFILE |
904 gap == &prof_ga || | 909 gap == &prof_ga || |
905 #endif | 910 #endif |
906 (bp->dbg_lnum > after && (lnum == 0 || bp->dbg_lnum < lnum))))) | 911 (bp->dbg_lnum > after && (lnum == 0 || bp->dbg_lnum < lnum))))) |
907 { | 912 { |
908 // Save the value of got_int and reset it. We don't want a | 913 // Save the value of got_int and reset it. We don't want a |
909 // previous interruption cancel matching, only hitting CTRL-C | 914 // previous interruption cancel matching, only hitting CTRL-C |
910 // while matching should abort it. | 915 // while matching should abort it. |
911 prev_got_int = got_int; | 916 prev_got_int = got_int; |
912 got_int = FALSE; | 917 got_int = FALSE; |
913 if (vim_regexec_prog(&bp->dbg_prog, FALSE, name, (colnr_T)0)) | 918 if ((name != NULL |
919 && vim_regexec_prog(&bp->dbg_prog, FALSE, name, (colnr_T)0)) | |
920 || vim_regexec_prog(&bp->dbg_prog, FALSE, | |
921 short_name, (colnr_T)0)) | |
914 { | 922 { |
915 lnum = bp->dbg_lnum; | 923 lnum = bp->dbg_lnum; |
916 if (fp != NULL) | 924 if (fp != NULL) |
917 *fp = bp->dbg_forceit; | 925 *fp = bp->dbg_forceit; |
918 } | 926 } |