Skip to content

Commit 7b8e8c9

Browse files
GorrayLiRbb666
authored andcommitted
[components/lwp]add doxygen comment for lwp_dbg.c.
1 parent adc3e2c commit 7b8e8c9

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

components/lwp/lwp_dbg.c

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1+
/*
2+
* Copyright (c) 2006-2025 RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2023-07-11 RT-Thread first version
9+
*/
110
#include <rtthread.h>
211
#include <rthw.h>
312
#include <lwp.h>
413

14+
/**
15+
* @brief Check if the current thread is in debug state.
16+
*
17+
* @return int Returns 1 if the thread is in debug state, 0 otherwise.
18+
*/
519
int dbg_thread_in_debug(void)
620
{
721
int ret = 0;
@@ -17,12 +31,30 @@ int dbg_thread_in_debug(void)
1731
struct dbg_ops_t *rt_dbg_ops = RT_NULL;
1832
RTM_EXPORT(rt_dbg_ops);
1933

34+
/**
35+
* @brief Register debugger operations.
36+
*
37+
* @param dbg_ops Pointer to debugger operations structure.
38+
*/
2039
void dbg_register(struct dbg_ops_t *dbg_ops)
2140
{
2241
rt_dbg_ops = dbg_ops;
2342
}
2443
RTM_EXPORT(dbg_register);
2544

45+
/**
46+
* @brief Debug command handler function
47+
*
48+
* @param[in] argc Number of command arguments
49+
* @param[in] argv Array of command argument strings
50+
*
51+
* @return int Returns the result from the debug operations handler if available,
52+
* otherwise returns -1 to indicate failure
53+
*
54+
* @note This function serves as a wrapper for debug operations, delegating to the registered
55+
* debug operations handler if available. If no debug operations are registered,
56+
* it prints an error message.
57+
*/
2658
static int dbg(int argc, char **argv)
2759
{
2860
int ret = -1;
@@ -39,6 +71,16 @@ static int dbg(int argc, char **argv)
3971
}
4072
MSH_CMD_EXPORT(dbg, dbg);
4173

74+
/**
75+
* @brief Get the current instruction value from debug operations
76+
*
77+
* @return uint32_t Returns the current instruction value if debug operations are available,
78+
* otherwise returns 0
79+
*
80+
* @note This function retrieves the current instruction value by calling the registered
81+
* debug operations handler if available. If no debug operations are registered,
82+
* it returns 0.
83+
*/
4284
uint32_t dbg_get_ins(void)
4385
{
4486
uint32_t ins = 0;
@@ -50,6 +92,12 @@ uint32_t dbg_get_ins(void)
5092
return ins;
5193
}
5294

95+
/**
96+
* @brief Activates single-step debugging mode if debug operations are registered
97+
*
98+
* @note This function checks if debug operations are registered (rt_dbg_ops) and if so,
99+
* calls the architecture-specific single-step activation function.
100+
*/
53101
void dbg_activate_step(void)
54102
{
55103
if (rt_dbg_ops)
@@ -58,6 +106,12 @@ void dbg_activate_step(void)
58106
}
59107
}
60108

109+
/**
110+
* @brief Deactivates single-step debugging mode if debug operations are registered
111+
*
112+
* @note This function checks if debug operations are registered (rt_dbg_ops) and if so,
113+
* calls the architecture-specific single-step deactivation function.
114+
*/
61115
void dbg_deactivate_step(void)
62116
{
63117
if (rt_dbg_ops)
@@ -66,6 +120,18 @@ void dbg_deactivate_step(void)
66120
}
67121
}
68122

123+
/**
124+
* @brief Checks for debug events and processes them if debug operations are registered
125+
*
126+
* @param[in] regs Pointer to the hardware exception stack containing register values
127+
* @param[in] esr Exception Syndrome Register value
128+
*
129+
* @return int Returns the result from the debug event check (0 if no debug operations registered)
130+
*
131+
* @note This function checks if debug operations are registered (rt_dbg_ops) and if so,
132+
* calls the debug event checking function with the provided registers and exception status.
133+
* If no debug operations are registered, it returns 0.
134+
*/
69135
int dbg_check_event(struct rt_hw_exp_stack *regs, unsigned long esr)
70136
{
71137
int ret = 0;
@@ -77,6 +143,15 @@ int dbg_check_event(struct rt_hw_exp_stack *regs, unsigned long esr)
77143
return ret;
78144
}
79145

146+
/**
147+
* @brief Gets the GDB server communication channel if debug operations are registered
148+
*
149+
* @return rt_channel_t Returns the GDB server channel (RT_NULL if no debug operations registered)
150+
*
151+
* @note This function checks if debug operations are registered (rt_dbg_ops) and if so,
152+
* retrieves the GDB server communication channel from the registered operations.
153+
* If no debug operations are registered, it returns RT_NULL.
154+
*/
80155
rt_channel_t gdb_server_channel(void)
81156
{
82157
rt_channel_t ret = RT_NULL;
@@ -88,6 +163,15 @@ rt_channel_t gdb_server_channel(void)
88163
return ret;
89164
}
90165

166+
/**
167+
* @brief Gets the current step type from debug operations
168+
*
169+
* @return int The current step type (0 if no debug operations are registered)
170+
*
171+
* @note This function checks if debug operations are registered (rt_dbg_ops) and if so,
172+
* retrieves the current step type from the registered debug operations.
173+
* If no debug operations are registered, it returns 0.
174+
*/
91175
int dbg_step_type(void)
92176
{
93177
int ret = 0;
@@ -99,6 +183,14 @@ int dbg_step_type(void)
99183
return ret;
100184
}
101185

186+
/**
187+
* @brief Handles debug attach request
188+
*
189+
* @param[in] pc Pointer to the program counter value
190+
*
191+
* @note This function checks if debug operations are registered and calls
192+
* the debug attach request handler if available.
193+
*/
102194
void dbg_attach_req(void *pc)
103195
{
104196
if (rt_dbg_ops)
@@ -107,6 +199,14 @@ void dbg_attach_req(void *pc)
107199
}
108200
}
109201

202+
/**
203+
* @brief Checks if debug suspend is requested
204+
*
205+
* @return int Returns the suspend status (0 if no debug operations are registered)
206+
*
207+
* @note This function checks if debug operations are registered and calls
208+
* the debug suspend check handler if available.
209+
*/
110210
int dbg_check_suspend(void)
111211
{
112212
int ret = 0;

0 commit comments

Comments
 (0)