From 387e7aad348a37a3048118a179ed7e88e19cb36e Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 29 Jun 2022 21:29:15 +0200 Subject: [PATCH] Chore: Configure debugging in vscode --- .vscode/launch.json | 29 +++++++++++++++++++++++++++++ .vscode/settings.json | 13 ++++++++++--- .vscode/tasks.json | 4 ++-- Implementierung/Makefile | 2 +- Implementierung/lib/io.h | 2 ++ Implementierung/src/helper.c | 2 +- Implementierung/src/io.c | 2 +- Implementierung/src/main.c | 6 +++--- 8 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..78b164e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "cppdbg", + "request": "launch", + "name": "C/C++: gcc debug active file", + "program": "${workspaceFolder}/Implementierung/md2", + "args": [ + "${workspaceFolder}/Implementierung/testfile" + ], + "cwd": "${workspaceFolder}", + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "C/C++: gcc build active file", + "miDebuggerPath": "/usr/bin/gdb" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index e8e7420..57c9e18 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,7 +10,14 @@ "string_view": "c", "system_error": "c", "variant": "c", - "array": "c" + "array": "c", + "md2.h": "c", + "io.h": "c" }, - "editor.formatOnSave": true -} + "editor.formatOnSave": true, + "C_Cpp.default.includePath": [ + "./lib", + "./Implementierung/lib", + "../lib" + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 08d9005..dde10c3 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,9 +7,9 @@ "args": [ "-fdiagnostics-color=always", "-g", - "${file}", + "${fileDirname}/*.c", "-o", - "${fileDirname}/${fileBasenameNoExtension}" + "${fileDirname}/../md2" ], "options": { "cwd": "${fileDirname}" diff --git a/Implementierung/Makefile b/Implementierung/Makefile index 9283a29..d678b32 100644 --- a/Implementierung/Makefile +++ b/Implementierung/Makefile @@ -3,7 +3,7 @@ SRC = src/main.c src/helper.c src/io.c src/md2.c OBJ = ${subst src,build,${SRC:.c=.o}} CC = gcc -CFLAGS = -Ilib +CFLAGS = -Ilib -ggdb LDFLAGS = all: md2 diff --git a/Implementierung/lib/io.h b/Implementierung/lib/io.h index da5e511..4d0ee2f 100644 --- a/Implementierung/lib/io.h +++ b/Implementierung/lib/io.h @@ -1,6 +1,8 @@ #ifndef IO_H #define IO_H +#define _XOPEN_SOURCE + #include #include #include diff --git a/Implementierung/src/helper.c b/Implementierung/src/helper.c index fa3043b..f809aa5 100644 --- a/Implementierung/src/helper.c +++ b/Implementierung/src/helper.c @@ -1,4 +1,4 @@ -#include "helper.h" +#include "../lib/helper.h" int stringToInt(char *string) { char *leftover = ""; diff --git a/Implementierung/src/io.c b/Implementierung/src/io.c index f289907..cd7bee3 100644 --- a/Implementierung/src/io.c +++ b/Implementierung/src/io.c @@ -1,4 +1,4 @@ -#include "io.h" +#include "../lib/io.h" bool read_file(const char* path, uint8_t** data, size_t* size) { // Read the contents of the file specified by path into a heap-allocated diff --git a/Implementierung/src/main.c b/Implementierung/src/main.c index 5193421..b8b6906 100644 --- a/Implementierung/src/main.c +++ b/Implementierung/src/main.c @@ -1,8 +1,8 @@ #include -#include "helper.h" -#include "io.h" -#include "md2.h" +#include "../lib/helper.h" +#include "../lib/io.h" +#include "../lib/md2.h" // Returns true when val is approx. equal to exp. static bool runTest(const char* message, const char* expectedHash) {