To: vim_dev@googlegroups.com Subject: Patch 8.1.2103 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2103 Problem: wrong error message if "termdebugger" is not executable. Solution: Check if "termdebugger" is executable and give a clear error message. (Ozaki Kiichi, closes #5000) Fix indents. Files: runtime/pack/dist/opt/termdebug/plugin/termdebug.vim *** ../vim-8.1.2102/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim 2019-09-04 14:24:01.910445794 +0200 --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim 2019-09-30 20:41:01.564339276 +0200 *************** *** 65,72 **** command -nargs=+ -complete=file -bang TermdebugCommand call s:StartDebugCommand(0, ) " Name of the gdb command, defaults to "gdb". ! if !exists('termdebugger') ! let termdebugger = 'gdb' endif let s:pc_id = 12 --- 65,72 ---- command -nargs=+ -complete=file -bang TermdebugCommand call s:StartDebugCommand(0, ) " Name of the gdb command, defaults to "gdb". ! if !exists('g:termdebugger') ! let g:termdebugger = 'gdb' endif let s:pc_id = 12 *************** *** 104,112 **** func s:StartDebug_internal(dict) if exists('s:gdbwin') ! echoerr 'Terminal debugger already running' return endif let s:ptywin = 0 let s:pid = 0 --- 104,117 ---- func s:StartDebug_internal(dict) if exists('s:gdbwin') ! echoerr 'Terminal debugger already running, cannot run two' return endif + if !executable(g:termdebugger) + echoerr 'Cannot execute debugger program "' .. g:termdebugger .. '"' + return + endif + let s:ptywin = 0 let s:pid = 0 *************** *** 156,164 **** func s:StartDebug_term(dict) " Open a terminal window without a job, to run the debugged program in. let s:ptybuf = term_start('NONE', { ! \ 'term_name': 'debugged program', ! \ 'vertical': s:vertical, ! \ }) if s:ptybuf == 0 echoerr 'Failed to open the program terminal window' return --- 161,169 ---- func s:StartDebug_term(dict) " Open a terminal window without a job, to run the debugged program in. let s:ptybuf = term_start('NONE', { ! \ 'term_name': 'debugged program', ! \ 'vertical': s:vertical, ! \ }) if s:ptybuf == 0 echoerr 'Failed to open the program terminal window' return *************** *** 177,186 **** " Create a hidden terminal window to communicate with gdb let s:commbuf = term_start('NONE', { ! \ 'term_name': 'gdb communication', ! \ 'out_cb': function('s:CommOutput'), ! \ 'hidden': 1, ! \ }) if s:commbuf == 0 echoerr 'Failed to open the communication terminal window' exe 'bwipe! ' . s:ptybuf --- 182,191 ---- " Create a hidden terminal window to communicate with gdb let s:commbuf = term_start('NONE', { ! \ 'term_name': 'gdb communication', ! \ 'out_cb': function('s:CommOutput'), ! \ 'hidden': 1, ! \ }) if s:commbuf == 0 echoerr 'Failed to open the communication terminal window' exe 'bwipe! ' . s:ptybuf *************** *** 196,203 **** let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args call ch_log('executing "' . join(cmd) . '"') let s:gdbbuf = term_start(cmd, { ! \ 'term_finish': 'close', ! \ }) if s:gdbbuf == 0 echoerr 'Failed to open the gdb terminal window' call s:CloseBuffers() --- 201,208 ---- let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args call ch_log('executing "' . join(cmd) . '"') let s:gdbbuf = term_start(cmd, { ! \ 'term_finish': 'close', ! \ }) if s:gdbbuf == 0 echoerr 'Failed to open the gdb terminal window' call s:CloseBuffers() *************** *** 229,245 **** let line1 = term_getline(s:gdbbuf, lnum) let line2 = term_getline(s:gdbbuf, lnum + 1) if line1 =~ 'new-ui mi ' ! " response can be in the same line or the next line ! let response = line1 . line2 ! if response =~ 'Undefined command' ! echoerr 'Sorry, your gdb is too old, gdb 7.12 is required' call s:CloseBuffers() ! return ! endif ! if response =~ 'New UI allocated' ! " Success! ! break ! endif elseif line1 =~ 'Reading symbols from' && line2 !~ 'new-ui mi ' " Reading symbols might take a while, try more times let try_count -= 1 --- 234,250 ---- let line1 = term_getline(s:gdbbuf, lnum) let line2 = term_getline(s:gdbbuf, lnum + 1) if line1 =~ 'new-ui mi ' ! " response can be in the same line or the next line ! let response = line1 . line2 ! if response =~ 'Undefined command' ! echoerr 'Sorry, your gdb is too old, gdb 7.12 is required' call s:CloseBuffers() ! return ! endif ! if response =~ 'New UI allocated' ! " Success! ! break ! endif elseif line1 =~ 'Reading symbols from' && line2 !~ 'new-ui mi ' " Reading symbols might take a while, try more times let try_count -= 1 *************** *** 300,308 **** call ch_log('executing "' . join(cmd) . '"') let s:gdbjob = job_start(cmd, { ! \ 'exit_cb': function('s:EndPromptDebug'), ! \ 'out_cb': function('s:GdbOutCallback'), ! \ }) if job_status(s:gdbjob) != "run" echoerr 'Failed to start gdb' exe 'bwipe! ' . s:promptbuf --- 305,313 ---- call ch_log('executing "' . join(cmd) . '"') let s:gdbjob = job_start(cmd, { ! \ 'exit_cb': function('s:EndPromptDebug'), ! \ 'out_cb': function('s:GdbOutCallback'), ! \ }) if job_status(s:gdbjob) != "run" echoerr 'Failed to start gdb' exe 'bwipe! ' . s:promptbuf *************** *** 327,334 **** " Unix: Run the debugged program in a terminal window. Open it below the " gdb window. belowright let s:ptybuf = term_start('NONE', { ! \ 'term_name': 'debugged program', ! \ }) if s:ptybuf == 0 echoerr 'Failed to open the program terminal window' call job_stop(s:gdbjob) --- 332,339 ---- " Unix: Run the debugged program in a terminal window. Open it below the " gdb window. belowright let s:ptybuf = term_start('NONE', { ! \ 'term_name': 'debugged program', ! \ }) if s:ptybuf == 0 echoerr 'Failed to open the program terminal window' call job_stop(s:gdbjob) *************** *** 508,516 **** if a:quotedText[i] == '\' let i += 1 if a:quotedText[i] == 'n' ! " drop \n ! let i += 1 ! continue endif endif let result .= a:quotedText[i] --- 513,526 ---- if a:quotedText[i] == '\' let i += 1 if a:quotedText[i] == 'n' ! " drop \n ! let i += 1 ! continue ! elseif a:quotedText[i] == 't' ! " append \t ! let i += 1 ! let result .= "\t" ! continue endif endif let result .= a:quotedText[i] *************** *** 594,621 **** endif if msg != '' if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)' ! call s:HandleCursor(msg) elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,' ! call s:HandleNewBreakpoint(msg) elseif msg =~ '^=breakpoint-deleted,' ! call s:HandleBreakpointDelete(msg) elseif msg =~ '^=thread-group-started' ! call s:HandleProgramRun(msg) elseif msg =~ '^\^done,value=' ! call s:HandleEvaluate(msg) elseif msg =~ '^\^error,msg=' ! call s:HandleError(msg) endif endif endfor endfunc " Install commands in the current window to control the debugger. func s:InstallCommands() let save_cpo = &cpo set cpo&vim ! command Break call s:SetBreakpoint() command Clear call s:ClearBreakpoint() command Step call s:SendCommand('-exec-step') command Over call s:SendCommand('-exec-next') --- 604,641 ---- endif if msg != '' if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)' ! call s:HandleCursor(msg) elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,' ! call s:HandleNewBreakpoint(msg) elseif msg =~ '^=breakpoint-deleted,' ! call s:HandleBreakpointDelete(msg) elseif msg =~ '^=thread-group-started' ! call s:HandleProgramRun(msg) elseif msg =~ '^\^done,value=' ! call s:HandleEvaluate(msg) elseif msg =~ '^\^error,msg=' ! call s:HandleError(msg) endif endif endfor endfunc + func s:GotoProgram() + if has('win32') + if executable('powershell') + call system(printf('powershell -Command "add-type -AssemblyName microsoft.VisualBasic;[Microsoft.VisualBasic.Interaction]::AppActivate(%d);"', s:pid)) + endif + else + win_gotoid(s:ptywin) + endif + endfunc + " Install commands in the current window to control the debugger. func s:InstallCommands() let save_cpo = &cpo set cpo&vim ! command -nargs=? Break call s:SetBreakpoint() command Clear call s:ClearBreakpoint() command Step call s:SendCommand('-exec-step') command Over call s:SendCommand('-exec-next') *************** *** 633,639 **** command -range -nargs=* Evaluate call s:Evaluate(, ) command Gdb call win_gotoid(s:gdbwin) ! command Program call win_gotoid(s:ptywin) command Source call s:GotoSourcewinOrCreateIt() command Winbar call s:InstallWinbar() --- 653,659 ---- command -range -nargs=* Evaluate call s:Evaluate(, ) command Gdb call win_gotoid(s:gdbwin) ! command Program call s:GotoProgram() command Source call s:GotoSourcewinOrCreateIt() command Winbar call s:InstallWinbar() *************** *** 695,706 **** let curwinid = win_getid(winnr()) for winid in s:winbar_winids if win_gotoid(winid) ! aunmenu WinBar.Step ! aunmenu WinBar.Next ! aunmenu WinBar.Finish ! aunmenu WinBar.Cont ! aunmenu WinBar.Stop ! aunmenu WinBar.Eval endif endfor call win_gotoid(curwinid) --- 715,726 ---- let curwinid = win_getid(winnr()) for winid in s:winbar_winids if win_gotoid(winid) ! aunmenu WinBar.Step ! aunmenu WinBar.Next ! aunmenu WinBar.Finish ! aunmenu WinBar.Cont ! aunmenu WinBar.Stop ! aunmenu WinBar.Eval endif endfor call win_gotoid(curwinid) *************** *** 733,739 **** endfunc " :Break - Set a breakpoint at the cursor position. ! func s:SetBreakpoint() " Setting a breakpoint may not work while the program is running. " Interrupt to make it work. let do_continue = 0 --- 753,759 ---- endfunc " :Break - Set a breakpoint at the cursor position. ! func s:SetBreakpoint(at) " Setting a breakpoint may not work while the program is running. " Interrupt to make it work. let do_continue = 0 *************** *** 746,754 **** endif sleep 10m endif " Use the fname:lnum format, older gdb can't handle --source. ! call s:SendCommand('-break-insert ' ! \ . fnameescape(expand('%:p')) . ':' . line('.')) if do_continue call s:SendCommand('-exec-continue') endif --- 766,776 ---- endif sleep 10m endif + " Use the fname:lnum format, older gdb can't handle --source. ! let at = empty(a:at) ? ! \ fnameescape(expand('%:p')) . ':' . line('.') : a:at ! call s:SendCommand('-break-insert ' . at) if do_continue call s:SendCommand('-exec-continue') endif *************** *** 763,776 **** let idx = 0 for id in s:breakpoint_locations[bploc] if has_key(s:breakpoints, id) ! " Assume this always works, the reply is simply "^done". ! call s:SendCommand('-break-delete ' . id) ! for subid in keys(s:breakpoints[id]) ! exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid) ! endfor ! unlet s:breakpoints[id] ! unlet s:breakpoint_locations[bploc][idx] ! break else let idx += 1 endif --- 785,798 ---- let idx = 0 for id in s:breakpoint_locations[bploc] if has_key(s:breakpoints, id) ! " Assume this always works, the reply is simply "^done". ! call s:SendCommand('-break-delete ' . id) ! for subid in keys(s:breakpoints[id]) ! exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid) ! endfor ! unlet s:breakpoints[id] ! unlet s:breakpoint_locations[bploc][idx] ! break else let idx += 1 endif *************** *** 899,912 **** if lnum =~ '^[0-9]*$' call s:GotoSourcewinOrCreateIt() if expand('%:p') != fnamemodify(fname, ':p') ! if &modified ! " TODO: find existing window ! exe 'split ' . fnameescape(fname) ! let s:sourcewin = win_getid(winnr()) ! call s:InstallWinbar() ! else ! exe 'edit ' . fnameescape(fname) ! endif endif exe lnum exe 'sign unplace ' . s:pc_id --- 921,934 ---- if lnum =~ '^[0-9]*$' call s:GotoSourcewinOrCreateIt() if expand('%:p') != fnamemodify(fname, ':p') ! if &modified ! " TODO: find existing window ! exe 'split ' . fnameescape(fname) ! let s:sourcewin = win_getid(winnr()) ! call s:InstallWinbar() ! else ! exe 'edit ' . fnameescape(fname) ! endif endif exe lnum exe 'sign unplace ' . s:pc_id *************** *** 1001,1008 **** if has_key(s:breakpoints, id) for [subid, entry] in items(s:breakpoints[id]) if has_key(entry, 'placed') ! exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid) ! unlet entry['placed'] endif endfor unlet s:breakpoints[id] --- 1023,1030 ---- if has_key(s:breakpoints, id) for [subid, entry] in items(s:breakpoints[id]) if has_key(entry, 'placed') ! exe 'sign unplace ' . s:Breakpoint2SignNumber(id, subid) ! unlet entry['placed'] endif endfor unlet s:breakpoints[id] *************** *** 1026,1032 **** for [id, entries] in items(s:breakpoints) for [subid, entry] in items(entries) if entry['fname'] == fname ! call s:PlaceSign(id, subid, entry) endif endfor endfor --- 1048,1054 ---- for [id, entries] in items(s:breakpoints) for [subid, entry] in items(entries) if entry['fname'] == fname ! call s:PlaceSign(id, subid, entry) endif endfor endfor *************** *** 1038,1044 **** for [id, entries] in items(s:breakpoints) for [subid, entry] in items(entries) if entry['fname'] == fname ! let entry['placed'] = 0 endif endfor endfor --- 1060,1066 ---- for [id, entries] in items(s:breakpoints) for [subid, entry] in items(entries) if entry['fname'] == fname ! let entry['placed'] = 0 endif endfor endfor *** ../vim-8.1.2102/src/version.c 2019-09-29 20:53:49.581950876 +0200 --- src/version.c 2019-09-30 20:44:52.571211335 +0200 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 2103, /**/ -- With sufficient thrust, pigs fly just fine. -- RFC 1925 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///