esp-idf/components
Ivan Grokhotkov 51d86081b8 gdbstub: fix thread list generation
This commit fixes an issue with gdbstub, where it would list threads
with TIDs 1 to N in qfThreadInfo/qsThreadInfo responses, and then
would tell GDB that the current TID is 0 in the qC response. This
caused an assertion failure in GDB, because it couldn't find the
thread structure corresponding to TID 0:

src/gdb/gdb/thread.c:93: internal-error: thread_info* inferior_thread(): Assertion `tp' failed.

The issue was caused by the logic of qfThreadInfo/qsThreadInfo.
If the "paniced" task index was 1, the code would report it in the
response to qfThreadInfo, and then mistakenly skip task with index 0
in qsThreadInfo, due to the use of pre-increment instead of a
post-increment.

With that issue fixed, GDB assertion doesn't happen anymore. However
the code contained a deeper problem, which manifested itself in the
fact that GDB would incorrectly show task index 0 as the current task,
after the above fix.

Previous version of the code assumed that when GDB requests the thread
list, it uses the first thread returned by the target as the "default"
thread, and subsequently shows the user that the program is stopped
in that thread. This assumption was incorrect. In fact, after
connecting to a remote target, GDB obtains information about the
"default" or "current" thread from two sources:
1. the 'thread' special register indicated in the status response
   ($T00thread;00000001#ee)
2. if the target has only sent the plain stop response ($T00#ee), GDB
   would ask for the current thread using a qC packet.
With that in mind, it is not necessary to report the paniced task as
the first task in qfThreadInfo response. We can simply returns the
tasks in their natural order, and then indicate the current task in
the qS packet response.

However even that change does not fully resolve the issues with task
list. The previous version of this code also incorrectly interpreted
the meaning of GDB TIDs -1 and 0. When GDB sends an "Hg0" command
early in the connection process, it doesn't expect the server to set
task 0 as the current task, as the code assumed. Rather, it tells the
server to "set any (arbitrary) task as the current one", and the most
logical thing to do for the server that is already in "stopped" state
is to keep the current task selection.

Since TID 0 has a special meaning in GDB remote protocol, gdbstub code
is now modified to map task indices (which start from 0) to GDB TIDs.
GDB TIDs are arbitrary, and for simplicity we keep the same order and
start counting them from 1.

The summary of all the above changes is:

1. Use "task index + 1" as the TID reported to GDB
2. Report the tasks in natural order; don't complicate the code to
   make the paniced task first in the list.
3. Centralize modification of 'current_task_index' and 'regfile'
   in the new 'set_active_task' function, to improve encapsulation.
2020-10-13 18:09:22 +02:00
..
app_trace apptrace: Fixes multiple defs of '__esp_apptrace_trax_eri_updated' for O2 builds 2020-09-29 18:19:34 +03:00
app_update bootloader: create public bootloader_flash.h header 2020-09-19 10:52:02 +08:00
asio asio: option to use wolfSSL as TLS stack for ASIO 2020-07-14 10:42:17 +00:00
bootloader esp32s3/bootloader: extend IRAM usage to 0x6000 2020-10-09 17:50:17 +08:00
bootloader_support Secure Boot V2: Fixes the OTA regression with secure boot in ESP32-V3 2020-10-12 07:15:16 +00:00
bt Merge branch 'bugfix/assert_no_IRAM_ATTR' into 'master' 2020-10-12 16:58:26 +08:00
cbor Update tinycbor submodule in ESP-IDF 2020-06-23 08:20:16 +00:00
cmock cmock: added cmock as component 2020-09-02 16:38:37 +08:00
coap coap: move mbedTLS config options from component to examples 2020-05-19 17:23:29 +05:30
console cmock: added cmock as component 2020-09-02 16:38:37 +08:00
cxx Removed C++ unit test 2020-09-21 01:32:23 +00:00
driver Merge branch 'feature/twai_isr_runs_with_cache_disabled' into 'master' 2020-10-12 20:18:36 +08:00
efuse global: enable build uinit test for esp32-s3 2020-09-22 15:15:03 +08:00
esp32 SHA: add HAL layer and refactor driver 2020-10-09 08:24:08 +00:00
esp32s2 SHA: add HAL layer and refactor driver 2020-10-09 08:24:08 +00:00
esp32s3 Merge branch 'feature/sha_hal' into 'master' 2020-10-12 15:15:28 +08:00
esp_adc_cal driver/adc: support for esp32s2 adc calibration scheme 2020-08-13 17:27:03 +08:00
esp_common esp32, esp32s2: create esp_pm component 2020-09-25 05:24:10 +00:00
esp_eth esp_eth_mac_esp32: optionally setup SMI GPIO's 2020-09-25 19:59:41 +08:00
esp_event cmock: added cmock as component 2020-09-02 16:38:37 +08:00
esp_gdbstub gdbstub: fix thread list generation 2020-10-13 18:09:22 +02:00
esp_hid cmock: added cmock as component 2020-09-02 16:38:37 +08:00
esp_http_client esp_http_client: Include port in host field 2020-09-30 15:39:42 +05:30
esp_http_server Merge branch 'feature/cmock_component' into 'master' 2020-09-10 16:06:20 +08:00
esp_https_ota esp_https_ota: fix error code formatting 2020-10-12 13:46:15 +02:00
esp_https_server https_server: Fix use of open_fn from application level 2020-09-09 08:00:20 +02:00
esp_ipc cmock: added cmock as component 2020-09-02 16:38:37 +08:00
esp_local_ctrl local-ctrl: fix memory allocation issues found by static analyser 2020-05-13 07:16:45 +02:00
esp_netif lwip/ipv6:ipv6 address get fail after wifi disconnect 2020-10-12 10:40:22 +08:00
esp_pm esp_pm: temporarily disable failing test 2020-09-29 18:35:47 +08:00
esp_ringbuf cmock: added cmock as component 2020-09-02 16:38:37 +08:00
esp_rom SHA: add HAL layer and refactor driver 2020-10-09 08:24:08 +00:00
esp_serial_slave_link soc: placeholder for esp32s3 HAL driver 2020-08-07 11:59:00 +08:00
esp_system Merge branch 'bugfix/deep_sleep_stub_heap_rtc_fast_mem' into 'master' 2020-10-13 06:17:50 +08:00
esp_timer ci: update configs to include/exclude esp_pm in unit test 2020-09-25 05:24:10 +00:00
esp_websocket_client Websocket client: avoid deadlock if stop called from event handler 2020-08-21 18:57:45 +08:00
esp_wifi esp_wifi: Update wifi lib 2020-10-10 09:03:55 +00:00
esp-tls esp32s2/esp_ds: Digital Signature software support 2020-09-22 18:31:31 +05:30
espcoredump espcoredump: fix exception when -thread-info fails 2020-10-02 16:54:32 +02:00
esptool_py Coredump config option rename throughout IDF 2020-09-30 20:22:27 +05:30
expat cmock: added cmock as component 2020-09-02 16:38:37 +08:00
fatfs fatfs: fix SPIRAM allocation not used due to Kconfig option name error 2020-09-14 18:30:31 +02:00
freemodbus docs: add warning for doxygen version 2020-09-03 13:48:40 +08:00
freertos freertos: don't create timer task if timer APIs are not used 2020-10-02 17:58:36 +02:00
hal Merge branch 'feature/twai_isr_runs_with_cache_disabled' into 'master' 2020-10-12 20:18:36 +08:00
heap cmock: added cmock as component 2020-09-02 16:38:37 +08:00
idf_test crypto accelerator support on esp32s3 2020-09-22 15:15:03 +08:00
jsmn
json cJSON: include only source file objects for cmake build 2020-02-05 11:14:23 +05:30
libsodium cmock: added cmock as component 2020-09-02 16:38:37 +08:00
log bringup esp32-s3 on FPGA 2020-09-22 15:15:03 +08:00
lwip lwip: Changed to C linkage for fixing bug when using mixed C/C++ code 2020-09-29 11:47:32 +02:00
mbedtls SHA: add HAL layer and refactor driver 2020-10-09 08:24:08 +00:00
mdns Coredump config option rename throughout IDF 2020-09-30 20:22:27 +05:30
mqtt Merge branch 'feature/cmock_component' into 'master' 2020-09-10 16:06:20 +08:00
newlib global: enable build uinit test for esp32-s3 2020-09-22 15:15:03 +08:00
nghttp nghttp2: upgrade to v1.41.0 release 2020-07-28 20:27:27 +05:30
nvs_flash NVS: put wild functions into namespace 2020-09-18 15:38:40 +08:00
openssl cmock: added cmock as component 2020-09-02 16:38:37 +08:00
partition_table parttool: make part_list an optional argument 2020-10-10 09:46:51 +08:00
perfmon cmock: added cmock as component 2020-09-02 16:38:37 +08:00
protobuf-c
protocomm protocomm_console.c: Check if memory is allocated to buf and if not then return ESP_ERR_NO_MEM error 2020-10-06 10:13:40 +05:30
pthread cmock: added cmock as component 2020-09-02 16:38:37 +08:00
sdmmc cmock: added cmock as component 2020-09-02 16:38:37 +08:00
soc Merge branch 'bugfix/deep_sleep_stub_heap_rtc_fast_mem' into 'master' 2020-10-13 06:17:50 +08:00
spi_flash Merge branch 'bugfix/esp_flash_erase_timeout' into 'master' 2020-10-12 12:49:36 +08:00
spiffs cmock: added cmock as component 2020-09-02 16:38:37 +08:00
tcp_transport tcp_transport: Added required API to support Digital Signature for SSL 2020-09-22 18:31:31 +05:30
tcpip_adapter Set default AP handlers in wifi_create_and_start_ap() 2020-09-08 11:36:07 +05:30
tinyusb Update tinyusb_cdcacm_write_flush to using ticks counting instead of the FreeRTOS timer 2020-10-08 09:42:44 +02:00
ulp global: enable build uinit test for esp32-s3 2020-09-22 15:15:03 +08:00
unity bringup esp32-s3 on FPGA 2020-09-22 15:15:03 +08:00
vfs bringup esp32-s3 on FPGA 2020-09-22 15:15:03 +08:00
wear_levelling global: enable build uinit test for esp32-s3 2020-09-22 15:15:03 +08:00
wifi_provisioning provisioning: use memcpy instead of strncpy for copying SSID 2020-09-17 12:59:22 +05:30
wpa_supplicant esp_wifi: Update wifi lib 2020-10-10 09:03:55 +00:00
xtensa esp32s2/3: Add missing stdlib includes 2020-10-09 15:05:41 +11:00