Resolved: Gdb Watchpoints with Daisy SIGTRAP Encountered

Hello, I seem to come across a strange issue when debugging using watchpoints.

Background:
Currently, I have a bug where a variable called release is being changed unexpectedly, most of the time 1-2 seconds after I set the knob’s value. Since I could not see the point where the value wildly changes from a very lower number to 820 (nor could I see any point in code that would cause this vast difference), I figured that I would try to get to the root of the problem by seeing when the value changes.

However, now that I am using these watchpoints, I will continuously get this SIGTRAP error where the issue seems to occur when the daisysp oscillator phase counter is incrementing:

<code>
(gdb) monitor halt
(gdb) monitor reset
(gdb) monitor halt
target halted due to debug-request, current mode: Handler External Interrupt(12)
xPSR: 0x8100001c pc: 0x08001a3e msp: 0x2001fe48
(gdb) watch release
Hardware watchpoint 8: release
(gdb) continue
Continuing.
halted: PC: 0x08001a42

Breakpoint 7, UpdateKnobs () at PolySynth.cpp:376
376         for(int i = 0; i < MAX_NUM_VOICES; ++i)
(gdb) delete 7
(gdb) continue
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
UpdateKnobs () at PolySynth.cpp:379
379                 Voices[i].ad.SetTime(ADENV_SEG_DECAY, release);
(gdb) p/f release
$10 = 0.0032043457
(gdb) continue
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
UpdateKnobs () at PolySynth.cpp:379
379                 Voices[i].ad.SetTime(ADENV_SEG_DECAY, release);
(gdb) p/f release
$11 = 0.104888916
(gdb) continue
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x08018b24 in daisysp::Oscillator::CalcPhaseInc(float) ()
(gdb) bt full
#00x08018b24 in daisysp::Oscillator::CalcPhaseInc(float) ()
No symbol table info available.
#10x08000dac in daisysp::Oscillator::SetFreq (f=659.255127,
this=<optimized out>) at ../../DaisySP/modules/oscillator.h:58
No locals.
#2HandleMidiMessage (m=...) at PolySynth.cpp:187
        tmpFreq = 659.255127
        p = <optimized out>
        p = <optimized out>
#30x080010d8 in main () at ../../libdaisy/src/util_ringbuffer.h:71
        sample_rate = 48014
</code>


What's also strange is that I only get SIGTRAP when I add watchpoints.

Has anyone else encountered any similar issues when debugging with daisy?


Environment:
Windows
Daisy Pod
STM32 Link V3
arm-none-eabi-gdb
OpenOcd

Setup:
Daisy Library was recompiled with DEBUG = 1
My project's Makefile was compiled with DEBUG = 1

Make Target for Debugging:

DEBUG_BUILD_OPTIONS= --eval-command=“target remote localhost:3333”
DEBUG_BUILD_OPTIONS+= --eval-command=“monitor reset halt”
DEBUG_BUILD_OPTIONS+= --eval-command=“monitor flash erase_address 0x8000000 0x20000”
DEBUG_BUILD_OPTIONS+= --eval-command=“monitor reset halt”
DEBUG_BUILD_OPTIONS+= --eval-command=“monitor halt”
DEBUG_BUILD_OPTIONS+= --eval-command=“file $(PROJECT_LOCATION)/build/ex_PolySynth.elf”
DEBUG_BUILD_OPTIONS+= --eval-command=“load”

my_debug:
         arm-none-eabi-gdb.exe $(DEBUG_BUILD_OPTIONS)

Edit:
After a refined search, I found the following: https://stackoverflow.com/questions/3475262/what-causes-a-sigtrap-in-a-debug-session
It seems that using SIGTRAP is the normally used SIGNAL by the processor for handling breakpoints. After looking at the trace one more time, I realized that I was mistakenly accessing an out of bounds element in one of my arrays.