return type(cmd) == v:t_list ? copy(cmd) : [cmd]
endfunc
+func s:Echoerr(msg)
+ echohl ErrorMsg | echom '[termdebug] ' .. a:msg | echohl None
+endfunc
+
func s:StartDebug(bang, ...)
" First argument is the command to debug, second core file or process ID.
call s:StartDebug_internal({'gdb_args': a:000, 'bang': a:bang})
func s:StartDebug_internal(dict)
if exists('s:gdbwin')
- echoerr 'Terminal debugger already running, cannot run two'
+ call s:Echoerr('Terminal debugger already running, cannot run two')
return
endif
let gdbcmd = s:GetCommand()
if !executable(gdbcmd[0])
- echoerr 'Cannot execute debugger program "' .. gdbcmd[0] .. '"'
+ call s:Echoerr('Cannot execute debugger program "' .. gdbcmd[0] .. '"')
return
endif
func s:CheckGdbRunning()
let gdbproc = term_getjob(s:gdbbuf)
if gdbproc == v:null || job_status(gdbproc) !=# 'run'
- echoerr string(s:GetCommand()[0]) . ' exited unexpectedly'
+ call s:Echoerr(string(s:GetCommand()[0]) . ' exited unexpectedly')
call s:CloseBuffers()
return ''
endif
\ 'vertical': s:vertical,
\ })
if s:ptybuf == 0
- echoerr 'Failed to open the program terminal window'
+ call s:Echoerr('Failed to open the program terminal window')
return
endif
let pty = job_info(term_getjob(s:ptybuf))['tty_out']
\ 'hidden': 1,
\ })
if s:commbuf == 0
- echoerr 'Failed to open the communication terminal window'
+ call s:Echoerr('Failed to open the communication terminal window')
exe 'bwipe! ' . s:ptybuf
return
endif
\ 'term_finish': 'close',
\ })
if s:gdbbuf == 0
- echoerr 'Failed to open the gdb terminal window'
+ call s:Echoerr('Failed to open the gdb terminal window')
call s:CloseBuffers()
return
endif
" 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:Echoerr('Sorry, your gdb is too old, gdb 7.12 is required')
" CHECKME: possibly send a "server show version" here
call s:CloseBuffers()
return
endif
let try_count += 1
if try_count > 100
- echoerr 'Cannot check if your gdb works, continuing anyway'
+ call s:Echoerr('Cannot check if your gdb works, continuing anyway')
break
endif
sleep 10m
\ 'out_cb': function('s:GdbOutCallback'),
\ })
if job_status(s:gdbjob) != "run"
- echoerr 'Failed to start gdb'
+ call s:Echoerr('Failed to start gdb')
exe 'bwipe! ' . s:promptbuf
return
endif
\ 'term_name': 'debugged program',
\ })
if s:ptybuf == 0
- echoerr 'Failed to open the program terminal window'
+ call s:Echoerr('Failed to open the program terminal window')
call job_stop(s:gdbjob)
return
endif
" Using job_stop() does not work on MS-Windows, need to send SIGTRAP to
" the debugger program so that gdb responds again.
if s:pid == 0
- echoerr 'Cannot interrupt gdb, did not find a process ID'
+ call s:Echoerr('Cannot interrupt gdb, did not find a process ID')
else
call debugbreak(s:pid)
endif
" - change \\ to \
func s:DecodeMessage(quotedText, literal)
if a:quotedText[0] != '"'
- echoerr 'DecodeMessage(): missing quote in ' . a:quotedText
+ call s:Echoerr('DecodeMessage(): missing quote in ' . a:quotedText)
return
endif
let msg = a:quotedText
endif
echomsg 'Breakpoint ' . id . ' cleared from line ' . lnum . '.'
else
- echoerr 'Internal error trying to remove breakpoint at line ' . lnum . '!'
+ call s:Echoerr('Internal error trying to remove breakpoint at line ' . lnum . '!')
endif
else
echomsg 'No breakpoint to remove at line ' . lnum . '.'
return
endif
let msgVal = substitute(a:msg, '.*msg="\(.*\)"', '\1', '')
- echoerr substitute(msgVal, '\\"', '"', 'g')
+ call s:Echoerr(substitute(msgVal, '\\"', '"', 'g'))
endfunc
func s:GotoSourcewinOrCreateIt()