Changeset d574e08 in rtems


Ignore:
Timestamp:
10/17/22 05:25:57 (8 months ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
468f21e
Parents:
1d2fab8
git-author:
Chris Johns <chrisj@…> (10/17/22 05:25:57)
git-committer:
Chris Johns <chrisj@…> (10/17/22 20:37:57)
Message:

libdebugger: Add a target break call to suspend all running threads

  • Optionally wait if there is no remote debugger connected and break when the remote connects

Closes #4740

Location:
cpukit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/debugger/rtems-debugger-server.h

    r1d2fab8 rd574e08  
    104104#define RTEMS_DEBUGGER_FLAG_VERBOSE_LOCK (1 << 5)
    105105#define RTEMS_DEBUGGER_FLAG_VERBOSE_CMDS (1 << 6)
     106#define RTEMS_DEBUGGER_FLAG_BREAK_WAITER (1 << 7)
    106107
    107108/**
  • cpukit/include/rtems/rtems-debugger.h

    r1d2fab8 rd574e08  
    5555
    5656/**
     57 * Suspend all running threads including the caller if not
     58 * excluded. Returns when the debugger has connected and continued.
     59 *
     60 * If wait is true and there is no remote connected wait then break.
     61 */
     62extern int rtems_debugger_break(bool wait);
     63
     64/**
    5765 * Stop the Debugger.
    5866 */
  • cpukit/libdebugger/rtems-debugger-server.c

    r1d2fab8 rd574e08  
    16791679  rtems_debugger_target_enable();
    16801680
    1681   while (rtems_debugger_server_events_running()) {
    1682     rtems_debugger_server_events_wait();
     1681  if (rtems_debugger_server_flag(RTEMS_DEBUGGER_FLAG_BREAK_WAITER)) {
     1682    rtems_debugger->flags &= ~RTEMS_DEBUGGER_FLAG_BREAK_WAITER;
     1683    r = rtems_debugger_thread_system_suspend();
    16831684    if (rtems_debugger_verbose())
    1684       rtems_debugger_printf("rtems-db: event woken\n");
    1685     if (!rtems_debugger_server_events_running())
    1686       break;
    1687     r = rtems_debugger_thread_system_suspend();
    1688     if (r < 0)
    1689       break;
    1690     r = remote_stop_reason(NULL, 0);
    1691     if (r < 0)
    1692       break;
     1685      rtems_debugger_printf("rtems-db: break waiter\n");
     1686    rtems_debugger_server_events_signal();
     1687    if (rtems_debugger_verbose())
     1688      rtems_debugger_printf("rtems-db: break waiter: signalled\n");
     1689  }
     1690
     1691  if (r == 0) {
     1692    while (rtems_debugger_server_events_running()) {
     1693      rtems_debugger_server_events_wait();
     1694      if (rtems_debugger_verbose())
     1695        rtems_debugger_printf("rtems-db: event woken\n");
     1696      if (!rtems_debugger_server_events_running())
     1697        break;
     1698      r = rtems_debugger_thread_system_suspend();
     1699      if (r < 0)
     1700        break;
     1701      r = remote_stop_reason(NULL, 0);
     1702      if (r < 0)
     1703        break;
     1704    }
    16931705  }
    16941706
     
    19741986
    19751987int
     1988rtems_debugger_break(bool wait)
     1989{
     1990  int r = 0;
     1991  if (!rtems_debugger_running()) {
     1992    errno = EIO;
     1993    r = -1;
     1994  } else {
     1995    rtems_debugger_lock();
     1996    if (rtems_debugger_server_events_running()) {
     1997      rtems_debugger_server_events_signal();
     1998    } else if (
     1999      wait && !rtems_debugger_server_flag(RTEMS_DEBUGGER_FLAG_BREAK_WAITER)) {
     2000      rtems_debugger->flags |= RTEMS_DEBUGGER_FLAG_BREAK_WAITER;
     2001      rtems_debugger_server_events_wait();
     2002    } else {
     2003      errno = EIO;
     2004      r = -1;
     2005    }
     2006    rtems_debugger_unlock();
     2007  }
     2008  return r;
     2009}
     2010
     2011int
    19762012rtems_debugger_stop(void)
    19772013{
     
    19992035rtems_debugger_remote_debug(bool state)
    20002036{
    2001   rtems_debugger_lock();
    2002   rtems_debugger->remote_debug = state;
    2003   rtems_debugger_printf("rtems-db: remote-debug is %s\n",
    2004                         rtems_debugger->remote_debug ? "on" : "off");
    2005   rtems_debugger_unlock();
    2006   return 0;
    2007 }
     2037  if (rtems_debugger_running()) {
     2038    rtems_debugger_lock();
     2039    rtems_debugger->remote_debug = state;
     2040    rtems_debugger_printf("rtems-db: remote-debug is %s\n",
     2041                          rtems_debugger->remote_debug ? "on" : "off");
     2042    rtems_debugger_unlock();
     2043  } else {
     2044    rtems_debugger_printf("rtems-db: debug server not running\n");
     2045  }
     2046  return 0;
     2047}
Note: See TracChangeset for help on using the changeset viewer.