libs/libc:Support gdb rsp protocol
you can debug nuttx through any transport layer (serial port, network etc.), currently supports the following functions: 1. Read and write registers 2. Read and write memory 3. Switch thread and read stack information Future support plans: 1. Support breakpoint, watch point (requires architecture support). related information: https://sourceware.org/gdb/onlinedocs/gdb/Remote-Protocol.html Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
97309dd22d
commit
b956495c5e
113
include/nuttx/gdbstub.h
Normal file
113
include/nuttx/gdbstub.h
Normal file
@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/gdbstub.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_GDBSTUB_H
|
||||
#define __INCLUDE_NUTTX_GDBSTUB_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
struct gdb_state_s;
|
||||
typedef CODE ssize_t (*gdb_send_func_t)(FAR void *priv, FAR void *buf,
|
||||
size_t len);
|
||||
typedef CODE ssize_t (*gdb_recv_func_t)(FAR void *priv, FAR void *buf,
|
||||
size_t len);
|
||||
|
||||
typedef CODE int (*gdb_monitor_func_t)(FAR struct gdb_state_s *state,
|
||||
FAR const char *cmd);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gdb_state_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize the GDB state structure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* send - The pointer to the send function.
|
||||
* recv - The pointer to the receive function.
|
||||
* monitor - The pointer to the monitor function.
|
||||
* priv - The pointer to the private data.
|
||||
*
|
||||
* Returned Value:
|
||||
* The pointer to the GDB state structure on success.
|
||||
* NULL on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct gdb_state_s *gdb_state_init(gdb_send_func_t send,
|
||||
gdb_recv_func_t recv,
|
||||
gdb_monitor_func_t monitor,
|
||||
FAR void *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gdb_state_uninit
|
||||
*
|
||||
* Description:
|
||||
* Uninitialize the GDB state structure.
|
||||
*
|
||||
* Input Parameters:
|
||||
* state - The pointer to the GDB state structure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void gdb_state_uninit(FAR struct gdb_state_s *state);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gdb_console_message
|
||||
*
|
||||
* Description:
|
||||
* Send a message to the GDB console (via O XX... packet).
|
||||
*
|
||||
* Input Parameters:
|
||||
* state - The pointer to the GDB state structure.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success.
|
||||
* Negative value on error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int gdb_console_message(FAR struct gdb_state_s *state, FAR const char *msg);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gdb_process
|
||||
*
|
||||
* Description:
|
||||
* Main debug loop. Handles commands.
|
||||
*
|
||||
* Input Parameters:
|
||||
* state - The pointer to the GDB state structure.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero if successful.
|
||||
* Negative value on error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int gdb_process(FAR struct gdb_state_s *state);
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_GDBSTUB_H */
|
@ -14,6 +14,7 @@ source "libs/libc/string/Kconfig"
|
||||
source "libs/libc/pthread/Kconfig"
|
||||
source "libs/libc/dlfcn/Kconfig"
|
||||
source "libs/libc/modlib/Kconfig"
|
||||
source "libs/libc/gdbstub/Kconfig"
|
||||
source "libs/libc/grp/Kconfig"
|
||||
source "libs/libc/pwd/Kconfig"
|
||||
source "libs/libc/locale/Kconfig"
|
||||
|
@ -30,6 +30,7 @@ include dlfcn/Make.defs
|
||||
include errno/Make.defs
|
||||
include eventfd/Make.defs
|
||||
include fixedmath/Make.defs
|
||||
include gdbstub/Make.defs
|
||||
include grp/Make.defs
|
||||
include hex2bin/Make.defs
|
||||
include inttypes/Make.defs
|
||||
|
20
libs/libc/gdbstub/Kconfig
Normal file
20
libs/libc/gdbstub/Kconfig
Normal file
@ -0,0 +1,20 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config LIB_GDBSTUB
|
||||
tristate "GDBSTUB"
|
||||
depends on DEBUG_TCBINFO
|
||||
---help---
|
||||
Enable support for gdbstub.
|
||||
|
||||
if LIB_GDBSTUB
|
||||
|
||||
config LIB_GDBSTUB_DEBUG
|
||||
bool "Gdbstub Debug Info"
|
||||
default n
|
||||
---help---
|
||||
Add debug info to gdbstub
|
||||
|
||||
endif
|
32
libs/libc/gdbstub/Make.defs
Normal file
32
libs/libc/gdbstub/Make.defs
Normal file
@ -0,0 +1,32 @@
|
||||
############################################################################
|
||||
# libs/libc/gdbstub/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_LIB_GDBSTUB),y)
|
||||
|
||||
# Add the internal C files to the build
|
||||
|
||||
CSRCS += lib_gdbstub.c
|
||||
|
||||
# Add the userfs directory to the build
|
||||
|
||||
DEPPATH += --dep-path gdbstub
|
||||
VPATH += :gdbstub
|
||||
|
||||
endif
|
1559
libs/libc/gdbstub/lib_gdbstub.c
Normal file
1559
libs/libc/gdbstub/lib_gdbstub.c
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user