From 1b5efdb1469ebe4bef78bc1aaa4da720e7b38857 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Sun, 19 Nov 2023 22:35:22 +0600 Subject: [PATCH] vscode debug --- .vscode/launch.json | 34 ++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 24 ++++++++++++++++++++++++ build.sh | 12 ++++++++++-- kerep/build.sh | 2 +- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2b3d5b5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,34 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) Debug", + "type": "cppdbg", + "request": "launch", + "cwd": "${workspaceFolder}/bin", + "windows": { + "program": "${workspaceFolder}\\bin\\cbuild.exe", + }, + "linux": { + "program": "${workspaceFolder}/bin/cbuild", + }, + "preLaunchTask": "build", + "stopAtEntry": false, + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..fdff072 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,24 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "cppbuild", + "label": "build", + "command": "bash", + "args": [ + "${workspaceRoot}/build.sh", + "debug" + ], + "options": { + "cwd": "${workspaceRoot}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/build.sh b/build.sh index acf2352..7e855dd 100644 --- a/build.sh +++ b/build.sh @@ -4,7 +4,15 @@ set -eo pipefail CONFIG_DIR="/etc/cbuild" CMP="gcc" WARN="-Wall -Wextra -Wno-discarded-qualifiers -Wno-unused-parameter" -ARGS="-O2 -flto -fdata-sections -ffunction-sections -Wl,--gc-sections" + +ARGS_DEBUG="-O0 -g" +ARGS_RELEASE="-O2 -flto=auto -fdata-sections -ffunction-sections -Wl,--gc-sections" +if [ "$1" -eq "debug" ]; then + ARGS=$ARGS_DEBUG +else + ARGS=$ARGS_RELEASE +fi + SRC="$(find src -name '*.c')" OS="$(./detect_os.sh)" @@ -32,7 +40,7 @@ if [ ! -f "kerep/bin/libkerep-$OS-$ARCH.a" ]; then fi rm -rf bin -mkdir bin +mkdir -p bin echo "----------------[cbuild]----------------" echo "$command" diff --git a/kerep/build.sh b/kerep/build.sh index 8bfebca..3c61538 100644 --- a/kerep/build.sh +++ b/kerep/build.sh @@ -3,7 +3,7 @@ set -eo pipefail CMP="gcc" WARN="-std=c11 -Wall -Wno-discarded-qualifiers -Wno-unused-parameter" -ARGS="-O2 -flto -fpic -fdata-sections -ffunction-sections" +ARGS="-O2 -flto=auto -fpic -fdata-sections -ffunction-sections" SRC="$(find src -name '*.c')" OS=$(../detect_os.sh)