From 10006933cc7deb2fee9d1d977009b4a5c8e123d6 Mon Sep 17 00:00:00 2001 From: cnlohr <lohr85@gmail.com> Date: Thu, 4 May 2023 05:51:51 -0400 Subject: [PATCH] Get working debugging in vs code. --- examples/blink/.vscode/launch.json | 25 --------- examples/blink/.vscode/settings.json | 12 ---- .../.vscode/c_cpp_properties.json | 19 +++++++ examples/debugprintfdemo/.vscode/launch.json | 33 +++++++++++ .../debugprintfdemo/.vscode/settings.json | 15 +++++ examples/debugprintfdemo/.vscode/tasks.json | 56 +++++++++++++++++++ examples/debugprintfdemo/debugprintfdemo.c | 1 - 7 files changed, 123 insertions(+), 38 deletions(-) delete mode 100644 examples/blink/.vscode/launch.json delete mode 100644 examples/blink/.vscode/settings.json create mode 100644 examples/debugprintfdemo/.vscode/c_cpp_properties.json create mode 100644 examples/debugprintfdemo/.vscode/launch.json create mode 100644 examples/debugprintfdemo/.vscode/settings.json create mode 100644 examples/debugprintfdemo/.vscode/tasks.json diff --git a/examples/blink/.vscode/launch.json b/examples/blink/.vscode/launch.json deleted file mode 100644 index daf0b51..0000000 --- a/examples/blink/.vscode/launch.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "configurations": [ - { - "name": "GDB debug - custom", - "type": "cppdbg", - "request": "launch", - "program": "blink.elf", - "args": [], - "stopAtEntry": true, - "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], - "miDebuggerPath": "/usr/bin/gdb-multiarch", - "miDebuggerServerAddress": "127.0.0.1:2000" - } - ] -} diff --git a/examples/blink/.vscode/settings.json b/examples/blink/.vscode/settings.json deleted file mode 100644 index 79b30b8..0000000 --- a/examples/blink/.vscode/settings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "cmake.configureOnOpen": false, - "makefile.launchConfigurations": [ - { - "cwd": "/home/cnlohr/git/ch32v003fun/examples/blink", - "sbinaryPath": "/home/cnlohr/git/ch32v003fun/examples/blink/blink.elf", - "binaryArgs": [] - } - ], - "editor.insertSpaces": false, - "editor.tabSize": 4 -} diff --git a/examples/debugprintfdemo/.vscode/c_cpp_properties.json b/examples/debugprintfdemo/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..6bf3f61 --- /dev/null +++ b/examples/debugprintfdemo/.vscode/c_cpp_properties.json @@ -0,0 +1,19 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/../../ch32v003fun" + ], + "defines": [], + "compilerPath": "/usr/bin/clang", + "cppStandard": "c++14", + "intelliSenseMode": "linux-clang-x64", + "compilerArgs": [ + "-DCH32V003FUN_BASE" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/examples/debugprintfdemo/.vscode/launch.json b/examples/debugprintfdemo/.vscode/launch.json new file mode 100644 index 0000000..3ba758b --- /dev/null +++ b/examples/debugprintfdemo/.vscode/launch.json @@ -0,0 +1,33 @@ +{ + "configurations": [ + { + "name": "GDB Debug Target", + "type": "cppdbg", + "request": "launch", + "program": "debugprintfdemo.elf", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "preLaunchTask": "run_flash_and_gdbserver", + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "miDebuggerPath": "/usr/bin/gdb-multiarch", + "miDebuggerServerAddress": "127.0.0.1:2000" + }, + { + "name": "Run Only (In Terminal)", + "type": "node", + "request": "launch", + "program": "", + "preLaunchTask": "run_flash_and_gdbserver", + } + ] +} diff --git a/examples/debugprintfdemo/.vscode/settings.json b/examples/debugprintfdemo/.vscode/settings.json new file mode 100644 index 0000000..5f7790e --- /dev/null +++ b/examples/debugprintfdemo/.vscode/settings.json @@ -0,0 +1,15 @@ +{ + "cmake.configureOnOpen": false, + "makefile.launchConfigurations": [ + { + "cwd": "", + "sbinaryPath": "blink.elf", + "binaryArgs": [] + } + ], + "editor.insertSpaces": false, + "editor.tabSize": 4, + "files.associations": { + "ch32v003fun.h": "c" + } +} diff --git a/examples/debugprintfdemo/.vscode/tasks.json b/examples/debugprintfdemo/.vscode/tasks.json new file mode 100644 index 0000000..0e0393d --- /dev/null +++ b/examples/debugprintfdemo/.vscode/tasks.json @@ -0,0 +1,56 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "flash", + "presentation": { + "echo": true, + "focus": false, + "group": "build", + "panel": "shared", + "showReuseMessage" : false + }, + "command": "killall minichlink; make flash", + }, + { + "type": "shell", + "label": "run_flash_and_gdbserver", + "command": "killall minichlink; make flash gdbserver", + + "presentation": { + "echo": true, + "focus": false, + "group": "build", + "panel": "shared", + "close": true, + "showReuseMessage" : false + }, + + "isBackground": true, + "options": { + "cwd": "${workspaceFolder}", + }, + "runOptions": { + "instanceLimit": 2, + }, + "group": "build", + "problemMatcher": { + "pattern": [ + { + "regexp": ".", + "file": 1, + "location": 2, + "message": 3 + } + ], + + "background": { + "activeOnStart": false, + "beginsPattern": "^.*Image written.*", + "endsPattern": "^.*GDBServer*" + } + }, + } + ] +} diff --git a/examples/debugprintfdemo/debugprintfdemo.c b/examples/debugprintfdemo/debugprintfdemo.c index a73faf1..41a153b 100644 --- a/examples/debugprintfdemo/debugprintfdemo.c +++ b/examples/debugprintfdemo/debugprintfdemo.c @@ -34,7 +34,6 @@ int main() GPIOD->BSHR = (1<<16) | (1<<(16+4)); // Turn off GPIODs GPIOC->BSHR = (1<<16); printf( "-%lu\n", count++ ); - //_write( 0, "xxxxxxx", 7 ); } } -- GitLab