From 5d8bffd11b0e8fb997778d986a3de46e03ab6146 Mon Sep 17 00:00:00 2001 From: John Franklin Date: Mon, 19 Oct 2015 10:10:23 -0500 Subject: [PATCH 1/2] print loom and fix a range calculation in u3e_fault() --- noun/events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/noun/events.c b/noun/events.c index 7b6c89d92..a32fc0b9f 100644 --- a/noun/events.c +++ b/noun/events.c @@ -115,8 +115,9 @@ u3e_fault(void* adr_v, c3_i ser_i) { c3_w* adr_w = (c3_w*) adr_v; - if ( (adr_w < u3_Loom) || (adr_w > (u3_Loom + u3a_words)) ) { + if ( (adr_w < u3_Loom) || (adr_w >= (u3_Loom + u3a_words)) ) { fprintf(stderr, "address %p out of loom!\r\n", adr_v); + fprintf(stderr, "loom: [%p : %p)\r\n", u3_Loom, u3_Loom + u3a_words); c3_assert(0); return 0; } From fcc8e8ada239a2d468b5b8f767fd1caf1d4da5c3 Mon Sep 17 00:00:00 2001 From: John Franklin Date: Mon, 19 Oct 2015 03:33:25 -0500 Subject: [PATCH 2/2] Add notes on debugging with gdb. --- CONTRIBUTING.md | 24 ++++++++++++++++++++++++ Makefile | 10 +++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bb9d596b3..a67b830ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -145,6 +145,30 @@ Just do the same procedure to create a new, merged pill before committing the merge. Otherwise, just make sure to use the correct `urbit.pill` for each commit. +## Debug urbit with `gdb` + +Follow the build instructions in README.md but run `make` with argument `DEBUG=yes`: + +(If you've already built urbit first run `make clean`.) + + make DEBUG=yes + +Run `gdb`, while loading `bin/urbit` and its symbol table: + + gdb bin/urbit + +Set a breakpoint on `main()` (optional): + + break main + +Run your urbit comet `mycomet`: + + run mycomet + +Continue from the breakpoint on `main()`: + + continue + ## What to work on If you are not thinking of contributing with a specific goal in mind, diff --git a/Makefile b/Makefile index 7160cb2c2..a4ed3c502 100644 --- a/Makefile +++ b/Makefile @@ -70,10 +70,18 @@ endif INCLUDE=include MDEFINES=-DU3_OS_$(OS) -DU3_OS_ENDIAN_$(ENDIAN) -D U3_LIB=\"$(LIB)\" +DEBUG=no + +ifeq ($(DEBUG),yes) +DEBUGFLAGS=-g +else +DEBUGFLAGS=-O3 +endif + # NOTFORCHECKIN - restore -O3 # -DGHETTO \ # -DHUSH -CFLAGS= $(COSFLAGS) -O3 -ffast-math \ +CFLAGS= $(COSFLAGS) $(DEBUGFLAGS) -ffast-math \ -funsigned-char \ -I/usr/local/include \ -I/opt/local/include \