clibs / debug Goto Github PK
View Code? Open in Web Editor NEWConditional debug logging for C
License: MIT License
Conditional debug logging for C
License: MIT License
[ . . . ]
test.c: In function ‘_debug_foobar’:
test.c:10:1: warning: implicit declaration of function ‘vasprintf’ [-Wimplicit-function-declaration]
test.c:10:1: warning: left-hand operand of comma expression has no effect [-Wunused-value]
test.c:10:1: warning: statement with no effect [-Wunused-value]
test.c: In function ‘_debug_foo_bar’:
test.c:11:1: warning: left-hand operand of comma expression has no effect [-Wunused-value]
test.c:11:1: warning: statement with no effect [-Wunused-value]
test.c: In function ‘_debug_foobaz’:
test.c:12:1: warning: left-hand operand of comma expression has no effect [-Wunused-value]
test.c:12:1: warning: statement with no effect [-Wunused-value]
test.c: In function ‘_debug_active’:
test.c:13:1: warning: left-hand operand of comma expression has no effect [-Wunused-value]
test.c:13:1: warning: statement with no effect [-Wunused-value]
test.c: In function ‘_debug_inactive’:
test.c:14:1: warning: left-hand operand of comma expression has no effect [-Wunused-value]
test.c:14:1: warning: statement with no effect [-Wunused-value]
I know vasprintf
is my fault. It's nonstandard or whatever :/
No idea how we'd handle it with the current impl (may need a rewrite :/), but I'd greatly appreciate being able to use non-alphanumberic chars when defining debugs.
For example:
debug_init(clib);
debug_init(clib:install);
debug_init(clib:search);
debug_init(clib:help);
We're only requesting an array with one element, which causes nasal demons:
$ DEBUG=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z ./test
*** glibc detected *** ./test: double free or corruption (out): 0x0000000000ab7030 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7f0010080b96]
./test[0x4009b9]
./test[0x400868]
./test[0x400beb]
./test[0x4006ce]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f001002376d]
./test[0x400765]
======= Memory map: ========
00400000-00402000 r-xp 00000000 ca:01 1058172 /home/stephen/debug/test
00601000-00602000 r--p 00001000 ca:01 1058172 /home/stephen/debug/test
00602000-00603000 rw-p 00002000 ca:01 1058172 /home/stephen/debug/test
00ab7000-00ad8000 rw-p 00000000 00:00 0 [heap]
7f000fdec000-7f000fe01000 r-xp 00000000 ca:01 142751 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f000fe01000-7f0010000000 ---p 00015000 ca:01 142751 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f0010000000-7f0010001000 r--p 00014000 ca:01 142751 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f0010001000-7f0010002000 rw-p 00015000 ca:01 142751 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f0010002000-7f00101b7000 r-xp 00000000 ca:01 133594 /lib/x86_64-linux-gnu/libc-2.15.so
7f00101b7000-7f00103b7000 ---p 001b5000 ca:01 133594 /lib/x86_64-linux-gnu/libc-2.15.so
7f00103b7000-7f00103bb000 r--p 001b5000 ca:01 133594 /lib/x86_64-linux-gnu/libc-2.15.so
7f00103bb000-7f00103bd000 rw-p 001b9000 ca:01 133594 /lib/x86_64-linux-gnu/libc-2.15.so
7f00103bd000-7f00103c2000 rw-p 00000000 00:00 0
7f00103c2000-7f00103e4000 r-xp 00000000 ca:01 142709 /lib/x86_64-linux-gnu/ld-2.15.so
7f00105d4000-7f00105d7000 rw-p 00000000 00:00 0
7f00105e1000-7f00105e4000 rw-p 00000000 00:00 0
7f00105e4000-7f00105e5000 r--p 00022000 ca:01 142709 /lib/x86_64-linux-gnu/ld-2.15.so
7f00105e5000-7f00105e7000 rw-p 00023000 ca:01 142709 /lib/x86_64-linux-gnu/ld-2.15.so
7fff22444000-7fff22465000 rw-p 00000000 00:00 0 [stack]
7fff22510000-7fff22511000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted (core dumped)
i'd like to add debug()
s to clib(1), but would like to namespace the debuggers with clib
(makes sense, right?).
doing this would require me to:
$ DEBUG=clib,clib_package,clib_install clib install user/repo
but this would be much nicer:
$ DEBUG=clib* clib install user/repo
It would make DEBUG=*
legible with many debuggers enabled.
See the js impl for examples
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.