comparison runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @ 28141:dce918af0c00

Update runtime files Commit: https://github.com/vim/vim/commit/47c532e2bc55e8a48f7f47e1fae1ed30144f2fa1 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 19 15:18:53 2022 +0000 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Sat, 19 Mar 2022 16:30:05 +0100
parents 3649b5a6b1b6
children f73a9bdff3a3
comparison
equal deleted inserted replaced
28140:4511c6ef2893 28141:dce918af0c00
2 " 2 "
3 " Author: Bram Moolenaar 3 " Author: Bram Moolenaar
4 " Copyright: Vim license applies, see ":help license" 4 " Copyright: Vim license applies, see ":help license"
5 " Last Change: 2022 Jan 17 5 " Last Change: 2022 Jan 17
6 " 6 "
7 " WORK IN PROGRESS - Only the basics work 7 " WORK IN PROGRESS - The basics works stable, more to come
8 " Note: On MS-Windows you need a recent version of gdb. The one included with 8 " Note: In general you need at least GDB 7.12 because this provides the
9 " MingW is too old (7.6.1). 9 " frame= response in MI thread-selected events we need to sync stack to file.
10 " I used version 7.12 from http://www.equation.com/servlet/equation.cmd?fa=gdb 10 " The one included with "old" MingW is too old (7.6.1), you may upgrade it or
11 " use a newer version from http://www.equation.com/servlet/equation.cmd?fa=gdb
11 " 12 "
12 " There are two ways to run gdb: 13 " There are two ways to run gdb:
13 " - In a terminal window; used if possible, does not work on MS-Windows 14 " - In a terminal window; used if possible, does not work on MS-Windows
14 " Not used when g:termdebug_use_prompt is set to 1. 15 " Not used when g:termdebug_use_prompt is set to 1.
15 " - Using a "prompt" buffer; may use a terminal window for the program 16 " - Using a "prompt" buffer; may use a terminal window for the program
311 if line1 =~ 'new-ui mi ' 312 if line1 =~ 'new-ui mi '
312 " response can be in the same line or the next line 313 " response can be in the same line or the next line
313 let response = line1 . line2 314 let response = line1 . line2
314 if response =~ 'Undefined command' 315 if response =~ 'Undefined command'
315 echoerr 'Sorry, your gdb is too old, gdb 7.12 is required' 316 echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
316 " CHECKME: possibly send a "server show version" here 317 " CHECKME: possibly send a "server show version" here
317 call s:CloseBuffers() 318 call s:CloseBuffers()
318 return 319 return
319 endif 320 endif
320 if response =~ 'New UI allocated' 321 if response =~ 'New UI allocated'
321 " Success! 322 " Success!
394 exe 'bwipe! ' . s:promptbuf 395 exe 'bwipe! ' . s:promptbuf
395 return 396 return
396 endif 397 endif
397 " Mark the buffer modified so that it's not easy to close. 398 " Mark the buffer modified so that it's not easy to close.
398 set modified 399 set modified
399 let s:gdb_channel = job_getchannel(s:gdbjob) 400 let s:gdb_channel = job_getchannel(s:gdbjob)
400 401
401 let s:ptybuf = 0 402 let s:ptybuf = 0
402 if has('win32') 403 if has('win32')
403 " MS-Windows: run in a new console window for maximum compatibility 404 " MS-Windows: run in a new console window for maximum compatibility
404 call s:SendCommand('set new-console on') 405 call s:SendCommand('set new-console on')
660 let was_buf = bufnr() 661 let was_buf = bufnr()
661 for bufnr in s:signcolumn_buflist 662 for bufnr in s:signcolumn_buflist
662 if bufexists(bufnr) 663 if bufexists(bufnr)
663 exe bufnr .. "buf" 664 exe bufnr .. "buf"
664 if exists('b:save_signcolumn') 665 if exists('b:save_signcolumn')
665 let &signcolumn = b:save_signcolumn 666 let &signcolumn = b:save_signcolumn
666 unlet b:save_signcolumn 667 unlet b:save_signcolumn
667 endif 668 endif
668 endif 669 endif
669 endfor 670 endfor
670 exe was_buf .. "buf" 671 exe was_buf .. "buf"
671 672
737 set nomodified 738 set nomodified
738 set filetype=asm 739 set filetype=asm
739 740
740 let lnum = search('^' . s:asm_addr) 741 let lnum = search('^' . s:asm_addr)
741 if lnum != 0 742 if lnum != 0
742 exe 'sign unplace ' . s:asm_id 743 exe 'sign unplace ' . s:asm_id
743 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC' 744 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC'
744 endif 745 endif
745 746
746 call win_gotoid(curwinid) 747 call win_gotoid(curwinid)
747 endif 748 endif
748 749
787 788
788 if s:parsing_disasm_msg 789 if s:parsing_disasm_msg
789 call s:HandleDisasmMsg(msg) 790 call s:HandleDisasmMsg(msg)
790 elseif msg != '' 791 elseif msg != ''
791 if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)' 792 if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)'
792 call s:HandleCursor(msg) 793 call s:HandleCursor(msg)
793 elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,' 794 elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,'
794 call s:HandleNewBreakpoint(msg, 0) 795 call s:HandleNewBreakpoint(msg, 0)
795 elseif msg =~ '^=breakpoint-modified,' 796 elseif msg =~ '^=breakpoint-modified,'
796 call s:HandleNewBreakpoint(msg, 1) 797 call s:HandleNewBreakpoint(msg, 1)
797 elseif msg =~ '^=breakpoint-deleted,' 798 elseif msg =~ '^=breakpoint-deleted,'
798 call s:HandleBreakpointDelete(msg) 799 call s:HandleBreakpointDelete(msg)
799 elseif msg =~ '^=thread-group-started' 800 elseif msg =~ '^=thread-group-started'
800 call s:HandleProgramRun(msg) 801 call s:HandleProgramRun(msg)
801 elseif msg =~ '^\^done,value=' 802 elseif msg =~ '^\^done,value='
802 call s:HandleEvaluate(msg) 803 call s:HandleEvaluate(msg)
803 elseif msg =~ '^\^error,msg=' 804 elseif msg =~ '^\^error,msg='
804 call s:HandleError(msg) 805 call s:HandleError(msg)
805 elseif msg =~ '^disassemble' 806 elseif msg =~ '^disassemble'
806 let s:parsing_disasm_msg = 1 807 let s:parsing_disasm_msg = 1
807 let s:asm_lines = [] 808 let s:asm_lines = []
808 endif 809 endif
809 endif 810 endif
810 endfor 811 endfor
811 endfunc 812 endfunc
812 813
984 if has_key(s:breakpoint_locations, bploc) 985 if has_key(s:breakpoint_locations, bploc)
985 let idx = 0 986 let idx = 0
986 let nr = 0 987 let nr = 0
987 for id in s:breakpoint_locations[bploc] 988 for id in s:breakpoint_locations[bploc]
988 if has_key(s:breakpoints, id) 989 if has_key(s:breakpoints, id)
989 " Assume this always works, the reply is simply "^done". 990 " Assume this always works, the reply is simply "^done".
990 call s:SendCommand('-break-delete ' . id) 991 call s:SendCommand('-break-delete ' . id)
991 for subid in keys(s:breakpoints[id]) 992 for subid in keys(s:breakpoints[id])
992 exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid) 993 exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
993 endfor 994 endfor
994 unlet s:breakpoints[id] 995 unlet s:breakpoints[id]
995 unlet s:breakpoint_locations[bploc][idx] 996 unlet s:breakpoint_locations[bploc][idx]
996 let nr = id 997 let nr = id
997 break 998 break
998 else 999 else
999 let idx += 1 1000 let idx += 1
1000 endif 1001 endif
1001 endfor 1002 endfor
1002 if nr != 0 1003 if nr != 0
1003 if empty(s:breakpoint_locations[bploc]) 1004 if empty(s:breakpoint_locations[bploc])
1004 unlet s:breakpoint_locations[bploc] 1005 unlet s:breakpoint_locations[bploc]
1005 endif 1006 endif
1006 echomsg 'Breakpoint ' . id . ' cleared from line ' . lnum . '.' 1007 echomsg 'Breakpoint ' . id . ' cleared from line ' . lnum . '.'
1007 else 1008 else
1008 echoerr 'Internal error trying to remove breakpoint at line ' . lnum . '!' 1009 echoerr 'Internal error trying to remove breakpoint at line ' . lnum . '!'
1009 endif 1010 endif
1025 let exprLHS = a:expr 1026 let exprLHS = a:expr
1026 else 1027 else
1027 " remove text that is likely an assignment 1028 " remove text that is likely an assignment
1028 let exprLHS = substitute(a:expr, ' *=.*', '', '') 1029 let exprLHS = substitute(a:expr, ' *=.*', '', '')
1029 endif 1030 endif
1030 1031
1031 " encoding expression to prevent bad errors 1032 " encoding expression to prevent bad errors
1032 let expr = a:expr 1033 let expr = a:expr
1033 let expr = substitute(expr, '\\', '\\\\', 'g') 1034 let expr = substitute(expr, '\\', '\\\\', 'g')
1034 let expr = substitute(expr, '"', '\\"', 'g') 1035 let expr = substitute(expr, '"', '\\"', 'g')
1035 call s:SendCommand('-data-evaluate-expression "' . expr . '"') 1036 call s:SendCommand('-data-evaluate-expression "' . expr . '"')
1036 let s:evalexpr = exprLHS 1037 let s:evalexpr = exprLHS
1037 endfunc 1038 endfunc
1038 1039
1039 " :Evaluate - evaluate what is specified / under the cursor 1040 " :Evaluate - evaluate what is specified / under the cursor
1040 func s:Evaluate(range, arg) 1041 func s:Evaluate(range, arg)
1041 let expr = s:GetEvaluationExpression(a:range, a:arg) 1042 let expr = s:GetEvaluationExpression(a:range, a:arg)
1042 let s:ignoreEvalError = 0 1043 let s:ignoreEvalError = 0
1043 call s:SendEval(expr) 1044 call s:SendEval(expr)
1044 endfunc 1045 endfunc
1045 1046
1046 " get what is specified / under the cursor 1047 " get what is specified / under the cursor
1047 func s:GetEvaluationExpression(range, arg) 1048 func s:GetEvaluationExpression(range, arg)
1048 if a:arg != '' 1049 if a:arg != ''
1049 " user supplied evaluation 1050 " user supplied evaluation
1050 let expr = s:CleanupExpr(a:arg) 1051 let expr = s:CleanupExpr(a:arg)
1051 " DSW: replace "likely copy + paste" assignment 1052 " DSW: replace "likely copy + paste" assignment
1190 exe 'file Termdebug-asm-listing' 1191 exe 'file Termdebug-asm-listing'
1191 endif 1192 endif
1192 1193
1193 if exists('g:termdebug_disasm_window') 1194 if exists('g:termdebug_disasm_window')
1194 if g:termdebug_disasm_window > 1 1195 if g:termdebug_disasm_window > 1
1195 exe 'resize ' . g:termdebug_disasm_window 1196 exe 'resize ' . g:termdebug_disasm_window
1196 endif 1197 endif
1197 endif 1198 endif
1198 endif 1199 endif
1199 1200
1200 if s:asm_addr != '' 1201 if s:asm_addr != ''
1201 let lnum = search('^' . s:asm_addr) 1202 let lnum = search('^' . s:asm_addr)
1202 if lnum == 0 1203 if lnum == 0
1203 if s:stopped 1204 if s:stopped
1204 call s:SendCommand('disassemble $pc') 1205 call s:SendCommand('disassemble $pc')
1205 endif 1206 endif
1206 else 1207 else
1207 exe 'sign unplace ' . s:asm_id 1208 exe 'sign unplace ' . s:asm_id
1208 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC' 1209 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC'
1209 endif 1210 endif
1234 if asm_addr != '' 1235 if asm_addr != ''
1235 let s:asm_addr = asm_addr 1236 let s:asm_addr = asm_addr
1236 1237
1237 let curwinid = win_getid(winnr()) 1238 let curwinid = win_getid(winnr())
1238 if win_gotoid(s:asmwin) 1239 if win_gotoid(s:asmwin)
1239 let lnum = search('^' . s:asm_addr) 1240 let lnum = search('^' . s:asm_addr)
1240 if lnum == 0 1241 if lnum == 0
1241 call s:SendCommand('disassemble $pc') 1242 call s:SendCommand('disassemble $pc')
1242 else 1243 else
1243 exe 'sign unplace ' . s:asm_id 1244 exe 'sign unplace ' . s:asm_id
1244 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC' 1245 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC'
1245 endif 1246 endif
1246 1247
1247 call win_gotoid(curwinid) 1248 call win_gotoid(curwinid)
1248 endif 1249 endif
1249 endif 1250 endif
1250 endif 1251 endif
1251 1252
1252 if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname) 1253 if a:msg =~ '^\(\*stopped\|=thread-selected\)' && filereadable(fname)
1261 " The file may be changed but not saved, warn for that. 1262 " The file may be changed but not saved, warn for that.
1262 au SwapExists * echohl WarningMsg 1263 au SwapExists * echohl WarningMsg
1263 \ | echo 'Warning: file is being edited elsewhere' 1264 \ | echo 'Warning: file is being edited elsewhere'
1264 \ | echohl None 1265 \ | echohl None
1265 \ | let v:swapchoice = '0' 1266 \ | let v:swapchoice = '0'
1266 augroup END 1267 augroup END
1267 if &modified 1268 if &modified
1268 " TODO: find existing window 1269 " TODO: find existing window
1269 exe 'split ' . fnameescape(fname) 1270 exe 'split ' . fnameescape(fname)
1270 let s:sourcewin = win_getid(winnr()) 1271 let s:sourcewin = win_getid(winnr())
1271 call s:InstallWinbar() 1272 call s:InstallWinbar()
1272 else 1273 else
1273 exe 'edit ' . fnameescape(fname) 1274 exe 'edit ' . fnameescape(fname)
1274 endif 1275 endif
1275 augroup Termdebug 1276 augroup Termdebug
1276 au! SwapExists 1277 au! SwapExists
1277 augroup END 1278 augroup END
1278 endif 1279 endif
1279 exe lnum 1280 exe lnum
1280 normal! zv 1281 normal! zv
1281 exe 'sign unplace ' . s:pc_id 1282 exe 'sign unplace ' . s:pc_id
1282 exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC priority=110 file=' . fname 1283 exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC priority=110 file=' . fname
1283 if !exists('b:save_signcolumn') 1284 if !exists('b:save_signcolumn')
1284 let b:save_signcolumn = &signcolumn 1285 let b:save_signcolumn = &signcolumn
1285 call add(s:signcolumn_buflist, bufnr()) 1286 call add(s:signcolumn_buflist, bufnr())
1286 endif 1287 endif
1287 setlocal signcolumn=yes 1288 setlocal signcolumn=yes
1288 endif 1289 endif
1289 elseif !s:stopped || fname != '' 1290 elseif !s:stopped || fname != ''
1290 exe 'sign unplace ' . s:pc_id 1291 exe 'sign unplace ' . s:pc_id
1394 return 1395 return
1395 endif 1396 endif
1396 if has_key(s:breakpoints, id) 1397 if has_key(s:breakpoints, id)
1397 for [subid, entry] in items(s:breakpoints[id]) 1398 for [subid, entry] in items(s:breakpoints[id])
1398 if has_key(entry, 'placed') 1399 if has_key(entry, 'placed')
1399 exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid) 1400 exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
1400 unlet entry['placed'] 1401 unlet entry['placed']
1401 endif 1402 endif
1402 endfor 1403 endfor
1403 unlet s:breakpoints[id] 1404 unlet s:breakpoints[id]
1404 echomsg 'Breakpoint ' . id . ' cleared.' 1405 echomsg 'Breakpoint ' . id . ' cleared.'
1405 endif 1406 endif
1420 func s:BufRead() 1421 func s:BufRead()
1421 let fname = expand('<afile>:p') 1422 let fname = expand('<afile>:p')
1422 for [id, entries] in items(s:breakpoints) 1423 for [id, entries] in items(s:breakpoints)
1423 for [subid, entry] in items(entries) 1424 for [subid, entry] in items(entries)
1424 if entry['fname'] == fname 1425 if entry['fname'] == fname
1425 call s:PlaceSign(id, subid, entry) 1426 call s:PlaceSign(id, subid, entry)
1426 endif 1427 endif
1427 endfor 1428 endfor
1428 endfor 1429 endfor
1429 endfunc 1430 endfunc
1430 1431
1432 func s:BufUnloaded() 1433 func s:BufUnloaded()
1433 let fname = expand('<afile>:p') 1434 let fname = expand('<afile>:p')
1434 for [id, entries] in items(s:breakpoints) 1435 for [id, entries] in items(s:breakpoints)
1435 for [subid, entry] in items(entries) 1436 for [subid, entry] in items(entries)
1436 if entry['fname'] == fname 1437 if entry['fname'] == fname
1437 let entry['placed'] = 0 1438 let entry['placed'] = 0
1438 endif 1439 endif
1439 endfor 1440 endfor
1440 endfor 1441 endfor
1441 endfunc 1442 endfunc
1442 1443