]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0878: termdebug: cannot enable DEBUG mode v9.1.0878
authorUbaldo Tiberi <ubaldo.tiberi@volvo.com>
Tue, 19 Nov 2024 21:32:30 +0000 (22:32 +0100)
committerChristian Brabandt <cb@256bit.org>
Tue, 19 Nov 2024 21:32:30 +0000 (22:32 +0100)
Problem:  termdebug: cannot enable DEBUG mode
Solution: Allow to specify DEBUG mode (Ubaldo Tiberi)

closes: #16080

Signed-off-by: Ubaldo Tiberi <ubaldo.tiberi@volvo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/tags
runtime/doc/terminal.txt
runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
src/testdir/test_termdebug.vim
src/version.c

index 706970f17af320e09ed7a66852ffe36dbca639fb..39f279d361171b88d7cf21048b70821d66a36bfa 100644 (file)
@@ -10688,6 +10688,7 @@ termdebug-starting      terminal.txt    /*termdebug-starting*
 termdebug-stepping     terminal.txt    /*termdebug-stepping*
 termdebug-timeout      terminal.txt    /*termdebug-timeout*
 termdebug-variables    terminal.txt    /*termdebug-variables*
+termdebug_contributing terminal.txt    /*termdebug_contributing*
 termdebug_disasm_window        terminal.txt    /*termdebug_disasm_window*
 termdebug_evaluate_in_popup    terminal.txt    /*termdebug_evaluate_in_popup*
 termdebug_map_K        terminal.txt    /*termdebug_map_K*
index 637277ab592203c741d526d8fcbf70e33d3c18e2..593dec77c7b00fde372c8d7accd4cb6903b676e0 100644 (file)
@@ -1,4 +1,4 @@
-*terminal.txt* For Vim version 9.1.  Last change: 2024 Nov 10
+*terminal.txt* For Vim version 9.1.  Last change: 2024 Nov 19
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1737,4 +1737,23 @@ This can also be used in a "one-shot" manner: >
          let g:termdebug_config['evaluate_in_popup'] = v:false
        endfunc
 <
+
+Contributing ~
+                                               *termdebug_contributing*
+Contributions for termdebug improvements are welcome.
+However, it is fairly common that during the development process you need some
+mechanisms like `echo` statements (or similar) to help you in your job.
+For this reason, you can set: >
+    let g:termdebug_config['debug'] = true
+<
+This sets the `DEBUG` variable to `true` in the source code that you can use
+within the source code. An example of its usage follows: >
+    if exists('g:termdebug_loaded')
+      if DEBUG
+       Echoerr('Termdebug already loaded.')
+      endif
+      finish
+    endif
+<
+
  vim:tw=78:ts=8:noet:ft=help:norl:
index 6f1f4b5227ac768e97b792823d7b6798c35f6906..9fbf3b7f69e4d8f4ccfb29a3534fcc0fea94e495 100644 (file)
@@ -4,7 +4,7 @@ vim9script
 
 # Author: Bram Moolenaar
 # Copyright: Vim license applies, see ":help license"
-# Last Change: 2024 Jul 04
+# Last Change: 2024 Nov 19
 # Converted to Vim9: Ubaldo Tiberi <ubaldo.tiberi@gmail.com>
 
 # WORK IN PROGRESS - The basics works stable, more to come
@@ -38,6 +38,11 @@ vim9script
 # The communication with gdb uses GDB/MI.  See:
 # https://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI.html
 
+var DEBUG = false
+if exists('g:termdebug_config')
+  DEBUG = get(g:termdebug_config, 'debug', false)
+endif
+
 def Echoerr(msg: string)
   echohl ErrorMsg | echom $'[termdebug] {msg}' | echohl None
 enddef
@@ -49,7 +54,9 @@ enddef
 # Variables to keep their status among multiple instances of Termdebug
 # Avoid to source the script twice.
 if exists('g:termdebug_loaded')
-  Echoerr('Termdebug already loaded.')
+  if DEBUG
+    Echoerr('Termdebug already loaded.')
+  endif
   finish
 endif
 g:termdebug_loaded = true
index 17e1d897a30f7119a7f99a59dd2bc8b89fc39714..0acdab1a508c1446ffe2607eb39232d5704aef70 100644 (file)
@@ -57,6 +57,8 @@ endfunction
 
 packadd termdebug
 
+" should be the first test to run, since it validates the window layout with
+" win ids
 func Test_termdebug_basic()
   let bin_name = 'XTD_basic'
   let src_name = bin_name .. '.c'
@@ -620,4 +622,22 @@ function Test_termdebug_config_types()
   unlet g:termdebug_config
 endfunction
 
+function Test_termdebug_config_debug()
+  let s:error_message = '\[termdebug\] Termdebug already loaded'
+
+  " USER mode: No error message shall be displayed
+  packadd termdebug
+  call assert_true(execute('messages') !~ s:error_message)
+
+  " DEBUG mode: Error message shall now be displayed
+  let g:termdebug_config = {}
+  let g:termdebug_config['debug'] = 1
+  packadd termdebug
+  call assert_true(execute('messages') =~ s:error_message)
+
+  unlet g:termdebug_config
+  unlet g:termdebug_loaded
+  " Revert DEBUG mode, by reloading the plugin
+  source $VIMRUNTIME/pack/dist/opt/termdebug/plugin/termdebug.vim
+endfunction
 " vim: shiftwidth=2 sts=2 expandtab
index 422633aa6c0ef1f4e2342d0b3ec0ce489e7800c3..6b263ea04e4a21886ec97462ad50485ed8249a2d 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    878,
 /**/
     877,
 /**/