sdstest1
+128 −104 · 5 files changed
-
sdstest/Tuprules.tup+6 −4 -
sdstest/include/square.h+1 −0 -
sdstest/obj/Tupfile+1 −0 -
sdstest/src/main.c+8 −3 -
sdstest/test/program_debug.txt+112 −97
@@ -1,11 +1,13 @@ -&libdir = include/ +&includedir = include/ &objdir = obj/ &bindir = bin/ +&libdir = lib/sds/ CDEBUG += -Weverything CDEBUG += -g CDEBUG += -Og CDEBUG += -ggdb +#CDEBUG += -v CRELEASE += -O2 CRELEASE += -D_FORTIFY_SOURCE=2 @@ -20,15 +22,15 @@ VALGRND += --verbose VALGRND += --log-file= ifeq (@(DO_RELEASE),y) - # Do the object files -!ccorel = |> clang $(CRELEASE) -I&(libdir) -c %f -o &(objdir)/%o |> %B_release.o + # Create object files - preprocess, compile and assemble steps +!ccorel = |> clang $(CRELEASE) -I&(includedir) -c %f -o &(objdir)/%o |> %B_release.o # macro for the archive command !ar = |> ar crs %o %f |> # Do binaries, debug and release !ccbrel = |> clang $(CRELEASE) %f -o &(bindir)/%o |> %B else # Do the object files -!ccodbg = |> clang $(CDEBUG) -I&(libdir) -c %f -o &(objdir)/%o |> %B_debug.o +!ccodbg = |> clang $(CDEBUG) -iquote../lib -iquote../include -c %f -o &(objdir)/%o |> %B_debug.o # macro for the archive command !ar = |> ar crs %o %f |> # Do binaries, debug and release @@ -1,2 +1,3 @@ #include <stdio.h> extern int square(int x,int y); + @@ -10,4 +10,5 @@ ifeq (@(DO_RELEASE),y) : foreach ../src/*.c |> !ccorel |> else : foreach ../src/*.c |> !ccodbg |> +: foreach ../lib/sds/*.c |> !ccodbg |> endif @@ -1,16 +1,21 @@ #include <stdio.h> #include <stdlib.h> #include <errno.h> -#include "../lib/sds/sds.h" -#include "../include/square.h" +#include "sds/sds.h" +#include "square.h" int main (int argc, char** argv) { if (argc != 2) { fprintf(stderr,"Argument count missing\n"); } + + sds mystring = sdsnew("Hello World!"); +// printf("%s\n", mystring); +// sdsfree(mystring); + fprintf(stdout, "The number of arguments is: %d\n",argc); - fprintf(stdout, "%s\n","correct" ); + fprintf(stdout, "The sds string is %s\n","test" ); int rc = square(4,5); fprintf(stdout, "%d\n",rc); @@ -1,97 +1,112 @@ -==83445== Memcheck, a memory error detector -==83445== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. -==83445== Using Valgrind-3.16.1-36d6727e1d-20200622X and LibVEX; rerun with -h for copyright info -==83445== Command: ../bin/program_debug -==83445== Parent PID: 83432 -==83445== ---83445-- ---83445-- Valgrind options: ---83445-- --leak-check=full ---83445-- --show-leak-kinds=all ---83445-- --track-origins=yes ---83445-- --verbose ---83445-- --log-file=program_debug.txt ---83445-- Contents of /proc/version: ---83445-- Linux version 5.8.5-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35) #1 SMP PREEMPT Thu, 27 Aug 2020 18:53:02 +0000 ---83445-- ---83445-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-ssse3-avx-avx2-bmi-f16c-rdrand ---83445-- Page sizes: currently 4096, max supported 4096 ---83445-- Valgrind library directory: /usr/lib/valgrind ---83445-- Reading syms from /home/kiro/proj/cproj/cproj/sdstest/bin/program_debug ---83445-- Reading syms from /usr/lib/ld-2.32.so ---83445-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux ---83445-- object doesn't have a dynamic symbol table ---83445-- Scheduler: using generic scheduler lock implementation. ---83445-- Reading suppressions file: /usr/lib/valgrind/default.supp -==83445== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-83445-by-???-on-??? -==83445== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-83445-by-???-on-??? -==83445== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-83445-by-???-on-??? -==83445== -==83445== TO CONTROL THIS PROCESS USING vgdb (which you probably -==83445== don't want to do, unless you know exactly what you're doing, -==83445== or are doing some strange experiment): -==83445== /usr/lib/valgrind/../../bin/vgdb --pid=83445 ...command... -==83445== -==83445== TO DEBUG THIS PROCESS USING GDB: start GDB like this -==83445== /path/to/gdb ../bin/program_debug -==83445== and then give GDB the following command -==83445== target remote | /usr/lib/valgrind/../../bin/vgdb --pid=83445 -==83445== --pid is optional if only one valgrind process is running -==83445== ---83445-- REDIR: 0x4021ee0 (ld-linux-x86-64.so.2:strlen) redirected to 0x580b9662 (vgPlain_amd64_linux_REDIR_FOR_strlen) ---83445-- REDIR: 0x4021cb0 (ld-linux-x86-64.so.2:index) redirected to 0x580b967c (vgPlain_amd64_linux_REDIR_FOR_index) ---83445-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so ---83445-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so -==83445== WARNING: new redirection conflicts with existing -- ignoring it ---83445-- old: 0x04021ee0 (strlen ) R-> (0000.0) 0x580b9662 vgPlain_amd64_linux_REDIR_FOR_strlen ---83445-- new: 0x04021ee0 (strlen ) R-> (2007.0) 0x0483dd90 strlen ---83445-- REDIR: 0x401e6c0 (ld-linux-x86-64.so.2:strcmp) redirected to 0x483ec60 (strcmp) ---83445-- REDIR: 0x4022440 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4842450 (mempcpy) ---83445-- Reading syms from /usr/lib/libc-2.32.so ---83445-- REDIR: 0x492a8c0 (libc.so.6:memmove) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929db0 (libc.so.6:strncpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492ac00 (libc.so.6:strcasecmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929850 (libc.so.6:strcat) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929e10 (libc.so.6:rindex) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492bfb0 (libc.so.6:rawmemchr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4944500 (libc.so.6:wmemchr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4944040 (libc.so.6:wcscmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492aa20 (libc.so.6:mempcpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492a850 (libc.so.6:bcmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929d40 (libc.so.6:strncmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929900 (libc.so.6:strcmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492a990 (libc.so.6:memset) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4944000 (libc.so.6:wcschr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929ca0 (libc.so.6:strnlen) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x49299e0 (libc.so.6:strcspn) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492ac50 (libc.so.6:strncasecmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929980 (libc.so.6:strcpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492ada0 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4945750 (libc.so.6:wcsnlen) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4944080 (libc.so.6:wcscpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929e50 (libc.so.6:strpbrk) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x49298b0 (libc.so.6:index) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929c60 (libc.so.6:strlen) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x49303a0 (libc.so.6:memrchr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492aca0 (libc.so.6:strcasecmp_l) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492a810 (libc.so.6:memchr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4944150 (libc.so.6:wcslen) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x4929f80 (libc.so.6:strspn) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492aba0 (libc.so.6:stpncpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492ab40 (libc.so.6:stpcpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492bff0 (libc.so.6:strchrnul) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x492acf0 (libc.so.6:strncasecmp_l) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) ---83445-- REDIR: 0x49fc8a0 (libc.so.6:__strrchr_avx2) redirected to 0x483d7d0 (rindex) ---83445-- REDIR: 0x49fc6b0 (libc.so.6:__strchrnul_avx2) redirected to 0x4841f40 (strchrnul) ---83445-- REDIR: 0x4925c90 (libc.so.6:malloc) redirected to 0x483a710 (malloc) ---83445-- REDIR: 0x49ffa60 (libc.so.6:__mempcpy_avx_unaligned_erms) redirected to 0x4842050 (mempcpy) ---83445-- REDIR: 0x49fca70 (libc.so.6:__strlen_avx2) redirected to 0x483dc70 (strlen) ---83445-- REDIR: 0x49262f0 (libc.so.6:free) redirected to 0x483b940 (free) -==83445== -==83445== HEAP SUMMARY: -==83445== in use at exit: 0 bytes in 0 blocks -==83445== total heap usage: 1 allocs, 1 frees, 4,096 bytes allocated -==83445== -==83445== All heap blocks were freed -- no leaks are possible -==83445== -==83445== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) +==88053== Memcheck, a memory error detector +==88053== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. +==88053== Using Valgrind-3.16.1-36d6727e1d-20200622X and LibVEX; rerun with -h for copyright info +==88053== Command: ../bin/program_debug +==88053== Parent PID: 88040 +==88053== +--88053-- +--88053-- Valgrind options: +--88053-- --leak-check=full +--88053-- --show-leak-kinds=all +--88053-- --track-origins=yes +--88053-- --verbose +--88053-- --log-file=program_debug.txt +--88053-- Contents of /proc/version: +--88053-- Linux version 5.8.5-arch1-1 (linux@archlinux) (gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35) #1 SMP PREEMPT Thu, 27 Aug 2020 18:53:02 +0000 +--88053-- +--88053-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-ssse3-avx-avx2-bmi-f16c-rdrand +--88053-- Page sizes: currently 4096, max supported 4096 +--88053-- Valgrind library directory: /usr/lib/valgrind +--88053-- Reading syms from /home/kiro/proj/cproj/sdstest/bin/program_debug +--88053-- Reading syms from /usr/lib/ld-2.32.so +--88053-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux +--88053-- object doesn't have a dynamic symbol table +--88053-- Scheduler: using generic scheduler lock implementation. +--88053-- Reading suppressions file: /usr/lib/valgrind/default.supp +==88053== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-88053-by-???-on-??? +==88053== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-88053-by-???-on-??? +==88053== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-88053-by-???-on-??? +==88053== +==88053== TO CONTROL THIS PROCESS USING vgdb (which you probably +==88053== don't want to do, unless you know exactly what you're doing, +==88053== or are doing some strange experiment): +==88053== /usr/lib/valgrind/../../bin/vgdb --pid=88053 ...command... +==88053== +==88053== TO DEBUG THIS PROCESS USING GDB: start GDB like this +==88053== /path/to/gdb ../bin/program_debug +==88053== and then give GDB the following command +==88053== target remote | /usr/lib/valgrind/../../bin/vgdb --pid=88053 +==88053== --pid is optional if only one valgrind process is running +==88053== +--88053-- REDIR: 0x4021ee0 (ld-linux-x86-64.so.2:strlen) redirected to 0x580b9662 (vgPlain_amd64_linux_REDIR_FOR_strlen) +--88053-- REDIR: 0x4021cb0 (ld-linux-x86-64.so.2:index) redirected to 0x580b967c (vgPlain_amd64_linux_REDIR_FOR_index) +--88053-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so +--88053-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so +==88053== WARNING: new redirection conflicts with existing -- ignoring it +--88053-- old: 0x04021ee0 (strlen ) R-> (0000.0) 0x580b9662 vgPlain_amd64_linux_REDIR_FOR_strlen +--88053-- new: 0x04021ee0 (strlen ) R-> (2007.0) 0x0483dd90 strlen +--88053-- REDIR: 0x401e6c0 (ld-linux-x86-64.so.2:strcmp) redirected to 0x483ec60 (strcmp) +--88053-- REDIR: 0x4022440 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4842450 (mempcpy) +--88053-- Reading syms from /usr/lib/libc-2.32.so +--88053-- REDIR: 0x492a8c0 (libc.so.6:memmove) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929db0 (libc.so.6:strncpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492ac00 (libc.so.6:strcasecmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929850 (libc.so.6:strcat) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929e10 (libc.so.6:rindex) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492bfb0 (libc.so.6:rawmemchr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4944500 (libc.so.6:wmemchr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4944040 (libc.so.6:wcscmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492aa20 (libc.so.6:mempcpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492a850 (libc.so.6:bcmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929d40 (libc.so.6:strncmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929900 (libc.so.6:strcmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492a990 (libc.so.6:memset) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4944000 (libc.so.6:wcschr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929ca0 (libc.so.6:strnlen) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x49299e0 (libc.so.6:strcspn) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492ac50 (libc.so.6:strncasecmp) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929980 (libc.so.6:strcpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492ada0 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4945750 (libc.so.6:wcsnlen) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4944080 (libc.so.6:wcscpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929e50 (libc.so.6:strpbrk) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x49298b0 (libc.so.6:index) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929c60 (libc.so.6:strlen) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x49303a0 (libc.so.6:memrchr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492aca0 (libc.so.6:strcasecmp_l) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492a810 (libc.so.6:memchr) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4944150 (libc.so.6:wcslen) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x4929f80 (libc.so.6:strspn) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492aba0 (libc.so.6:stpncpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492ab40 (libc.so.6:stpcpy) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492bff0 (libc.so.6:strchrnul) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x492acf0 (libc.so.6:strncasecmp_l) redirected to 0x48301c0 (_vgnU_ifunc_wrapper) +--88053-- REDIR: 0x49fc8a0 (libc.so.6:__strrchr_avx2) redirected to 0x483d7d0 (rindex) +--88053-- REDIR: 0x49fca70 (libc.so.6:__strlen_avx2) redirected to 0x483dc70 (strlen) +--88053-- REDIR: 0x4925c90 (libc.so.6:malloc) redirected to 0x483a710 (malloc) +--88053-- REDIR: 0x49ffa80 (libc.so.6:__memcpy_avx_unaligned_erms) redirected to 0x48414b0 (memmove) +--88053-- REDIR: 0x49fc6b0 (libc.so.6:__strchrnul_avx2) redirected to 0x4841f40 (strchrnul) +--88053-- REDIR: 0x49ffa60 (libc.so.6:__mempcpy_avx_unaligned_erms) redirected to 0x4842050 (mempcpy) +--88053-- REDIR: 0x49262f0 (libc.so.6:free) redirected to 0x483b940 (free) +==88053== +==88053== HEAP SUMMARY: +==88053== in use at exit: 14 bytes in 1 blocks +==88053== total heap usage: 2 allocs, 1 frees, 4,110 bytes allocated +==88053== +==88053== Searching for pointers to 1 not-freed blocks +==88053== Checked 70,944 bytes +==88053== +==88053== 14 bytes in 1 blocks are definitely lost in loss record 1 of 1 +==88053== at 0x483A77F: malloc (vg_replace_malloc.c:307) +==88053== by 0x10933B: sdsnewlen (sds.c:99) +==88053== by 0x10947F: sdsnew (sds.c:156) +==88053== by 0x109266: main (main.c:13) +==88053== +==88053== LEAK SUMMARY: +==88053== definitely lost: 14 bytes in 1 blocks +==88053== indirectly lost: 0 bytes in 0 blocks +==88053== possibly lost: 0 bytes in 0 blocks +==88053== still reachable: 0 bytes in 0 blocks +==88053== suppressed: 0 bytes in 0 blocks +==88053== +==88053== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)