Skip to content

Instantly share code, notes, and snippets.

@keyle
Last active May 24, 2023 09:38
Show Gist options
  • Save keyle/f1eef36df3aae29aafb2c88557b3f67d to your computer and use it in GitHub Desktop.
Save keyle/f1eef36df3aae29aafb2c88557b3f67d to your computer and use it in GitHub Desktop.
M1/M2 C Debugging with Clang, CodeLLDB and VSCode
{
"version": "0.2.0",
"configurations": [
{
"name": "CodeLLDB",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/<binary>",
"args": [
],
}
]
}
COMPILER = clang
SOURCE_LIBS = -Ilib/ -Llib/
INCLUDES = -include **.h # NOTE not used below as it compiles the *.h files as well and generates multiple outputs
# OSX_OPT = -framework CoreVideo -framework IOKit -framework Cocoa -framework OpenGL
WARNINGS = -Wall
DEBUG_BUILD = -g -v -o "binary" -std=c99
LEAKS_BUILD = -v -o "binary" -std=c99 -fsanitize=address
RELEASE_BUILD = -o "binary-release" -std=c99 # -O1 O2 remove the hex map?
CFILES = **.c
# for debug -fsanitize=address
export ASAN_OPTIONS := allocator_may_return_null=1
build_osx:
$(COMPILER) $(CFILES) $(SOURCE_LIBS) $(WARNINGS) $(DEBUG_BUILD)
./binary
leaks:
$(COMPILER) $(CFILES) $(SOURCE_LIBS) $(WARNINGS) $(LEAKS_BUILD)
./binary
clean:
rm -rf binary.*
rm binary-*
release:
$(COMPILER) $(CFILES) $(SOURCE_LIBS) $(WARNINGS) $(RELEASE_BUILD)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment