Skip to content

Commit fb192fd

Browse files
committed
Merge branch 'bugfix/spinlock_coredump_regressions' into 'master'
Bugfix/spinlock coredump regressions Closes IDF-1901 See merge request espressif/esp-idf!9559
2 parents ae3ac0e + 8e6d450 commit fb192fd

File tree

7 files changed

+10
-77
lines changed

7 files changed

+10
-77
lines changed

components/esp_gdbstub/src/gdbstub.c

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
static void init_task_info(void);
2323
static void find_paniced_task_index(void);
2424
static int handle_task_commands(unsigned char *cmd, int len);
25-
static void esp_gdbstub_send_str_as_hex(const char *str);
2625
#endif
2726

2827
static void send_reason(void);
@@ -77,6 +76,7 @@ void esp_gdbstub_panic_handler(esp_gdbstub_frame_t *frame)
7776
}
7877
}
7978

79+
8080
static void send_reason(void)
8181
{
8282
esp_gdbstub_send_start();
@@ -90,16 +90,6 @@ static uint32_t gdbstub_hton(uint32_t i)
9090
return __builtin_bswap32(i);
9191
}
9292

93-
#ifdef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS
94-
static void esp_gdbstub_send_str_as_hex(const char *str)
95-
{
96-
while (*str) {
97-
esp_gdbstub_send_hex(*str, 8);
98-
str++;
99-
}
100-
}
101-
#endif
102-
10393
/** Send all registers to gdb */
10494
static void handle_g_command(const unsigned char* cmd, int len)
10595
{
@@ -187,16 +177,6 @@ static bool get_task_handle(size_t index, TaskHandle_t *handle)
187177
return true;
188178
}
189179

190-
static eTaskState get_task_state(size_t index)
191-
{
192-
return s_scratch.tasks[index].eState;
193-
}
194-
195-
static int get_task_cpu_id(size_t index)
196-
{
197-
return s_scratch.tasks[index].xCpuId;
198-
}
199-
200180
/** Get the index of the task running on the current CPU, and save the result */
201181
static void find_paniced_task_index(void)
202182
{
@@ -308,34 +288,12 @@ static void handle_qThreadExtraInfo_command(const unsigned char* cmd, int len)
308288
return;
309289
}
310290
esp_gdbstub_send_start();
311-
esp_gdbstub_send_str_as_hex("Name: ");
312-
esp_gdbstub_send_str_as_hex(pcTaskGetTaskName(handle));
313-
esp_gdbstub_send_hex(' ', 8);
314-
315-
eTaskState state = get_task_state(task_index);
316-
switch (state) {
317-
case eRunning:
318-
esp_gdbstub_send_str_as_hex("State: Running ");
319-
esp_gdbstub_send_str_as_hex("@CPU");
320-
esp_gdbstub_send_hex(get_task_cpu_id(task_index) + '0', 8);
321-
break;
322-
case eReady:
323-
esp_gdbstub_send_str_as_hex("State: Ready");
324-
break;
325-
case eBlocked:
326-
esp_gdbstub_send_str_as_hex("State: Blocked");
327-
break;
328-
case eSuspended:
329-
esp_gdbstub_send_str_as_hex("State: Suspended");
330-
break;
331-
case eDeleted:
332-
esp_gdbstub_send_str_as_hex("State: Deleted");
333-
break;
334-
default:
335-
esp_gdbstub_send_str_as_hex("State: Invalid");
336-
break;
291+
const char* task_name = pcTaskGetTaskName(handle);
292+
while (*task_name) {
293+
esp_gdbstub_send_hex(*task_name, 8);
294+
task_name++;
337295
}
338-
296+
/** TODO: add "Running" or "Suspended" and "CPU0" or "CPU1" */
339297
esp_gdbstub_send_end();
340298
}
341299

components/freertos/include/freertos/task.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ typedef struct xTASK_SNAPSHOT
199199
StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */
200200
StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo
201201
pxTopOfStack > pxEndOfStack, stack grows lo2hi*/
202-
eTaskState eState; /*!< Current state of the task. Can be running or suspended */
203-
BaseType_t xCpuId; /*!< CPU where this task was running */
204202
} TaskSnapshot_t;
205203

206204
/**

components/freertos/tasks.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5057,26 +5057,6 @@ TickType_t uxReturn;
50575057
}
50585058
pxTaskSnapshotArray[ *uxTask ].pxTCB = pxTCB;
50595059
pxTaskSnapshotArray[ *uxTask ].pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack;
5060-
pxTaskSnapshotArray[ *uxTask ].eState = eTaskGetState(pxTCB);
5061-
5062-
if(pxTaskSnapshotArray[ *uxTask ].eState == eRunning)
5063-
{
5064-
BaseType_t xCoreId = xPortGetCoreID();
5065-
/* task is running, let's find in which core it is located */
5066-
if(pxTCB == pxCurrentTCB[xCoreId])
5067-
{
5068-
pxTaskSnapshotArray[ *uxTask ].xCpuId = xCoreId;
5069-
}
5070-
else
5071-
{
5072-
pxTaskSnapshotArray[ *uxTask ].xCpuId = !xCoreId;
5073-
}
5074-
}
5075-
else
5076-
{
5077-
pxTaskSnapshotArray[ *uxTask ].xCpuId = -1;
5078-
}
5079-
50805060
#if( portSTACK_GROWTH < 0 )
50815061
{
50825062
pxTaskSnapshotArray[ *uxTask ].pxEndOfStack = pxTCB->pxEndOfStack;

components/freertos/test/test_tasks_snapshot.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ TEST_CASE("Tasks snapshot", "[freertos]")
2727
esp_cpu_stall(other_core_id);
2828
#endif
2929
UBaseType_t task_num = uxTaskGetSnapshotAll(tasks, TEST_MAX_TASKS_NUM, &tcb_sz);
30-
for (uint32_t i = 0; i < task_num; i++) {
31-
TEST_ASSERT_EQUAL(tasks[i].eState, eTaskGetState(tasks[i].pxTCB));
32-
}
3330
#ifndef CONFIG_FREERTOS_UNICORE
3431
esp_cpu_unstall(other_core_id);
3532
#endif

components/freertos/xtensa/include/freertos/portmacro.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static inline uint32_t xPortGetCoreID(void);
144144
// They can be called from interrupts too.
145145
// WARNING: Only applies to current CPU. See notes above.
146146
static inline unsigned portENTER_CRITICAL_NESTED(void) {
147-
unsigned state = XTOS_SET_MIN_INTLEVEL(XCHAL_EXCM_LEVEL);
147+
unsigned state = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
148148
portbenchmarkINTERRUPT_DISABLE();
149149
return state;
150150
}

components/soc/include/soc/spinlock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static inline bool __attribute__((always_inline)) spinlock_acquire(spinlock_t *l
6767
uint32_t core_id, other_core_id;
6868

6969
assert(lock);
70-
irq_status = XTOS_SET_MIN_INTLEVEL(XCHAL_EXCM_LEVEL);
70+
irq_status = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
7171

7272
if(timeout != SPINLOCK_WAIT_FOREVER){
7373
RSR(CCOUNT, ccount_start);
@@ -139,7 +139,7 @@ static inline void __attribute__((always_inline)) spinlock_release(spinlock_t *l
139139
uint32_t core_id;
140140

141141
assert(lock);
142-
irq_status = XTOS_SET_MIN_INTLEVEL(XCHAL_EXCM_LEVEL);
142+
irq_status = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
143143

144144
RSR(PRID, core_id);
145145
assert(core_id == lock->owner); // This is a mutex we didn't lock, or it's corrupt

docs/en/api-guides/fatal-errors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ If :doc:`IDF Monitor <tools/idf-monitor>` is used, GDB is started automatically
186186
36 *((int*) 0) = 0;
187187
(gdb)
188188

189-
GDB prompt can be used to inspect CPU registers, local and static variables, state of created tasks by issuing "info thread" command on the GDB prompt, and arbitrary locations in memory. It is not possible to set breakpoints, change PC, or continue execution. To reset the program, exit GDB and perform external reset: Ctrl-T Ctrl-R in IDF Monitor, or using external reset button on the development board.
189+
GDB prompt can be used to inspect CPU registers, local and static variables, and arbitrary locations in memory. It is not possible to set breakpoints, change PC, or continue execution. To reset the program, exit GDB and perform external reset: Ctrl-T Ctrl-R in IDF Monitor, or using external reset button on the development board.
190190

191191
Guru Meditation Errors
192192
----------------------

0 commit comments

Comments
 (0)