|
| 1 | +/**************************************************************************** |
| 2 | + * include/nuttx/gdbstub.h |
| 3 | + * |
| 4 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 5 | + * contributor license agreements. See the NOTICE file distributed with |
| 6 | + * this work for additional information regarding copyright ownership. The |
| 7 | + * ASF licenses this file to you under the Apache License, Version 2.0 (the |
| 8 | + * "License"); you may not use this file except in compliance with the |
| 9 | + * License. You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 16 | + * License for the specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + * |
| 19 | + ****************************************************************************/ |
| 20 | + |
| 21 | +#ifndef __INCLUDE_NUTTX_GDBSTUB_H |
| 22 | +#define __INCLUDE_NUTTX_GDBSTUB_H |
| 23 | + |
| 24 | +/**************************************************************************** |
| 25 | + * Included Files |
| 26 | + ****************************************************************************/ |
| 27 | + |
| 28 | +#include <stdlib.h> |
| 29 | + |
| 30 | +/**************************************************************************** |
| 31 | + * Type Definitions |
| 32 | + ****************************************************************************/ |
| 33 | + |
| 34 | +struct gdb_state_s; |
| 35 | +typedef CODE ssize_t (*gdb_send_func_t)(FAR void *priv, FAR void *buf, |
| 36 | + size_t len); |
| 37 | +typedef CODE ssize_t (*gdb_recv_func_t)(FAR void *priv, FAR void *buf, |
| 38 | + size_t len); |
| 39 | + |
| 40 | +typedef CODE int (*gdb_monitor_func_t)(FAR struct gdb_state_s *state, |
| 41 | + FAR const char *cmd); |
| 42 | + |
| 43 | +/**************************************************************************** |
| 44 | + * Name: gdb_state_init |
| 45 | + * |
| 46 | + * Description: |
| 47 | + * Initialize the GDB state structure. |
| 48 | + * |
| 49 | + * Input Parameters: |
| 50 | + * send - The pointer to the send function. |
| 51 | + * recv - The pointer to the receive function. |
| 52 | + * monitor - The pointer to the monitor function. |
| 53 | + * priv - The pointer to the private data. |
| 54 | + * |
| 55 | + * Returned Value: |
| 56 | + * The pointer to the GDB state structure on success. |
| 57 | + * NULL on failure. |
| 58 | + * |
| 59 | + ****************************************************************************/ |
| 60 | + |
| 61 | +FAR struct gdb_state_s *gdb_state_init(gdb_send_func_t send, |
| 62 | + gdb_recv_func_t recv, |
| 63 | + gdb_monitor_func_t monitor, |
| 64 | + FAR void *priv); |
| 65 | + |
| 66 | +/**************************************************************************** |
| 67 | + * Name: gdb_state_uninit |
| 68 | + * |
| 69 | + * Description: |
| 70 | + * Uninitialize the GDB state structure. |
| 71 | + * |
| 72 | + * Input Parameters: |
| 73 | + * state - The pointer to the GDB state structure. |
| 74 | + * |
| 75 | + ****************************************************************************/ |
| 76 | + |
| 77 | +void gdb_state_uninit(FAR struct gdb_state_s *state); |
| 78 | + |
| 79 | +/**************************************************************************** |
| 80 | + * Name: gdb_console_message |
| 81 | + * |
| 82 | + * Description: |
| 83 | + * Send a message to the GDB console (via O XX... packet). |
| 84 | + * |
| 85 | + * Input Parameters: |
| 86 | + * state - The pointer to the GDB state structure. |
| 87 | + * |
| 88 | + * Returned Value: |
| 89 | + * Zero on success. |
| 90 | + * Negative value on error. |
| 91 | + * |
| 92 | + ****************************************************************************/ |
| 93 | + |
| 94 | +int gdb_console_message(FAR struct gdb_state_s *state, FAR const char *msg); |
| 95 | + |
| 96 | +/**************************************************************************** |
| 97 | + * Name: gdb_process |
| 98 | + * |
| 99 | + * Description: |
| 100 | + * Main debug loop. Handles commands. |
| 101 | + * |
| 102 | + * Input Parameters: |
| 103 | + * state - The pointer to the GDB state structure. |
| 104 | + * |
| 105 | + * Returned Value: |
| 106 | + * Zero if successful. |
| 107 | + * Negative value on error. |
| 108 | + * |
| 109 | + ****************************************************************************/ |
| 110 | + |
| 111 | +int gdb_process(FAR struct gdb_state_s *state); |
| 112 | + |
| 113 | +#endif /* __INCLUDE_NUTTX_GDBSTUB_H */ |
0 commit comments