Lines Matching refs:s
45 let s:way = 'terminal'
47 let s:way = 'prompt'
50 let s:err = 'Cannot debug, missing prompt buffer support'
52 let s:err = 'Cannot debug, +channel feature is not supported'
54 command -nargs=* -complete=file -bang Termdebug echoerr s:err
55 command -nargs=+ -complete=file -bang TermdebugCommand echoerr s:err
59 let s:keepcpo = &cpo
64 command -nargs=* -complete=file -bang Termdebug call s:StartDebug(<bang>0, <f-args>)
65 command -nargs=+ -complete=file -bang TermdebugCommand call s:StartDebugCommand(<bang>0, <f-args>)
72 let s:pc_id = 12
73 let s:asm_id = 13
74 let s:break_id = 14 " breakpoint number is added to this
75 let s:stopped = 1
77 let s:parsing_disasm_msg = 0
78 let s:asm_lines = []
79 let s:asm_addr = ''
84 func s:Breakpoint2SignNumber(id, subid)
85 return s:break_id + a:id * 1000 + a:subid
88 func s:Highlight(init, old, new)
97 call s:Highlight(1, '', &background)
100 func s:StartDebug(bang, ...)
102 call s:StartDebug_internal({'gdb_args': a:000, 'bang': a:bang})
105 func s:StartDebugCommand(bang, ...)
107 call s:StartDebug_internal({'gdb_args': [a:1], 'proc_args': a:000[1:], 'bang': a:bang})
110 func s:StartDebug_internal(dict)
111 if exists('s:gdbwin')
120 let s:ptywin = 0
121 let s:pid = 0
122 let s:asmwin = 0
131 let s:sourcewin = win_getid(winnr())
133 " Remember the old value of 'signcolumn' for each buffer that it's set in, so
136 let s:signcolumn_buflist = [bufnr()]
138 let s:save_columns = 0
139 let s:allleft = 0
142 let s:save_columns = &columns
146 let s:allleft = 1
148 let s:vertical = 1
150 let s:vertical = 0
156 let s:way = 'terminal'
158 let s:way = 'prompt'
161 if s:way == 'prompt'
162 call s:StartDebug_prompt(a:dict)
164 call s:StartDebug_term(a:dict)
170 call s:GotoAsmwinOrCreateIt()
181 func s:CloseBuffers()
182 exe 'bwipe! ' . s:ptybuf
183 exe 'bwipe! ' . s:commbuf
184 unlet! s:gdbwin
187 func s:CheckGdbRunning()
188 let gdbproc = term_getjob(s:gdbbuf)
191 call s:CloseBuffers()
197 func s:StartDebug_term(dict)
199 let s:ptybuf = term_start('NONE', {
201 \ 'vertical': s:vertical,
203 if s:ptybuf == 0
207 let pty = job_info(term_getjob(s:ptybuf))['tty_out']
208 let s:ptywin = win_getid(winnr())
209 if s:vertical
213 if s:allleft
220 let s:commbuf = term_start('NONE', {
222 \ 'out_cb': function('s:CommOutput'),
225 if s:commbuf == 0
227 exe 'bwipe! ' . s:ptybuf
230 let commpty = job_info(term_getjob(s:commbuf))['tty_out']
239 let s:gdbbuf = term_start(cmd, {
242 if s:gdbbuf == 0
244 call s:CloseBuffers()
247 let s:gdbwin = win_getid(winnr())
252 if s:CheckGdbRunning() != 'ok'
257 if term_getline(s:gdbbuf, lnum) =~ 'startupdone'
272 call term_sendkeys(s:gdbbuf, 'set args ' . join(proc_args) . "\r")
276 call term_sendkeys(s:gdbbuf, 'new-ui mi ' . commpty . "\r")
282 if s:CheckGdbRunning() != 'ok'
288 let line1 = term_getline(s:gdbbuf, lnum)
289 let line2 = term_getline(s:gdbbuf, lnum + 1)
295 call s:CloseBuffers()
321 call s:SendCommand('-gdb-set mi-async on')
323 call s:SendCommand('-gdb-set target-async on')
327 call s:SendCommand('set pagination off')
329 call job_setoptions(term_getjob(s:gdbbuf), {'exit_cb': function('s:EndTermDebug')})
334 call s:StartDebugCommon(a:dict)
337 func s:StartDebug_prompt(dict)
339 if s:vertical
344 let s:gdbwin = win_getid(winnr())
345 let s:promptbuf = bufnr('')
346 call prompt_setprompt(s:promptbuf, 'gdb> ')
349 call prompt_setcallback(s:promptbuf, function('s:PromptCallback'))
350 call prompt_setinterrupt(s:promptbuf, function('s:PromptInterrupt'))
352 if s:vertical
365 let s:gdbjob = job_start(cmd, {
366 \ 'exit_cb': function('s:EndPromptDebug'),
367 \ 'out_cb': function('s:GdbOutCallback'),
369 if job_status(s:gdbjob) != "run"
371 exe 'bwipe! ' . s:promptbuf
374 " Mark the buffer modified so that it's not easy to close.
376 let s:gdb_channel = job_getchannel(s:gdbjob)
381 call s:SendCommand('-gdb-set mi-async on')
383 call s:SendCommand('-gdb-set target-async on')
385 let s:ptybuf = 0
388 call s:SendCommand('set new-console on')
392 belowright let s:ptybuf = term_start('NONE', {
395 if s:ptybuf == 0
397 call job_stop(s:gdbjob)
400 let s:ptywin = win_getid(winnr())
401 let pty = job_info(term_getjob(s:ptybuf))['tty_out']
402 call s:SendCommand('tty ' . pty)
406 call s:SendCommand('set env TERM = xterm-color')
407 call s:SendCommand('set env ROWS = ' . winheight(s:ptywin))
408 call s:SendCommand('set env LINES = ' . winheight(s:ptywin))
409 call s:SendCommand('set env COLUMNS = ' . winwidth(s:ptywin))
410 call s:SendCommand('set env COLORS = ' . &t_Co)
411 call s:SendCommand('set env VIM_TERMINAL = ' . v:version)
414 call s:SendCommand('show inferior-tty')
416 call s:SendCommand('set print pretty on')
417 call s:SendCommand('set breakpoint pending on')
419 call s:SendCommand('set pagination off')
423 call s:SendCommand('set args ' . join(proc_args))
426 call s:StartDebugCommon(a:dict)
430 func s:StartDebugCommon(dict)
436 call win_gotoid(s:sourcewin)
437 call s:InstallCommands()
438 call win_gotoid(s:gdbwin)
458 let s:breakpoints = {}
462 let s:breakpoint_locations = {}
465 au BufRead * call s:BufRead()
466 au BufUnload * call s:BufUnloaded()
467 au OptionSet background call s:Highlight(0, v:option_old, v:option_new)
473 call s:SendCommand('-exec-run')
474 call win_gotoid(s:ptywin)
479 func s:SendCommand(cmd)
481 if s:way == 'prompt'
482 call ch_sendraw(s:gdb_channel, a:cmd . "\n")
484 call term_sendkeys(s:commbuf, a:cmd . "\r")
490 if s:way == 'prompt'
491 call ch_sendraw(s:gdb_channel, a:cmd . "\n")
494 if !s:stopped
496 call s:SendCommand('-exec-interrupt')
499 call term_sendkeys(s:gdbbuf, a:cmd . "\r")
507 func s:PromptCallback(text)
508 call s:SendCommand(a:text)
513 func s:PromptInterrupt()
518 if s:pid == 0
521 call debugbreak(s:pid)
524 call job_stop(s:gdbjob, 'int')
529 func s:GdbOutCallback(channel, text)
538 let text = s:DecodeMessage(a:text[11:])
539 …if exists('s:evalexpr') && text =~ 'A syntax error in expression, near\|No symbol .* in current co…
541 unlet s:evalexpr
545 let text = s:DecodeMessage(a:text[1:])
547 call s:CommOutput(a:channel, a:text)
552 call win_gotoid(s:gdbwin)
563 func s:DecodeMessage(quotedText)
591 func s:GetFullname(msg)
595 let name = s:DecodeMessage(substitute(a:msg, '.*fullname=', '', ''))
604 func s:GetAsmAddr(msg)
608 let addr = s:DecodeMessage(substitute(a:msg, '.*addr=', '', ''))
612 func s:EndTermDebug(job, status)
617 exe 'bwipe! ' . s:commbuf
618 unlet s:gdbwin
620 call s:EndDebugCommon()
623 func s:EndDebugCommon()
626 if exists('s:ptybuf') && s:ptybuf
627 exe 'bwipe! ' . s:ptybuf
631 call win_gotoid(s:sourcewin)
633 for bufnr in s:signcolumn_buflist
644 call s:DeleteCommands()
648 if s:save_columns > 0
649 let &columns = s:save_columns
669 func s:EndPromptDebug(job, status)
675 call win_gotoid(s:gdbwin)
678 if curwinid != s:gdbwin
682 call s:EndDebugCommon()
683 unlet s:gdbwin
703 func s:HandleDisasmMsg(msg)
706 if win_gotoid(s:asmwin)
708 call setline(1, s:asm_lines)
712 let lnum = search('^' . s:asm_addr)
714 exe 'sign unplace ' . s:asm_id
715 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC'
721 let s:parsing_disasm_msg = 0
722 let s:asm_lines = []
724 if s:parsing_disasm_msg == 1
726 " find the function frame address, so let's try to disassemble starting
728 call s:SendCommand('disassemble $pc,+100')
730 let s:parsing_disasm_msg = 0
734 let s:parsing_disasm_msg = 2
744 if value != '' || !empty(s:asm_lines)
745 call add(s:asm_lines, value)
751 func s:CommOutput(chan, msg)
760 if s:parsing_disasm_msg
761 call s:HandleDisasmMsg(msg)
764 call s:HandleCursor(msg)
766 call s:HandleNewBreakpoint(msg)
768 call s:HandleBreakpointDelete(msg)
770 call s:HandleProgramRun(msg)
772 call s:HandleEvaluate(msg)
774 call s:HandleError(msg)
776 let s:parsing_disasm_msg = 1
777 let s:asm_lines = []
783 func s:GotoProgram()
786 …AssemblyName microsoft.VisualBasic;[Microsoft.VisualBasic.Interaction]::AppActivate(%d);"', s:pid))
789 call win_gotoid(s:ptywin)
794 func s:InstallCommands()
798 command -nargs=? Break call s:SetBreakpoint(<q-args>)
799 command Clear call s:ClearBreakpoint()
800 command Step call s:SendCommand('-exec-step')
801 command Over call s:SendCommand('-exec-next')
802 command Finish call s:SendCommand('-exec-finish')
803 command -nargs=* Run call s:Run(<q-args>)
804 command -nargs=* Arguments call s:SendCommand('-exec-arguments ' . <q-args>)
805 command Stop call s:SendCommand('-exec-interrupt')
808 if s:way == 'prompt'
809 command Continue call s:SendCommand('continue')
811 command Continue call term_sendkeys(s:gdbbuf, "continue\r")
814 command -range -nargs=* Evaluate call s:Evaluate(<range>, <q-args>)
815 command Gdb call win_gotoid(s:gdbwin)
816 command Program call s:GotoProgram()
817 command Source call s:GotoSourcewinOrCreateIt()
818 command Asm call s:GotoAsmwinOrCreateIt()
819 command Winbar call s:InstallWinbar()
822 let s:k_map_saved = maparg('K', 'n', 0, 1)
827 call s:InstallWinbar()
830 let s:saved_mousemodel = &mousemodel
842 let s:winbar_winids = []
845 func s:InstallWinbar()
853 call add(s:winbar_winids, win_getid(winnr()))
858 func s:DeleteCommands()
875 if exists('s:k_map_saved')
876 if empty(s:k_map_saved)
879 call mapset('n', 0, s:k_map_saved)
881 unlet s:k_map_saved
887 for winid in s:winbar_winids
898 let s:winbar_winids = []
900 if exists('s:saved_mousemodel')
901 let &mousemodel = s:saved_mousemodel
902 unlet s:saved_mousemodel
910 exe 'sign unplace ' . s:pc_id
911 for [id, entries] in items(s:breakpoints)
913 exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
916 unlet s:breakpoints
917 unlet s:breakpoint_locations
920 for val in s:BreakpointSigns
923 let s:BreakpointSigns = []
927 func s:SetBreakpoint(at)
931 if !s:stopped
933 if s:way == 'prompt'
934 call s:PromptInterrupt()
936 call s:SendCommand('-exec-interrupt')
944 call s:SendCommand('-break-insert ' . at)
946 call s:SendCommand('-exec-continue')
951 func s:ClearBreakpoint()
954 let bploc = printf('%s:%d', fname, lnum)
955 if has_key(s:breakpoint_locations, bploc)
957 for id in s:breakpoint_locations[bploc]
958 if has_key(s:breakpoints, id)
960 call s:SendCommand('-break-delete ' . id)
961 for subid in keys(s:breakpoints[id])
962 exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
964 unlet s:breakpoints[id]
965 unlet s:breakpoint_locations[bploc][idx]
971 if empty(s:breakpoint_locations[bploc])
972 unlet s:breakpoint_locations[bploc]
977 func s:Run(args)
979 call s:SendCommand('-exec-arguments ' . a:args)
981 call s:SendCommand('-exec-run')
984 func s:SendEval(expr)
999 call s:SendCommand('-data-evaluate-expression "' . expr . '"')
1000 let s:evalexpr = expr
1004 func s:Evaluate(range, arg)
1018 let s:ignoreEvalError = 0
1019 call s:SendEval(expr)
1022 let s:ignoreEvalError = 0
1023 let s:evalFromBalloonExpr = 0
1026 func s:HandleEvaluate(msg)
1029 if s:evalFromBalloonExpr
1030 if s:evalFromBalloonExprResult == ''
1031 let s:evalFromBalloonExprResult = s:evalexpr . ': ' . value
1033 let s:evalFromBalloonExprResult .= ' = ' . value
1035 call balloon_show(s:evalFromBalloonExprResult)
1037 echomsg '"' . s:evalexpr . '": ' . value
1040 if s:evalexpr[0] != '*' && value =~ '^0x' && value != '0x0' && value !~ '"$'
1042 let s:ignoreEvalError = 1
1043 call s:SendEval('*' . s:evalexpr)
1045 let s:evalFromBalloonExpr = 0
1052 if v:beval_winid != s:sourcewin
1055 if !s:stopped
1060 let s:evalFromBalloonExpr = 1
1061 let s:evalFromBalloonExprResult = ''
1062 let s:ignoreEvalError = 1
1063 call s:SendEval(v:beval_text)
1068 func s:HandleError(msg)
1069 if s:ignoreEvalError
1070 " Result of s:SendEval() failed, ignore.
1071 let s:ignoreEvalError = 0
1072 let s:evalFromBalloonExpr = 0
1079 func s:GotoSourcewinOrCreateIt()
1080 if !win_gotoid(s:sourcewin)
1082 let s:sourcewin = win_getid(winnr())
1083 call s:InstallWinbar()
1087 func s:GotoAsmwinOrCreateIt()
1088 if !win_gotoid(s:asmwin)
1089 if win_gotoid(s:sourcewin)
1095 let s:asmwin = win_getid(winnr())
1117 if s:asm_addr != ''
1118 let lnum = search('^' . s:asm_addr)
1120 if s:stopped
1121 call s:SendCommand('disassemble $pc')
1124 exe 'sign unplace ' . s:asm_id
1125 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC'
1132 func s:HandleCursor(msg)
1137 let s:stopped = 1
1140 let s:stopped = 0
1144 let fname = s:GetFullname(a:msg)
1150 let asm_addr = s:GetAsmAddr(a:msg)
1152 let s:asm_addr = asm_addr
1155 if win_gotoid(s:asmwin)
1156 let lnum = search('^' . s:asm_addr)
1158 call s:SendCommand('disassemble $pc')
1160 exe 'sign unplace ' . s:asm_id
1161 exe 'sign place ' . s:asm_id . ' line=' . lnum . ' name=debugPC'
1172 call s:GotoSourcewinOrCreateIt()
1177 let s:sourcewin = win_getid(winnr())
1178 call s:InstallWinbar()
1185 exe 'sign unplace ' . s:pc_id
1186 exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC priority=110 file=' . fname
1189 call add(s:signcolumn_buflist, bufnr())
1193 elseif !s:stopped || fname != ''
1194 exe 'sign unplace ' . s:pc_id
1200 let s:BreakpointSigns = []
1202 func s:CreateBreakpoint(id, subid)
1204 if index(s:BreakpointSigns, nr) == -1
1205 call add(s:BreakpointSigns, nr)
1210 func! s:SplitMsg(s) argument
1211 return split(a:s, '{.\{-}}\zs')
1216 func s:HandleNewBreakpoint(msg)
1221 for msg in s:SplitMsg(a:msg)
1222 let fname = s:GetFullname(msg)
1234 call s:CreateBreakpoint(id, subid)
1236 if has_key(s:breakpoints, id)
1237 let entries = s:breakpoints[id]
1240 let s:breakpoints[id] = entries
1253 let bploc = printf('%s:%d', fname, lnum)
1254 if !has_key(s:breakpoint_locations, bploc)
1255 let s:breakpoint_locations[bploc] = []
1257 let s:breakpoint_locations[bploc] += [id]
1260 call s:PlaceSign(id, subid, entry)
1265 func s:PlaceSign(id, subid, entry)
1267 …exe 'sign place ' . s:Breakpoint2SignNumber(a:id, a:subid) . ' line=' . a:entry['lnum'] . ' name=d…
1273 func s:HandleBreakpointDelete(msg)
1278 if has_key(s:breakpoints, id)
1279 for [subid, entry] in items(s:breakpoints[id])
1281 exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid)
1285 unlet s:breakpoints[id]
1290 " Will store the process ID in s:pid
1291 func s:HandleProgramRun(msg)
1296 let s:pid = nr
1297 call ch_log('Detected process ID: ' . s:pid)
1301 func s:BufRead()
1303 for [id, entries] in items(s:breakpoints)
1306 call s:PlaceSign(id, subid, entry)
1313 func s:BufUnloaded()
1315 for [id, entries] in items(s:breakpoints)
1324 let &cpo = s:keepcpo
1325 unlet s:keepcpo