aboutsummaryrefslogtreecommitdiff
path: root/src/helper
AgeCommit message (Collapse)AuthorFilesLines
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>
2021-07-24openocd: fix Yoda conditions with checkpatchAntonio Borneo4-5/+5
The new checkpatch can automatically fix the code, but this feature is still error prone and not complete. Patch generated automatically through the new checkpatch with flags "--types CONSTANT_COMPARISON --fix-inplace". Some Yoda condition is detected by checkpatch but not fixed; it will be fixed manually in a following commit. Change-Id: Ifaaa1159e63dbd1db6aa3c017125df9874fa9703 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6355 Tested-by: jenkins
2021-07-24openocd: manually remove NULL comparisonsAntonio Borneo2-4/+4
For the remaining NULL comparisons, remove then manually. While there, make more readable a loop, by moving the assigment out of the loop condition. Change-Id: I44193aaa95813156a3a79c16b80e1ad333dc1eaf Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6353 Tested-by: jenkins
2021-07-24openocd: remove NULL comparisons with checkpatch [2/2]Antonio Borneo1-1/+1
Patch generated automatically through a modified checkpatch that detects the patterns if (NULL == symbol) if (NULL != symbol) and through flags "--types COMPARISON_TO_NULL --fix-inplace". The unmodified checkpatch detects this pattern as Yoda condition, but it's odd fixing it as Yoda condition and then again as NULL comparison. This triggered the modification to the script. Change-Id: I5fe984a85e9c4fc799f049211797aef891ebce18 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6352 Tested-by: jenkins
2021-07-24openocd: remove NULL comparisons with checkpatch [1/2]Antonio Borneo3-6/+6
Patch generated automatically through the new checkpatch with flags "--types COMPARISON_TO_NULL --fix-inplace". This only fixes the comparisons if (symbol == NULL) if (symbol != NULL) The case of NULL on the left side of the comparison is not tested. Some automatic fix is incorrect and has been massaged by hands: - if (*psig == NULL) + if (*!psig) changed as + if (!*psig) Change-Id: If4a1e2b4e547e223532e8e3d9da89bf9cb382ce6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6351 Tested-by: jenkins
2021-07-24openocd: fix simple cases of NULL comparisonAntonio Borneo6-43/+43
There are more than 1000 NULL comparisons to be aligned to the coding style. For recurrent NULL comparison it's preferable using trivial scripts in order to minimize the review effort. Patch generated automatically with the command: sed -i PATTERN $(find src/ -type f) where PATTERN is in the list: 's/(\([a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(NULL == \([a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL == \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL == \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL != \([a-z][a-z0-9_]*\))/(\1)/g' 's/(NULL != \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(\1)/g' 's/(NULL != \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(\1)/g' Change-Id: Ida103e325d6d0600fb69c0b7a1557ee969db4417 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6350 Tested-by: jenkins
2021-07-20openocd: manually fix Yoda conditionsAntonio Borneo2-3/+3
Fix the remaining Yoda conditions, detected by checkpatch but not fixed automatically. While there, apply minor style changes. Change-Id: I6e1978b89c4d56a20aceaeb2b52968eb6384432a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6356 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Reviewed-by: Xiang W <wxjstz@126.com>
2021-07-20openocd: fix simple cases of Yoda conditionAntonio Borneo3-9/+9
There are ~900 Yoda conditions to be aligned to the coding style. For recurrent Yoda conditions it's preferable using a trivial script in order to minimize the review effort. E.g. comparison of uppercase macro/enum with lowercase variable: - ...(ERROR_OK == retval)... + ...(retval == ERROR_OK)... Patch generated automatically with the command: sed -i \ 's/(\([A-Z][A-Z0-9_]*\) \([=!]=\) \([a-z][a-z0-9_]*\))/(\3 \2 \1)/g' \ $(find src/ -type f) While there, remove the braces {} around a single statement block to prevent warning from checkpatch. Change-Id: If585b0a4b4578879c87b2dd74d9e0025e275ec6b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6354 Tested-by: jenkins Reviewed-by: Xiang W <wxjstz@126.com>
2021-07-02helper: rename camelcase symbolsAntonio Borneo3-9/+9
No cross dependency, just changes internal to each file/function. Change-Id: I16568ddcd8304f5e6748c2e19f32421b047b0357 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6300 Tested-by: jenkins
2021-06-18Doc fix: echo writes to the log, and not to stdoutR. Diez1-1/+0
Fixes bug #202 Change-Id: I855a1b8570af71379891634f405b4cc726917cb2 Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de> Reviewed-on: http://openocd.zylin.com/6272 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-06-04Avoid non-standard conditionals with omitted operands.R. Diez1-2/+2
Fixes bug #257. Change-Id: I05fc6468306d46399e769098e031e7e588798afc Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de> Reviewed-on: http://openocd.zylin.com/6271 Tested-by: jenkins Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-06-04gdb_server: Log both incoming and outgoing GDB packetsJan Matyas2-0/+15
- Made sure that also outgoing GDB packets are logged, not only the incoming ones. - Improved the treatment of non-printable characters in the packets to make it more robust. Prior to this change: - Outgoing packets were not printed unless OpenOCD was re-compiled with _DEBUG_GDB_IO_. - Non-prinable characters were only treated in incoming 'X' packets. After this change: - Both incoming and outgoing GDB packets are logged on debug_level >= 3, so that both directions of the GDB channel are visible. - Non-printable characters are checked for in every packet so that hey do not interfere with the terminal. Change-Id: I0613e57ae5059b3279b0abcb71276cf5719a8699 Signed-off-by: Jan Matyas <matyas@codasip.com> Reviewed-on: http://openocd.zylin.com/6269 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-06-04helper/list.h: add mention to the example in contribAntonio Borneo1-0/+2
Without such reference, it could be difficult to find the example. Change-Id: Ia9ffb06bc1a45446c2c7b53197ab3400e1d8a9e9 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6281 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com>
2021-06-04helper/list.h: align file to Linux v5.12Antonio Borneo1-137/+431
Main improvement is in the doxygen comments. Minimize the delta with kernel file. Skip the functions hlist_unhashed_lockless() and __list_del_clearprev() that are relevant only in kernel. Remove gcc extension "omitted conditional operand". Change-Id: I2e9ddb54cfe2fa5f7cf18f44726acd144e1f98b9 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6276 Reviewed-by: <rdiezmail-openocd@yahoo.de> Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2021-06-04server/telnet: fix autocomplete for jimtcl commandsAntonio Borneo2-4/+15
Current autocomplete filters-out some command reported by "info commands". One of the filter rule concerns the command's private data. Every command registered by OpenOCD has its 'struct command' as private data. By ignoring commands without private data, we loose several TCL commands registered by jimtcl, e.g. 'foreach', 'llength'. By assuming that every command with non-NULL private data has 'struct command' as private data, we risk at best to access inconsistent data, at worst to trigger a segmentation fault. Export the already available functions: - to check if a command has been registered by OpenOCD and - to get the private data. While there, rename jimcmd_is_ocd_command() as jimcmd_is_oocd_command(). Don't filter-out jimtcl commands with no private data. Check the private data only on OpenOCD commands. Change-Id: Ib5bf8d2bc5c12440c0cfae438f637c38724a79b7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6282 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2021-06-04helper/jim-nvp: comply with coding style [1/2]Antonio Borneo2-110/+250
The helper jim-nvp does not comply with OpenOCD coding style due to typedef of struct and CamelCase symbol names. While it's trivial fixing the helper and all its current use in the code, changing these APIs will potentially break a number of patches pending in gerrit. Gerrit will not trigger any alert, but the code will generate compile error after the merge. Add the compile flag "-Wno-error=deprecated-declarations" to keep as warning (not as error) the use of "deprecated" functions and types. Rename all the CamelCase symbols is lowercase and provide struct prototypes in place of the typedef. Add a DEPRECATED section to 'jim-nvp.h' where the old CamelCase symbols and the old typedef are re-declared with compile attribute 'deprecated'. With this change OpenOCD compiles, but generates warnings. The remaining changes allover OpenOCD code will be fixed in a separate patch for easier review. The patches merged later that still use the old deprecated API will compile with warnings. This will permit to identify and fix these cases. Change-Id: I786385d0f662dbb1be5be313ae42623156d68ce5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6183 Tested-by: jenkins Reviewed-by: Marc Schink <dev@zapb.de>
2021-05-29help: fix line size in 'usage' outputAntonio Borneo1-7/+6
The implementation of command 'usage' is broken while checking the line limit of 76 chars per line (e.g. 'usage load_image') and the line wrapping is not correct. The same broken code is used for the first output line of command 'help' too. When call command_help_show_wrap(), include the command's name in the string so the whole text would be wrapped. Change-Id: Idece01ce54994db7e851d8522435ff764b11f3ac Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6223 Tested-by: jenkins
2021-05-22helper/command: silent debug msg on command register/unregisterAntonio Borneo1-2/+4
Commit e216186fab59 ("helper/command: register full-name commands in jim") and commit a7d68878e4ba ("helper/command: unregister commands through their full-name") introduce a LOG_DEBUG() message each for command registration and unregistration. The messages above are quite noisy and pollute the log when debug_level is 3 or higher. They can be useful to debug the command registration logic, but for the other debug activities on OpenOCD are just noisy. Already commit a03ac1ba3087 ("helper/command: disable logging of registered commands [RFC]") was merged to silent the first case that is now back with additional logs. Silent both log messages. Use 'if (false)' to silent them, making easy to re-enable it when or if someone needs it. Change-Id: Id8a067e60e822d4ecbddcb036d081298f7e6181f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6220 Tested-by: jenkins
2021-05-22openocd: fix some minor typoAntonio Borneo1-1/+1
Minor typos found by the new checkpatch boosted by the dictionary provided by 'codespell'. Change-Id: I7b4cae1798ff5ea048fcbc671a397af763fdc605 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6218 Tested-by: jenkins
2021-05-15jimtcl: restrict memory leak workaround on Linux onlyAntonio Borneo1-2/+3
The workaround for jimtcl 0.80 in commit 36ae487ed04b ("jimtcl: add temporary workaround for memory leak in jimtcl 0.80") issues a compile time error on macOS: ../src/helper/command.c:157:22: error: aliases are not supported on darwin __attribute__((weak, alias("workaround_createcommand"))); The OS is x86_64-apple-darwin19.6.0 and the compiler used is x86_64-apple-darwin13.4.0-clang. Restrict the workaround on Linux host only. The fix for 'expr' syntax change is already merged and the workaround will be dropped soon. Change-Id: I925109a9c57c05f8c95b70bc7d6604eb1172cd79 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Adam JeliƄski <ajelinski@users.sourceforge.net> Fixes: 36ae487ed04b ("jimtcl: add temporary workaround for memory leak in jimtcl 0.80") Fixes: https://sourceforge.net/p/openocd/tickets/304/ Reviewed-on: http://openocd.zylin.com/6241 Tested-by: jenkins
2021-05-08Add IPDBG JtagHost functionality to OpenOCDDaniel Anselmi1-0/+42
IPDBG are utilities to debug IP-cores. It uses JTAG for transport to/from the FPGA. The different UIs use TCP/IP as transport. The JtagHost makes the bridge between these two. Comparable to the bridge between GDB and the in-circuit- debugging-unit of a micro controller. Change-Id: Ib1bc10dcbd4ea426e492bb7b2d85c1ed1b7a8d5a Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: http://openocd.zylin.com/5938 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-05-01Cleanup of config/includes.Tim Newsome11-9/+21
Remove a use of AH_BOTTOM from configure.ac. This macro is used by autoheader to add '#include' of some include file to the end of config.h.in and then to config.h. OpenOCD can be built with a custom config.h, so it's preferable to move these '#include' statement directly in the C files that need them dropping this unneeded dependency. It also causes problems when I want to use the gnulib library (which comes with its own Makefile, and does not have the same include path as the top-level Makefile). So this change touches a lot of files, but is actually really simple. It does not affect functionality at all. Change-Id: I52c70bf15eb2edc1dd10e0fde23b2bcd4caec000 Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: http://openocd.zylin.com/6171 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-05-01helper/command: drop the TCL variable 'ocd_HOSTOS'Antonio Borneo1-34/+0
Commit 7a731eb63731 ("Added HostOS variable"), merged in 2009, adds a TCL global variable 'ocd_HostOS' that reports in a string the OS of the host. This was proposed as a workaround for jimtcl that didn't define the standard TCL variable 'tcl_platform(os)'. With commit 42f3fb7b7f46 ("Determine platform_tcl() settings with configure"), merged in 2010 and part of jimtcl 0.70 issued in early 2011, jimtcl provides the requires TCL standard variable 'tcl_platform(os)'. The variable 'ocd_HostOS' has never been used by any TCL script distributed with OpenOCD. Drop the TCL variable 'ocd_HostOS'. Change-Id: I27858de35cc9d30df97145ca1ccd24877be4af11 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6189 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-05-01helper/command: fix memory leak on malloc() failAntonio Borneo1-5/+9
If malloc() fails, the just allocated Jim_Obj will leaks. Move Jim_IncrRefCount() before the malloc() and deallocate the Jim object with Jim_DecrRefCount() on malloc() fail. While there, add the 'out of memory' log and fix the CamelCase name of the symbol tclOutput. Change-Id: Ic733db229d5aa5d477d758ea9cb88cd81d7542cd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6188 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-05-01helper/jim-nvp: remove unused function Jim_nvpInit()Antonio Borneo1-6/+0
The files jim-nvp.[ch] were originally inside jimtcl, then in 2011 they were dropped by jimtcl and integrated in OpenOCD. The initial purpose was to make them as an independent library, thus the presence of an 'init' function. Being now part of OpenOCD do not require the 'init' function anymore, that is still empty and unused, plus its name is in violation of the coding style. Drop the function Jim_nvpInit(). Change-Id: I429e10444c86a26dbdc22aa071315324dc5edc3e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6187 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-05-01helper/types: remove type '_Bool'Antonio Borneo1-7/+1
Accordingly to OpenOCD coding style, both typedef and Camelcase symbols are forbidden. The type '_Bool' is not used in the code, having 'bool' as preferred choice. Remove the definition of '_Bool' from 'types.h'. Change-Id: I8863f9836ccd9166e0c69fa5d75d6fef79ae7bfb Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6186 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-05-01helper/replacements: remove unused typedef'sAntonio Borneo1-2/+0
The ELF typedef's 'Elf32_Sword' and 'Elf32_Hashelt' are not used within OpenOCD. Plus, being their name in CamelCase require extra effort to include them in the exceptions for checkpatch. Remove the unused typedef's. Change-Id: I18f039567edd5b24dbb41df5406c154f31022ae7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6178 Tested-by: jenkins Reviewed-by: Christian Hoff <christian.hoff@advantest.com>
2021-05-01target/image: allow loading of 64-bit ELF filesFlorian Meister1-1/+41
Change-Id: I9b88edacf5ffcc3c1caeab8c426693de0d92a695 Signed-off-by: Florian Meister <florian.meister@advantest.com> Signed-off-by: Christian Hoff <christian.hoff@advantest.com> Reviewed-on: http://openocd.zylin.com/5204 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Ooi, Cinly <cinly.ooi@intel.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-05-01helper/command: fix build with jimtcl 0.79 or olderAntonio Borneo1-0/+4
Commit a7d68878e4ba ("helper/command: unregister commands through their full-name") introduces for the first time in OpenOCD the use of jimtcl API Jim_DeleteCommand(). The prototype of Jim_DeleteCommand() has changed with jimtcl 0.80 and the current code doesn't build with jimtcl 0.79 or older. This is an issue for those distributions, like Debian, that provide jimtcl as a separate package/library and have not switched yet to the new jimtcl version. Add a compile-time condition to cope with the jimtcl API change. Change-Id: Ic813ab7c0ebd3c8772f27775ba3912a47d5c275c Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: a7d68878e4ba ("helper/command: unregister commands through their full-name") Reviewed-on: http://openocd.zylin.com/6191 Tested-by: jenkins
2021-04-18helper/command: rename s/command_unknown/jim_command_dispatch/Antonio Borneo1-5/+5
The function's name was consistent with its purpose to handle commands that were not at root level, thus not directly 'known' by jimtcl. Rename it as jim_command_dispatch() to highlight that now it is a jim_handler and its purpose is to dispatch the call to the proper command handler. Change-Id: I9491a6d6459b8eb37a6c402abcae08388c693764 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5791 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-04-18helper/command: make script_debug() staticAntonio Borneo2-3/+1
Now that all commands are executed through the common handler command_unknown(), the message about command execution is logged by command_unknown(). There is no need, for "native" commands (.jim_handler) at root level to log the message (again) by itself. Remove calls to script_debug() apart from command_unknown(). Make script_debug() static as only used in command.c. Change-Id: I9b2728b69e7643d6121c4b35a96bc825bcb5488d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5676 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-04-18helper/command: get rid of the tree of struct commandAntonio Borneo2-191/+71
There is no need anymore to keep alive the tree of struct command. Remove it and let jim to free() the command's struct command that is referenced through command's private data. Change-Id: I2cd84e0274a969ce200320e3a177ac20c7823da0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5675 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-04-18helper/command: unregister commands through their full-nameAntonio Borneo2-5/+97
While keeping the struct command in place, unregister the jim commands by scanning the list of jim commands through their full-name. Change-Id: I0e903fbc31172858b703d67ccd471809c7949e86 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5674 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>