Skip to content

Commit

Permalink
Minor gdb fixes (#1662)
Browse files Browse the repository at this point in the history
* Add missing return value from `HardwareSerial::updateUartCallback()`

* Fix debug statement in `GdbFileStream::open()`

* Make sure debug output appears before exception message

* Missing nullptr check in `uart_get_status()`
  • Loading branch information
mikee47 authored and slaff committed Apr 10, 2019
1 parent 4c0fb66 commit fee27ee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sming/SmingCore/Data/Stream/GdbFileStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool GdbFileStream::open(const String& fileName, FileOpenFlags openFlags)
this->size = size;
gdb_syscall_lseek(fd, 0, SEEK_SET);
pos = 0;
debug_d("opened file: '%s' (%u bytes) #0x%08X", fileName().c_str(), size, this);
debug_d("opened file: '%s' (%u bytes) #0x%08X", fileName.c_str(), size, this);
}
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions Sming/SmingCore/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ bool HardwareSerial::updateUartCallback()
statusMask = mask;

setUartCallback(mask == 0 ? nullptr : staticCallbackHandler, this);

return mask != 0;
}

void HardwareSerial::commandProcessing(bool reqEnable)
Expand Down
3 changes: 3 additions & 0 deletions Sming/appspecific/gdb/gdb_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void debug_print_stack(uint32_t start, uint32_t end)
void debug_crash_callback(const rst_info* rst_info, uint32_t stack, uint32_t stack_end)
{
#ifdef ENABLE_GDB
gdbFlushUserData();
if(gdb_state.attached) {
m_setPuts(gdbWriteConsole);
}
Expand Down Expand Up @@ -159,6 +160,8 @@ static void __attribute__((noinline)) gdbstub_exception_handler_flash(UserFrame*
gdbstub_savedRegs.a[1] = uint32_t(frame) + EXCEPTION_GDB_SP_OFFSET;

#if defined(ENABLE_GDB) && GDBSTUB_BREAK_ON_EXCEPTION
gdbFlushUserData();

// If GDB is attached, temporarily redirect m_printf calls to the console
nputs_callback_t oldPuts = nullptr;
if(gdb_state.attached) {
Expand Down
8 changes: 5 additions & 3 deletions Sming/system/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,11 @@ uint8_t uart_get_status(uart_t* uart)
uart->status = 0;
// Read raw status register directly from real uart, masking out non-error bits
uart = get_physical(uart);
status |= USIR(uart->uart_nr) & (_BV(UIBD) | _BV(UIOF) | _BV(UIFR) | _BV(UIPE));
// Clear errors
USIC(uart->uart_nr) = status;
if(uart != nullptr) {
status |= USIR(uart->uart_nr) & (_BV(UIBD) | _BV(UIOF) | _BV(UIFR) | _BV(UIPE));
// Clear errors
USIC(uart->uart_nr) = status;
}
uart_restore_interrupts();
}
return status;
Expand Down

0 comments on commit fee27ee

Please sign in to comment.