aboutsummaryrefslogtreecommitdiff
path: root/src/server
AgeCommit message (Collapse)AuthorFilesLines
2024-05-04ipdbg: fix double free of virtual-ir dataDaniel Anselmi1-7/+6
Fix possible double free and possible memory leak while creating an ipdbg hub. Change-Id: I6254663c27c4f38d46008c4dbff11aa27b84f399 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/8085 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-03-24gdb_server: drop useless check in gdb_keep_client_alive()Antonio Borneo1-5/+2
OpenOCD can send it's log to gdb, and gdb replies with 'OK'. Calls to LOG_XXX() are also present in the code that communicates with gdb. This can cause infinite nested calls. OpenOCD uses the flag 'gdb_con->busy' to protect the communication with gdb and prevent nested calls. There is no reason to check for 'gdb_con->busy' in the code for keep-alive, as keep_alive() is never called in this gdb server; the flag would eventually be set if the current keep_alive() will send something to gdb. Drop the flag 'gdb_con->busy' in gdb_keep_client_alive(). While there, document the use of 'gdb_con->busy'. Change-Id: I1ea20bf96abb5d2f1fcdba1e3861df257c396bb6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8166 Tested-by: jenkins
2024-03-24gdb_server: add async-notif keep-alive during memory read/writeAntonio Borneo1-6/+46
To avoid gdb to timeout, OpenOCD implements a keep-alive mechanism that consists in sending periodically to gdb empty strings embedded in the "O" remote reply packet. The main purpose of "O" packets is to forward in the gdb console the output of the remote execution; the gdb-remote puts in the "O" packet the string that gdb will print. It's use is restricted to few "running/execution" contexts listed in http://sourceware.org/gdb/onlinedocs/gdb/Stop-Reply-Packets.html and this currently limits the keep-alive capabilities of OpenOCD. Long data transfer (memory R/W) can also cause gdb to timeout if the interface is too slow. In this case the usual keep-alive based on "O" packet cannot be used and, if used, would trigger a protocol error that causes the transfer to be dropped. The slow transfer rate can be simulated by adding some delay in the main loop of mem_ap_write() and mem_ap_read(), then using the gdb commands "dump" and "restore". In the wait loop during a memory R/W, gdb drops any extra character received from the gdb-remote that is not recognized as a valid reply to the memory command. Every dropped character re-initializes the timeout counter and could be used as keep-alive. From gdb 7.0 (released 2009-10-06), an asynchronous notification can also be received from gdb-remote during a memory R/W and has the effect to reset the timeout counter, thus can be used as keep-alive. The notification would be treated as "junk" extra characters by any gdb older than 7.0, being still valid as keep-alive. Check putpkt_binary() and getpkt_sane() in gdb commit 74531fed1f2d662debc2c209b8b3faddceb55960 Currently, only one notification packet ("Stop") is recognized by gdb, and gdb documentation reports that notification packets that are not recognized should be silently dropped. Use 'set debug remote 1' in gdb to dump the received notifications and the junk extra characters. Add a new level in enum gdb_output_flag for using the asynchronous notifications. Activate this new level during memory transfers. Send a custom "oocd_keepalive" notification packet as keep_alive. While there, drop a useless return in the switch/case, already managed in case of break. After this commit, the proper calls to keep_alive() have to be added in the loops that code the memory transfers. Of course, the keep_alive() should be placed during the wait for JTAG flush, not while locally queuing the JTAG elementary transfers. Change-Id: I9ca8e78630611597d15984bd0e8634c8fc3c32b9 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8165 Tested-by: jenkins
2024-03-16ipdbg: configurable queue size used between JTAG-Host and JTAG-HubDaniel Anselmi1-14/+54
Change-Id: I7941de02a968ccab730bfebd3483b8c3b84d7e53 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7980 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2024-03-16ipdbg: split ipdbg command into multiple commandsDaniel Anselmi3-139/+280
To simplify the ipdbg start/stop command and be able to add additional commands in the future, we introduce the concept of a hub which has to be created before a ipdbg server can be started. The hub was created on the fly in previous versions. Change-Id: I55f317542d01a7324990b2cacd496a41fa5ff875 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7979 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2024-03-09gdb_server: fix segfault with GDB command 'flash-erase'Antonio Borneo1-0/+7
Running the GDB command 'flash-erase' triggers sending the remote GDB commands 'vFlashErase' (one per flash bank) followed by one single 'vFlashDone', with no 'vFlashWrite' commands in between. This causes the field 'gdb_connection->vflash_image' to be NULL during the execution of 'vFlashDone', triggering a segmentation fault in OpenOCD. While parsing 'vFlashDone', check if any image to flash has been received. Change-Id: I443021c7a531255b60f2c44c2685e52e3c34b5c8 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8164 Tested-by: jenkins
2024-03-02gdb_server: don't send unrequested ACK at connectionAntonio Borneo1-3/+0
On 2008-03-05, before git's age, commit 6d9501467441 adds sending an ACK ('+' char) at GDB connection, before receiving any GDB remote command that requires to be ACK'ed. Neither the text added in the commit message ("added ACK upon connection (send +)") nor in the associated comment ("send ACK to GDB for debug request") provide an exhaustive explanation for sending this unsolicited ACK. This code has never been touched since its introduction. Analysis of GDB code doesn't show it's required, including old GDB code. Running gdbserver (from GDB package) and attaching it with "nc" shows that gdbserver does not send any ACK to a new connection. Same for lldb-server. Drop it! Change-Id: Id68c352ce44dd85a1ea3d67446e17e2a241ef058 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6768 Tested-by: jenkins Reviewed-by: Jan Matyas <jan.matyas@codasip.com> Reviewed-by: Anatoly P <anatoly.parshintsev@syntacore.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2024-02-17server/gdb-server: fix type error.wangyanwen1-4/+5
Fix flash operation error when addr-width > 32bit on any 32-bit OS and some 64-bit OS (windows). Change-Id: I199f1cc5128c45bd0bb155e37acb2fb6325dff88 Signed-off-by: wangyanwen <wangyanwen@nucleisys.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8095 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2024-01-13ipdbg: improve ipdbg-host speedDaniel Anselmi1-67/+209
By queuing multiple jtag transfers the connection speed between JTAG-Host and JTAG-Hub is improved. This is due to much less calls to OS functions. An improvement of about x30 has been measured with ftdi-based jtag adapters For this to work the JTAG-Host server needs to know if flow control is enabled on the JTAG-Hub ports. This is possible with newer JTAG-Hub/JtagCDC. For old JTAG-Hubs the queuing is not enabled so this change is backwards compatible. Change-Id: I8a5108adbe2a2c1e3d3620b5c9ff77a546bfc14e Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7978 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-12-24break from long loops on shutdown requestEvgeniy Naydanov1-0/+1
In loops that typically take longer time to complete, check if there is a pending shutdown request. If so, terminate the loop. This allows to respond to a signal requesting a shutdown during some loops which do not return control to main OpenOCD loop. Change-Id: Iace0b58eddde1237832d0f9333a7c7b930565674 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8032 Reviewed-by: Jan Matyas <jan.matyas@codasip.com> Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-11-24rtt_server: Add option for a message when client connectsThiemo van Engelen1-3/+21
This is useful when using the SEGGER RTT tooling, as the SEGGER RTT tool J-Link RTT Viewer version 7.84f requires that it receives a messages immediately after connecting. Otherwise it will give a timeout and it will not connect. Change-Id: I9240a1b6a93cd5c0fbd18292afb33b89013d78bf Signed-off-by: Thiemo van Engelen <tvanengelen@victronenergy.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7752 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-10-14server/gdb_server: Log gdb index in debug messages.Tim Newsome1-13/+20
This makes it easier to look at log files where multiple gdb instances are connected. Change-Id: Ic5aca52b32ee03ac35ffbed9a2fc552abb0a1cba Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7895 Reviewed-by: Jan Matyas <jan.matyas@codasip.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2023-09-17server/gdb_server.c: support unavailable registersEvgeniy Naydanov1-19/+30
According to gdb documentation, `g` and `p` packets can report a register being unavailable by a string of 'x' instead of register's value. Change-Id: I8ef279f1357c2e612f5d3290eb0022c1b47d9fa7 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7876 Reviewed-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Anatoly Parshintsev <kupokupokupopo@gmail.com> Tested-by: jenkins
2023-08-08breakpoints: use 64-bit type for watchpoint mask and valueParshintsev Anatoly1-1/+1
This patch changes data types of watchpoint value and mask to allow for 64-bit values match that some architectures (like RISCV) allow. In addition this patch fixes the behavior of watchpoint command to zero-out mask if only data value is provided. Change-Id: I3c7ec1630f03ea9534ec34c0ebe99e08ea56e7f0 Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7840 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Marek Vrbka <marek.vrbka@codasip.com> Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-07-14ipdbg: fix 'double free' in case of failed startDaniel Anselmi1-3/+1
Change-Id: Id241d9dd0793095106fea000422617fbef462669 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7770 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2023-07-08ipdbg/pld: ipdbg can get tap and hub/ir from pld driver.Daniel Anselmi1-1/+31
To start a ipdbg server one needs to know the tap and the instruction code to reach the IPDBG-Hub. This instruction is vendor/family specific. Knowledge which can be provided by the pld driver. Change-Id: I13eeb9fee895d65cd48544da4704fcc9b528b869 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7369 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-06-10gdb_server: refactor and unify function gdb_get_char_innerMarek Vrbka1-31/+12
The old implementation of gdb socket error handling in the gdb_get_char_inner() differs between Windows and *nix platforms. This patch simplifies it by using an existing function log_socket_error() which handles most of the platform specific things. It also provides better error messages. Change-Id: Iec871c4965b116dc7cfb03c3565bab66c8b41958 Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7724 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-06-10gdb_server: add debug signal reason printsMarek Vrbka1-2/+7
Added debug prints to show what is the target debug reason. Also added debug print for Ctrl-C response. This is useful for troubleshooting and log analysis. Change-Id: I055936257d989efe7255656198a8d73a367fcd15 Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7720 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2023-05-18server: gdb: export gdb_actual_connections through a functionAntonio Borneo2-1/+9
The internal variable 'gdb_actual_connections' is used by log and by semihosting to determine if there are active GDB connections. Keep the variable local in server's code and only export its value through a dedicated function. This solves the issue detected by 'parse' of the variable defined as global but not declared in any include file. Change-Id: I6e14f4cb1097787404094636f8a2a291340222dd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7673 Tested-by: jenkins
2023-04-30src: fix clang15 compiler warningsErhan Kurubas1-6/+2
Below warnings are fixed. 1- A function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] 2- error: variable set but not used [-Werror,-Wunused-but-set-variable] Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: I1cf14b8e5e3e732ebc9cacc4b1cb9009276a8ea9 Reviewed-on: https://review.openocd.org/c/openocd/+/7569 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2023-04-30server/ipdbg: add error checks after allocating memoryDaniel Anselmi1-1/+22
Change-Id: Icf18a855eb66d2b09789a9ee27f5fbc4cd9afc89 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7605 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-04-14src/server: Fix memory leak of reg_listpanciyan1-0/+1
memory leak of reg_list when local_list realloc fail. Signed-off-by: panciyan <panciyan@eswincomputing.com> Change-Id: I6b09137ecd132ab326205f5a575a38bcc82e8469 Reviewed-on: https://review.openocd.org/c/openocd/+/7566 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-04-07ipdbg: whitespacesDaniel Anselmi1-9/+9
Change-Id: I9294c551cf2e795ad5e3e92dc3926c564424e067 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7399 Tested-by: jenkins Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-18openocd: fix SPDX tag format for files .cAntonio Borneo6-6/+6
With the old checkpatch we cannot use the correct format for the SPDX tags in the file .c, in fact the C99 comments are not allowed and we had to use the block comment. With the new checkpatch, let's switch to the correct SPDX format. Change created automatically through the command: sed -i \ 's,^/\* *\(SPDX-License-Identifier: .*[^ ]\) *\*/$,// \1,' \ $(find src/ contrib/ -name \*.c) Change-Id: I6da16506baa7af718947562505dd49606d124171 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7153 Tested-by: jenkins
2022-09-03server: add function to get openocd shutdown statusErhan Kurubas2-0/+7
In the app-trace module we are polling the target in the while loops outside of the server.c In that loops, we need to catch ctrl+c signal by checking shutdown_openocd status Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: Id87c709a01470bf6d3642078b160a68ca85f4406 Reviewed-on: https://review.openocd.org/c/openocd/+/7142 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-08-27server/server: fix target timer timingTomas Vanek1-4/+7
The change 6363: Call poll at a fixed interval switched from target_call_timer_callbacks() to target_call_timer_callbacks_now(). It breaks the timing as all timers callbacks are called every time one timer expires. Revert this part of change and use target_call_timer_callbacks(). Fixes: db16b3dc5b06 (Call poll at a fixed interval.) Change-Id: Ib5b7774de9694d40c55d2a4109d0d1582fc5008b Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7118 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-08-20server/gdb_server: Add support for default thread, use by IDA debuggerMadSquirrel1-93/+92
Signed-off-by: Benoit Forgette <benoit.forgette@ci-yow.com> Change-Id: Ia3a29a3377be650f0ccad11a0ae4fe4da78b3ab4 Reviewed-on: https://review.openocd.org/c/openocd/+/7017 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-08-15gdb_server: custom target-specific GDB queriesIan Thompson1-0/+5
Provide a customizable hook for handling target-specific GDB queries Valgrind-clean, no new Clang analyzer warnings Signed-off-by: Ian Thompson <ianst@cadence.com> Change-Id: I684a259ed29f3651cbce668101cff421e522f79e Reviewed-on: https://review.openocd.org/c/openocd/+/7082 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-08-15gdb_server: support sparse register mapsIan Thompson1-2/+6
Add additional error handling for targets where gaps may exist in reg_list[] Signed-off-by: Ian Thompson <ianst@cadence.com> Change-Id: I65232429e2de08f5d54eeca53aea0db8ce2b58af Reviewed-on: https://review.openocd.org/c/openocd/+/7103 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-08-15gdb_server: add "not supported" Z-packet replyIan Thompson1-2/+8
GDB remote serial protocol specifies breakpoint/watchpoint packet responses can be an empty string to indicate the specified breakpoint type is not supported. Add support for this response alongside existing "OK", "E NN" replies. Signed-off-by: Ian Thompson <ianst@cadence.com> Change-Id: Iaf6280e4c936eb95a92bc80cc74d451ebb328dc3 Reviewed-on: https://review.openocd.org/c/openocd/+/7102 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-07-23openocd: src: replace the GPL-2.0-or-later license tagAntonio Borneo10-130/+20
Replace the FSF boilerplate with the SPDX tag. The SPDX tag on files *.c is incorrect, as it should use the C99 single line comment using '//'. But current checkpatch doesn't allow C99 comments, so keep using standard C comments, by now. Change-Id: I30cd66ac7d737f1973c68fdbb841ffcf00e917c4 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7072 Tested-by: jenkins
2022-07-23openocd: build: add SPDX tagAntonio Borneo2-0/+4
Add the SPDX tag to makefiles, configuration scripts and tcl files present in the folders under src/ Change-Id: I1e4552aafe46ef4893d510da9d732c5f181784a4 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7051 Tested-by: jenkins
2022-06-10telnet_server: fix scan-build warningTarek BOCHKATI1-1/+5
fix "Declared variable-length array (VLA) has zero size" warning raised in .../src/server/telnet_server.c:633:2: Change-Id: Icff5228b02790c472b212a86a3849b1a3df98fdb Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6565 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-06-08telnet_server: fix valgrind errorErhan Kurubas1-10/+1
Error: Uninitialised value was created by a heap allocation at telnet_new_connection (telnet_server.c:227) Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: I698a3648be698c93a2395a718ee1ade028226995 Reviewed-on: https://review.openocd.org/c/openocd/+/7006 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-05-14openocd: add post-init and pre-shutdown helpersAntonio Borneo1-0/+2
It is a common requirement to automatically execute some command after "init". This can be achieved, either in scripts or through OpenOCD command line, by explicitly calling "init" followed by the commands. But this approach fails if the request for post-init commands is spread across configuration files; only one of the files can split pre-init and post-init status by calling "init". The common workaround is to "rename" the command "init" and replace it with a TCL proc that calls the original "init" and the post-init commands. E.g. in Zephyr script [1]. To simplify and formalize the post-init execution, use a TCL list that contains the list of commands to be executed. Every script can contribute adding new commands, e.g. using "lappend". In the same way, formalize the pre-shutdown execution with a TCL list of user commands to be executed before OpenOCD exit. Document them and add trivial examples. Drop from documentation the suggestion to rename "shutdown". Change-Id: I9464fb40ccede3e7760d425873adca363b49a64f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Link: [1] https://github.com/zephyrproject-rtos/zephyr/blob/zephyr-v2.7.1/boards/arm/nucleo_h743zi/support/openocd.cfg#L15 Reviewed-on: https://review.openocd.org/c/openocd/+/6851 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-05-07server/gdb: fix gdb remote monitor cmd on multi-targetAntonio Borneo1-4/+16
Commit 5ebb1bdea1df ("server/gdb: fix return of gdb remote monitor command") replaces the call to command_run_line() with call to Jim_EvalObj() but does not properly set the "context". In multi-target environment, his can cause the erroneously execution of the command on the wrong target. Copy from the code in command_run_line() the proper setup before executing Jim_EvalObj(). Change-Id: I56738c80779082ca146a06c01bc30e28bc835fd3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Bohdan Tymkiv <bohdan200@gmail.com> Fixes: 5ebb1bdea1df ("server/gdb: fix return of gdb remote monitor command") Reviewed-on: https://review.openocd.org/c/openocd/+/6966 Tested-by: jenkins Reviewed-by: Bohdan Tymkiv <bohdan200@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Tim Newsome <tim@sifive.com>
2022-05-07smp: deprecate legacy SMP core switching supportAntonio Borneo1-0/+2
The deprecation was already in the documentation since v0.11.0 through commit 85ba2dc4c6ab ("rtos/hwthread: add hardware-thread pseudo rtos") but OpenOCD was not informing the user printing a runtime message. Remove the deprecated method from the documentation and print a deprecated message at runtime. There is no reliable way to print the same message in GDB console, so we have to rely on user noticing it in the OpenOCD log. Target is to remove the functionality after v0.12.0. Change-Id: Idd2d9e3b6eccc92dcf0432c3c7de2f8a0fcabe9f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6862 Tested-by: jenkins
2022-04-23server/gdb: fix return of gdb remote monitor commandAntonio Borneo1-1/+42
Current implementation for gdb remote monitor command uses the command_run_line() to execute the command. While command_run_line() has several advantages, it unfortunately hides the error codes and outputs the result of the command through LOG_USER(), which is not what gdb requires. See 'qRcmd' in https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html Replace command_run_line() with Jim_EvalObj() and parse the output to provide the proper result to gdb. Can be tested by defining in OpenOCD: proc a {} {return hello} proc b {} {return -code 4} proc c {} {return -code 4 "This is an error!"} then by executing in gdb console: monitor a monitor b monitor c monitor foo Change-Id: I1b85554d59221560e97861a499e16764e70c1172 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Torbjorn Svensson <torbjorn.svensson@st.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6886 Tested-by: jenkins
2022-04-03gdb_server: Improve logging of GDB-remote packetsJan Matyas1-14/+31
- Print also the target name, not just the packet contents. This is important when there are more GDB servers (more debug-able targets) active in one OpenOCD session. - Log also the received Ctrl-C requests coming from GDB (one byte 0x3), ACKs ("+") and NACKs ("-"). - Do not print zero-length incoming packets (this occurred when Ctrl-C packets were received). - Removed a stray apostrophe "'" that got printed in gdb_log_outgoing_packet() Signed-off-by: Jan Matyas <matyas@codasip.com> Change-Id: If68fe0a8aa635165d0bbe6fa0e48a4645a02da67 Reviewed-on: https://review.openocd.org/c/openocd/+/6879 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-26openocd: include config.h in every file .cAntonio Borneo1-0/+4
Including config.h as first is required for every C file. Add it to the C files that still miss it. Change-Id: I1a210e7d3a854958a85a290b086ad8a9f5176425 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6856 Tested-by: jenkins
2022-03-19keep-alive: drop link with log frameworkAntonio Borneo3-1/+33
OpenOCD implements the GDB keep-alive by sending empty strings as output for GDB client. This has been implemented as part of the log framework, creating an odd dependency. Move the keep-alive notifications out of log framework. For the moment, keep keep_alive() inside log.c, but it should be moved in server.c This should also fix an old issue with KDE Konsole when tab alert for activity is enabled. The empty strings is sent to all the connections, including telnet, and causes the tab running OpenOCD telnet to continuously show activity even when no new text is printed. Anyway, I cannot replicate this issue anymore. Change-Id: Iebb00b00fb74b3c9665d9e1ddd3c055275bfbd43 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6840 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-19gdb_server: simplify logic to enable/disable gdb_log_callback()Antonio Borneo1-13/+29
GDB client cannot always display generic messages from OpenOCD. The callback gdb_log_callback() is continuously added and removed to follow the GDB status and thus enabling/disabling sending the OpenOCD output to GDB. While this is a nice stress test for log_{add,remove}_callback(), it is also a waste of computational resources that could impact the speed of OpenOCD during GDB user interactions. Add a connection-level flag to enable/disable the log callback and simply change the flag instead of adding/removing the callback. Use an enum for the flag instead of a bool. This improves code readability and allows setting other states, e.g. keep-alive through asynchronous notification https://review.openocd.org/4828/ Change-Id: I072d3c6928dedfd0cef0abe7acf9bdd4b89dbf5b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6839 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-19server: change prototype of add_service()Antonio Borneo7-35/+86
To easily add new methods to a service, pass all the methods through a struct. While there, drop the typedef for the methods and add currently unused new methods to support keep-alive and connections during keep-alive. No change in functionality. Change-Id: I2b5e7140db95021f6e7201e9d631ee340c60b453 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6838 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-19server: fix: remove kept_alive() from server loopAntonio Borneo1-1/+0
The kept_alive() action is specific of a server that enjoyed an unscheduled keep_alive and want to communicate it to the keep alive logic to reschedule next keep_alive(). In server loop we are not expected to call kept_alive(). Remove it! This call was erroneously added in commit 94e75e0c06c4. Later, commit 7442b26d45dc properly added the same call in gdb_put_packet(), but incorrectly left the older in place. Change-Id: If476410f870eebfbdaccdb1366ba2e9254e2fdf6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6836 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-02-26gdb_server: check target examined while combining reg listAntonio Borneo1-0/+12
Commit 6541233aa78d ("Combine register lists of smp targets.") assumes that all the targets in the SMP cluster are already examined and unconditionally call target_get_gdb_reg_list_noread() that will in turn return error if the target is not examined yet. Skip targets not examined yet. Add an additional check in case the register list cannot be built, e.g. because no target in the SMP cluster is examined. This should never happen, but it's better to play safe. Change-Id: I8609815c3d5144790fb05a870cb0c931540aef8a Fixes: 6541233aa78d ("Combine register lists of smp targets.") Reported-by: Michele Bisogno <michele.bisogno.ct@renesas.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6853 Tested-by: jenkins Reviewed-by: Michele Bisogno <michele.bisogno.ct@renesas.com> Reviewed-by: Tim Newsome <tim@sifive.com>
2022-02-26gdb_server: fix double freeAntonio Borneo1-15/+17
Commit 6541233aa78d ("Combine register lists of smp targets.") unconditionally assigns the output pointers of the function smp_reg_list_noread(), even if the function fails and returns error. This causes a double free from the caller, that has assigned NULL to the pointers to simplify the error handling. Use local variables in smp_reg_list_noread() and assign the output pointers only on success. Change-Id: Ic0fd2f26520566cf322f0190780e15637c01cfae Fixes: 6541233aa78d ("Combine register lists of smp targets.") Reported-by: Michele Bisogno <michele.bisogno.ct@renesas.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6852 Tested-by: jenkins Reviewed-by: Michele Bisogno <michele.bisogno.ct@renesas.com> Reviewed-by: Tim Newsome <tim@sifive.com>
2022-02-14server: remove remaining crust from dropped eCos codeAntonio Borneo4-42/+0
Commit 39650e2273bc ("ecosboard: delete bit-rotted eCos code") has removed eCos code but has left some empty function that was used during non-eCos build to replace eCos mutex. Drop the functions and the file that contain them. Change-Id: I31bc0237ea699c11bd70921660f960ee406ffa80 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6835 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-02-14gdb_server: Include thread name as XML attributeBen McMorran1-2/+8
Explicitly providing a thread name in the "thread" element produces better thread visualizations in downstream tools like IDEs. Signed-off-by: Ben McMorran <bemcmorr@microsoft.com> Change-Id: I102c14ddb8b87757fa474de8e3a3f6a1cfe10d98 Reviewed-on: https://review.openocd.org/c/openocd/+/6828 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-02-14target/smp: use a struct list_head to hold the smp targetsAntonio Borneo1-7/+4
Instead of reinventing a simply linked list, reuse the list helper for the list of targets in a smp cluster. Using the existing helper, that implements a double linked list, makes trivial going through the list in reverse order. Change-Id: Ib36ad2955f15cd2a601b0b9e36ca6d948b12d00f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6783 Tested-by: jenkins
2022-01-29Combine register lists of smp targets.Tim Newsome1-2/+104
This is helpful when you want to pretend to gdb that your heterogeneous multicore system is homogeneous, because gdb cannot handle heterogeneous systems. This won't always works, but works fine if e.g. one of the cores has an FPU while the other does not. (Specifically, HiFive Unleashed has 1 core with no FPU, plus 4 cores with an FPU.) Signed-off-by: Tim Newsome <tim@sifive.com> Change-Id: I05ff4c28646778fbc00327bc510be064bfe6c9f0 Reviewed-on: https://review.openocd.org/c/openocd/+/6362 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>