aboutsummaryrefslogtreecommitdiff
path: root/src/helper
AgeCommit message (Collapse)AuthorFilesLines
2023-05-18server: gdb: export gdb_actual_connections through a functionAntonio Borneo1-3/+2
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-05-18helper: types: rework h_u32_to_le() and similar for sparseAntonio Borneo1-18/+18
The static analyser 'sparse' complains about values bigger that 255 that gets cast-ed and/or stored in an 8 bit variable. Rework the functions: - h_u32_to_le() - h_u32_to_be() - h_u24_to_le() - h_u24_to_be() - h_u16_to_le() - h_u16_to_be() to avoid all the related warnings, without adding any functional change. Any modern compiler should not be impacted by this. Change-Id: I0b84043600a41c72d0e4ddb3dd195d69e3b2896b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7670 Tested-by: jenkins
2023-05-18helper: replacements: rework including replacements.hAntonio Borneo2-8/+11
The static analyser 'sparse' complains that the functions clear_malloc() and fill_malloc() are defined global but not cross checked against a prototype in an include file. Rework replacements.h and replacements.c to let the former be included by the latter. Change-Id: I536393a9c3718dcd7e144cde8f02e169f64c88e0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7667 Tested-by: jenkins
2023-05-05helper: with pointers, use NULL instead of 0Antonio Borneo3-8/+8
Don't compare pointers with 0, use NULL when needed. Don't assign pointer to 0, use NULL. Don't pass 0 ad pointer argument, pass NULL. Detected through 'sparse' tool. Change-Id: I3f867cb9c0903f6e396311e7b3970ee5fb3a4231 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7597 Tested-by: jenkins
2023-05-05helper: util: include util.hAntonio Borneo1-0/+1
Let source file to include its file .h to validate the exported prototypes. Detected through 'sparse' tool. Change-Id: I5de107b4f8a468f0e37f06171f5f0c3c0546db1a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7596 Tested-by: jenkins
2023-04-07helper/compiler fix build with gcc on MacOSAntonio Borneo1-2/+4
On MacOS libc includes files from MacOSX.sdk that define the macro #define __nonnull without arguments, causing compile error. Extend the existing check for clang on MacOS and undefine the macro for gcc too. Change-Id: Ic99de78348c6aa86561212a3aded9342e5d32e02 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Erhan Kurubas <erhan.kurubas@espressif.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7571 Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com> Tested-by: jenkins
2023-04-07helper/list: re-align with Linux kernel 6.3-rc1Antonio Borneo1-8/+58
Minor changes due to kernel switch to 100 char/line. Added four new functions. Silent checkpatch; we don't want to diverge from Linux reference code. Checkpatch-ignore: MACRO_ARG_REUSE, UNNECESSARY_PARENTHESES Checkpatch-ignore: MACRO_ARG_PRECEDENCE Change-Id: I1d2ff25bf3bab8cd0f5c9be55c7501795490ea75 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7568 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-04-07helper/list: remove unused hlist_*Antonio Borneo1-238/+1
The file list.h is taken from Linux and includes two similar implementation of double linked lists: - with single linked list's head (hlist_*), and - with double linked list's head (list_*). While the former offers a minor memory footprint improvement, keeping two implementations makes harder for newbie developers to approach them. So far only the latter implementation has been used and no new patches in gerrit is going to change that. Drop the support for lists with single linked head. It can be easily taken back from git history, if needed. Change-Id: I420e5de38ab755fdfbeb2115538c61818308ec2b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7567 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-03-25helper: util: rewrite command 'ms' as COMMAND_HANDLERAntonio Borneo1-13/+6
Use full 64 bits in output; no reason to truncate at 32 bits. Change-Id: I433815a381e147731ff0da2c805170649a9bcf38 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7487 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2023-03-25helper: command: rewrite command 'ocd_find' as COMMAND_HANDLERAntonio Borneo1-10/+10
The mixed use of jim commands and OpenOCD commands is error prone due to handling of errors through JIM_xx and ERROR_yy. Rewrite the jim command 'ocd_find' as OpenOCD command. Change-Id: Id775bccc12840bcf95d8c19787beda5e7c3107fc Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7484 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2023-03-25helper/compiler: fix build on MacOSAntonio Borneo1-0/+8
On MacOS, clang defines [1]: #define __nonnull _Nonnull that creates incompatibility with GCC and with the macro __nonnull defined in some libc. Detect clang on MacOS and undefine __nonnull. Change-Id: I64fcf51b102ea91c196e657debd8c267943a2b08 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Links: [1] https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0/clang/lib/Frontend/InitPreprocessor.cpp#L1226 Reviewed-on: https://review.openocd.org/c/openocd/+/7544 Tested-by: jenkins
2023-03-18openocd: drop JIM_EMBEDDED macroAntonio Borneo1-3/+0
The macro JIM_EMBEDDED was required to be defined before including jim.h in applications that embed jimtcl. This requirement has been dropped in 2010 by removing the file dos/Embedder-HOWTO.txt from jimtcl in https://github.com/msteveb/jimtcl/commit/2d8564100c86#diff-3e93fa55e666 Drop the macro definition and the comment that mandates it. Change-Id: I36883f60f25bb25839e4ebf908159569659764dd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7518 Tested-by: jenkins
2023-03-18helper: add compiler.h to handle compiler specific workaroundsAntonio Borneo3-3/+50
Not all compilers nor compiler versions supports the attributes used in OpenOCD code. Collect in a single file the workaround to handle them. Change-Id: I92d871337281169134ce8e40b2064591518be71f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7519 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-02-26helper: command: drop last LF ('\n') from sequence of command_print()Antonio Borneo2-2/+21
The OpenOCD commands produce their TCL text result through the pair command_print() and command_print_sameline(). The latter is used to concatenate output in a single line. At the end of a sequence of command_print(), the last LF is taken as part of the command result, while it is not always needed, and it is even annoying when the output of two commands needs to be concatenate in a single line. Using command_print_sameline() in place of the last call to command_print() would solve the problem but it's quite expensive in term of coding to fix all the existing commands. Drop the last LF, if present. Commands that would specifically need a LF as last char, can add an extra LF at the end of the output. Document this behavior in command.h. Change-Id: I6757c20fbfce923dd393083146e8d5a1f3b790b4 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7471 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-02-03helper: nvp: add openocd nvp filesAntonio Borneo3-1/+145
Long ago jim_nvp was part of jimtcl. When jimtcl dropped it, OpenOCD kept copy of it in its code base. Current code of jim_nvp is still related with jimtcl data types and functions. With the target of better isolating OpenOCD code from jimtcl, create a new file nvp.c that re-proposes only the core of the old jim_nvp, dropping any link with jimtcl and removing the string 'jim' either from the filename and from the code. Keep the same license from the old code, as the new files are clearly derived from it. Change-Id: I273448cf1f1484b10f6b6113ed7bb0fcf946482b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7423 Tested-by: jenkins Reviewed-by: Evgeniy Didin <didin@synopsys.com>
2023-01-21helper: Add generic little endian CRC32 functionMarian Buschsieweke3-0/+89
This generalizes the little endian CRC32 function used in the OR1K target and moves it to a common helper, so that other places do not need to reinvent the wheel. It is directly used in the OR1K target. Change-Id: I0e55340281a5bfd80669bb1994f3a96fecc1248a Signed-off-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de> Reviewed-on: https://review.openocd.org/c/openocd/+/7415 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15openocd: revert workarounds for 'expr' syntax changeAntonio Borneo1-13/+1
With OpenOCD v0.12.0 released, drop the workarounds for 'expr' syntax change by reverting: - commit 320043c054dc ("openocd: fix for polling during "expr" computation"); - commit c7eaaf620488 ("openocd: prepare for jimtcl 0.81 'expr' syntax change"). Replace the call to target_call_timer_callbacks_now() with call to target_call_timer_callbacks(). Change-Id: Iae5afc50e3f688e11176a52648efc9a6577a9a11 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7405 Tested-by: jenkins
2022-11-15jep106: update to revision JEP106BF.01 Oct 2022Antonio Borneo1-3/+84
Change-Id: Ia1f19dcce48da997c036ccffa65e76e179de2eb9 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7341 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-11-11helper/types: use unsigned type for all h_u64_to_le() and similarAntonio Borneo1-8/+8
All the converters functions: h_u64_to_le() h_u64_to_be() h_u32_to_le() h_u32_to_be() h_u24_to_le() h_u24_to_be() h_u16_to_le() h_u16_to_be() have signed type in their prototype, while the function name and all the current use cases pass an unsigned value. Change the prototypes to use unsigned types. Change-Id: I76dcfdd7912b81f60902184712b2907eae9843f7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7299 Tested-by: jenkins
2022-09-18openocd: fix SPDX tag format for files .cAntonio Borneo12-12/+12
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-13openocd: fix for polling during "expr" computationAntonio Borneo1-1/+13
Commit c7eaaf620488 ("openocd: prepare for jimtcl 0.81 'expr' syntax change") replaces the jimtcl command "expr" with an openocd version that detects the TCL syntax change and prints a warning. The openocd "expr" command will be dropped after v0.12.0, One side effect is that openocd invokes polling the target after every openocd command, causing scripts that use several "expr" commands to run much slower; see [1]. The proper fix would require openocd to invoke polling only at the time period deadline, instead of at each command. Such fix is too risky to be applied now, due to short time before v0.12.0-rc1. As a temporarily workaround, let openocd to detect the "expr" command and skip the polling. This will be dropped together with the openocd "expr" command. Change-Id: I8151aa28694817001046165a15475d64896f985e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: https://sourceforge.net/p/openocd/tickets/362/ [1] Fixes: c7eaaf620488 ("openocd: prepare for jimtcl 0.81 'expr' syntax change") Reviewed-on: https://review.openocd.org/c/openocd/+/7174 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-09-13log: remove unused set_log_output()Antonio Borneo2-7/+0
The function set_log_output() has never been used after the drop of eCos build with commit 39650e2273bc ("ecosboard: delete bit-rotted eCos code") in 2012. Drop it! Change-Id: I070b688061776c7ced5db18f738d78a4a7623726 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7164 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-09-08jep106: update to revision JEP106BE Jan 2022Antonio Borneo1-3/+91
Change-Id: I687c653517133c114a66f628cce58178ce6707cd Signed-off-by: Antonio Borneo <antonio.borneo@st.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7148 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-08jep106: add SPDX tag and JEDEC copyrightAntonio Borneo1-4/+10
As a follow-up of talks between JEDEC and STMicroelectronics, JEDEC agrees to let OpenOCD project including the manufacturer's identification code list extracted from JEDEC JEP106 document and to let OpenOCD being updated regularly using the future JEDEC JEP106 document versions. JEDEC requires OpenOCD to report the origin of the JEDEC JEP106 manufacturer's identification code list together with the JEDEC copyright. As agreed with JEDEC, add in the file jep106.inc: - the SPDX tag with the GPL license of the OpenOCD project; - the JEDEC copyright; - the text provided by JEDEC reporting the origin of the JEDEC JEP106 manufacturer's identification code list. While there: - add a line reporting the version of the JEP106 document that was used for the current code list extraction; - remove the obsolete comment, as the script for extraction is not working anymore; keep the script as example. Change-Id: Iaa76716db14e15ffca04fcf7d8c27bb85a27ba10 Signed-off-by: Antonio Borneo <antonio.borneo@st.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7147 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-08-15target: add API to temporarily mask target pollingAntonio Borneo1-4/+2
The same flag 'jtag_poll' is currently used as local data for the command 'poll' and to temporarily mask the target polling. This can cause unexpected behavior if the command 'poll' is executed while polling is temporarily masked. Add a new flag 'jtag_poll_en' to hold the temporarily mask condition and keep 'jtag_poll' for the 'poll' command only. While there, change the initial assignment of 'jtag_poll' using the proper boolean value. Change-Id: I18dcf7c65b07aefadf046caaa2fcd2d74fa6fbae Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7009 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-07-23helper/jim-nvp: avoid camelcase error by deprecated APIAntonio Borneo1-140/+0
Commit b8e18d292eb6 ("helper/jim-nvp: comply with coding style [1/2]") tags as deprecated the old CamelCase API of jim-nvp, so that old patches already in gerrit or in user's local git can still build while dumping a deprecated message. So far, we have not found any such case, so the deprecated API can be safely dropped in preparation of v0.12.0-rc1. Drop the compile flag "-Wno-error=deprecated-declarations" and the deprecated API. Change-Id: I52ce47eda69a51c2dd29aac15f16e285492d89b4 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7052 Tested-by: jenkins
2022-07-23openocd: src: replace SPDX to remaining filesAntonio Borneo2-0/+3
With most of the files already processed through scripts, replace manually the license to the few remaining files. Change-Id: I3c7131e66b89ddad482f1074b5be5a9a69fdf6fd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7073 Tested-by: jenkins
2022-07-23openocd: src/helper: replace the GPL-2.0-or-later license tagAntonio Borneo23-299/+46
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: I7851617e2682f97ccc3927e3941aadef2df63b54 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7068 Tested-by: jenkins
2022-07-23openocd: src: replace the BSD-2-Clause-Views license tagAntonio Borneo2-56/+6
Add the license text in the license pool. Replace the BSD boilerplate with the SPDX tag. Add the copyright owner of Jim Project, as it was explicitly listed in the boilerplate text. 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: I6dd004b1945773c10539016ce733d1fbfe776a9d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7060 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-24helper: fix build with mingw gcc 12.1.0Antonio Borneo1-2/+4
New mingw compiler correctly complains for using a freed memory area: src/helper/configuration.c: In function 'get_home_dir': src/helper/configuration.c:182:29: error: dangling pointer 'home' to 'homepath' may be used [-Werror=dangling-pointer=] 182 | home_path = alloc_printf("%s/%s", home, append_path); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In fact the variable 'homepath' is declared inside an 'if' branch and is not available outside. Move the declaration of 'homepath' to have it available in a wider context. Change-Id: I4a43a03c007c9f0d5c4cee962a9f7cc83ca49637 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Dietmar May <dietmar.may@outlook.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7038 Tested-by: jenkins Reviewed-by: Dietmar May <dietmar.may@outlook.com>
2022-05-14openocd: add post-init and pre-shutdown helpersAntonio Borneo1-0/+22
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-03-26helper/bits: add BIT_ULL and GENMASK macrosAntonio Borneo1-0/+4
To support 64 bits bit and masks Replace local definition of BIT in rtos/chromium-ec Change-Id: I1f268d6e8790f1b07bf798680b797878ce81064b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6857 Tested-by: jenkins
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 Borneo1-20/+16
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-19log: drop global current_timeAntonio Borneo1-4/+2
The value of this variable is not shared across functions, so the variable can be local. Change-Id: I00b0444209e81c07bb57fb732f47052ad0596728 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6837 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-02-14helper/list: add list_for_each_entry_direction()Antonio Borneo1-0/+14
Use a bool flag to specify if the list should be forward or backward iterated. Change-Id: Ied19d049f46cdcb7f50137d459cc7c02014526bc Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6784 Tested-by: jenkins
2022-01-22log: fix memory leak when log to file is enabledAntonio Borneo2-0/+10
When log to file is enabled, the file is not closed by OpenOCD at exit. This is reported by Valgrind as a memory leak that is still reachable, as the internal buffers of 'FILE *log_output' are freed by the automatic fclose() at exit. Close the log file before exit. Change-Id: Id472c0d04462035254a9b49ecb0a4037263c6f6f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6789 Tested-by: jenkins
2021-12-18openocd: add keep_alive during command sleepAntonio Borneo1-0/+1
The command sleep holds the host CPU until it completes. Send keep_alive to GDB, so it will not timeout. Change-Id: I92e9c5fc871b4e6a7695cdc449ca9fb3c1f1d9ec Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6770 Tested-by: jenkins Reviewed-by: Jan Matyas <matyas@codasip.com>
2021-11-13helper/log: Add macros for target-related errors/warnings/...Jan Matyas1-0/+17
This commit introduces macros for target related log entries (error, warning, ...) which is a very common operation in OpenOCD: * LOG_TARGET_ERROR * LOG_TARGET_WARNING * LOG_TARGET_INFO * LOG_TARGET_DEBUG * LOG_TARGET_DEBUG_IO The goal is to have one macro for this common operation and to make such log entries look the same way - to make it more readable for humans as well easier for parsing via scripts. Change-Id: I6166565fc9040b03d3fca5c3aa44a1ccbcf96ad2 Signed-off-by: Jan Matyas <matyas@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6667 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-11-07jimtcl: revert temporary workaround for memory leak in jimtcl 0.80Antonio Borneo1-35/+0
By using jimtcl from latest master branch, the workaround added in commit 36ae487ed04b ("jimtcl: add temporary workaround for memory leak in jimtcl 0.80") is not needed anymore. Revert the workaround. Change-Id: Ia1b5804be15362d0400740c375455ee19ac09f04 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6228 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-10-25command: document enum command_modeAntonio Borneo1-0/+9
Add the description to doxygen documentation. Change-Id: Iec04b4a37088e1b3b52ca84102820f450528b5b9 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6593 Tested-by: jenkins
2021-10-02helper: Remove src/helper from include dirsYasushi SHOJI2-2/+2
The header files under src/helper/ can currently be included with either #include <bits.h> or #include <helper/bits.h> This is because we specify both "src/" and "src/helper/" directories as include directories. Some files name under "src/helper/", such as types.h, log.h, and util.h are too generic and could be ambiguous depending on the search path. This commit remove "src/helper/" from our include dir and make C files include explicitly. Change-Id: I38fc9b96ba01a513d4a72757d40007e21b502f25 Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6507 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-09-18helper/command: fix echo return valuesTarek BOCHKATI1-5/+7
the echo command is managed through command handler and not jim_handler to be consistent rename the handler from jim_echo to handle_echo and update the return values Fixes: 4747af362de0 (JIM: document "echo" command) Change-Id: I5ae87ea802d8430b573fb83daa6b35490b5d5775 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6549 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-09-18jep106.inc: Update to revision JEP106BCFlorian Zaruba1-8/+206
Signed-off-by: Florian Zaruba <florian@openhwgroup.org> Change-Id: I566eb331b2884de3df5ad3f02c2ec7961539257b Reviewed-on: https://review.openocd.org/c/openocd/+/6551 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-08-30Makefile: drop warning suppression on win buildAntonio Borneo1-6/+0
Commit dcdf71c21b99 ("- fix signed/unsigned build errors under win32. Thanks Zach Welch <zw@superlucidity.net>") in 2009 prevents gcc warnings on sign/unsigned comparisons while building for Win on folders 'helper' and 'server'. In 2011, commit b69119668ed8 ("RTOS Thread awareness support wip") uses the same method on the new folder 'rtos'. In mean time, all the incorrect sign/unsigned comparisons has been fixed and no warning is present with the default -Wextra flag that implies -Wsign-compare. The comment: # FD_* macros are sloppy with their signs on MinGW32 platform seems linked to some old implementation of MinGW32 include file that doesn't apply on current versions. Remove the obsolete hacks to suppress the warnings. Change-Id: I76dba9e54a647d3b9fbf1b7e9ae1844e3d7adc9a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6254 Tested-by: jenkins Reviewed-by: Xiaofan Chen <xiaofanc@gmail.com>
2021-08-30helper: remove fix for libusb pre-v1.0.9Antonio Borneo3-48/+0
Libusb v1.0.9 has been released on April 2012. We can reasonably expect that every user has already updated his system to a libusb newer of equel to v1.0.9. Remove the fix for older libusb. Change-Id: I0c40e53d7af85a11b0bb265bbf8035857a2dfce1 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6253 Tested-by: jenkins Reviewed-by: Xiaofan Chen <xiaofanc@gmail.com>
2021-08-22jep106: use packed jedec manufacturer codeAntonio Borneo2-2/+7
JEP106 encodes JEDEC-assigned manufacture code as: a) a sequence of zero or more escape codes 0x7f; b) an odd-parity bit of the next 7 bits; c) 7 bits. The same code is often represented as a single value composed by the logical OR between: - the number of escape codes in a), shifted left by 7 positions; - the 7 bits in c). This is the preferred packed representation used by this change. Currently there are only two uses of JEP106 in openocd to get the manufacturer name: - to decode the JTAG IDCODE of each TAP, where the JEP106 code is already packed as in the preferred representation above in bits IDCODE[11:1]; - to decode the ARM CoreSight PIDR register, where the JEP106 code is split in 3 parts: = PIDR3[3:0], corresponding to bits [10:7] of the packed code; = PIDR2[2:0], corresponding to bits [6:4] of the packed code; = PIDR1[7:4], corresponding to bits [3:0] of the packed code. Wrap the existing JEP106 decode function in a simpler API using the packed code. Simplify the callers by skipping the bit unpacking. Change the manufacturer code in CoreSight table dap_partnums[] to match the packed representation, by removing the always-one bit 7 erroneously taken from PIDR bit JEDEC and included in the former table. Change-Id: I63eb4da9e6801fab25e330f1f6b792d2fd619493 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6418 Tested-by: jenkins
2021-08-22command: log the command only when it is executedAntonio Borneo1-2/+2
In case of multi-word commands, the command dispatcher is nested called at each word during command name parsing. The improper position of the call to script_debug() causes the command line to be logged once at each parsed word. In the example of command "cpu arm disassemble 0" the full command is logged three times for "cpu", "arm" and "disassemble": Debug: 656617 61843 command.c:201 script_debug(): command - cpu arm disassemble 0 Debug: 656618 61843 command.c:201 script_debug(): command - cpu arm disassemble 0 Debug: 656619 61843 command.c:201 script_debug(): command - cpu arm disassemble 0 Call script_debug() only when the parsing is terminated and the command handler is going to be executed. Change-Id: Ide4cb01b3b38912e2e24b073c94a9560f92d30bb Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6436 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2021-08-14helper: add align.hAntonio Borneo2-0/+31
OpenOCD has to often align values or check for alignment. Use a dedicated set of macros instead of reinventing the wheel each time. Change-Id: Ia58711608aae0801deeaccb5f33148f2073b0bbd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6374 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>