DM548 – Extra Stuff

Lab cheat sheet

C

To compile with extra warnings, debug symbols:

gcc -Wall -Wextra -g yourProgram.c -o yourProgram

To compile with extra warnings, debug symbols, and sanitizers:

gcc -Wall -Wextra -g -fsanitize=address -fsanitize=leak -fsanitize=undefined yourProgram.c -o yourProgram

When using Valgrind, do not compile with sanitizers. Invoke with:

valgrind --leak-check=full --track-origins=yes ./yourProgram with args

Example Makefile:

compiler_flags=-Wall -Wextra -g -fsanitize=address -fsanitize=leak -fsanitize=undefined

 

exercise_sources=$(wildcard lab_?/*.c)

exercise_executables=$(patsubst %.c,%,${exercise_sources})

 

$(exercise_executables): %: %.c

    gcc $(compiler_flags) $< -o $@

 

clean:

    rm $(exercise_executables)


Assembly

To assemble and link (Compile):

as --gstabs 1.s -o 1.o

as --gstabs utils.s -o utils.o

ld 1.o utils.o -o 1.out

To run:

./1.out

To debug with GDB:

gdb ./1.out

Add, Commit, and push to git repository:

git add my_file.txt

git commit -m "Wrote some stuff in my_file.txt"

git push -u origin master

Course resources

Course Homepage:
imada.sdu.dk/~jlandersen/teaching/dm548_19/

IMADA git server:
git.imada.sdu.dk

Test server:
dm548.imada.sdu.dk

Git guide:
imada.sdu.dk/~jlandersen/_static/git.pdf

GDB intro:
imada.sdu.dk/~jlandersen/_static/teaching/dm548_19/gdbNotes.pdf

Resources I find cool or helpful

If you have questions

Send me (Jakob, your TA) an e-mail: jakkj16@student.sdu.dk