aboutsummaryrefslogtreecommitdiff
path: root/src/helper/command.c
AgeCommit message (Collapse)Author
2019-12-19helper/command: remove unused field in struct command_registrationAntonio Borneo
The field jim_handler_data in struct command_registration is never assigned, thus has always value NULL. It was added in commit 17a9dea53a71 ("add jim_handler to command_registration") on Nov 23 2009, together with the homonym field jim_handler_data in struct command, but never used since then. Only the field jim_handler_data in struct command is used. Remove the field from struct command_registration and use NULL where it was referenced (or remove the assignment if the recipient is already zero, e.g. allocated with calloc()). Removing the field decreases the total size of OpenOCD binary by only 4944 byte on a 64 bit x86. Not a significant improvement from this point of view. Change-Id: I9f1d281e3de6b2eb398e2d883c5e9ff92628aecd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5225 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-09-24helper/command: clear errno before calling parserChristopher Head
The C standard says that errno is set to ERANGE if an out-of-range value is returned by strtol, strtoul, et. al., but it does not say that errno is cleared if the function is successful (and, indeed, it is not on glibc). This means that, if errno is ERANGE before strtol is called, and if the value to be converted is exactly the maximum (or, for a signed conversion, the minimum) legal value, COMMAND_PARSE_NUMBER will erroneously indicate that the value is out of range. Change-Id: I8a8b50a815b408a38235968f1c1d70297ea1a6aa Signed-off-by: Christopher Head <chead@zaber.com> Reviewed-on: http://openocd.zylin.com/5298 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-06-20helper/command: make command_run_line reentrantChristopher Head
The `command_run_line` function contains a comment saying it should be reentrant. However, it isn’t: it NULLs out `current_target_override` and doesn’t restore it before returning, and it changes the `context` associated data of the `interp` object and then deletes that associated data before returning rather than restoring it to its previous value. Change-Id: I84fd46ef7173f08cf7c57b9a5b76e4986a60816f Signed-off-by: Christopher Head <chead@zaber.com> Reviewed-on: http://openocd.zylin.com/5223 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-05-23helper/command: remove dead code in command_unknown()Antonio Borneo
Commit 89fa493a3bc34d22eeca06fa4e78523ac3b766a8 removes the top level command "unknown" and adds in command_unknown() some unclear code that should detect a user-implemented "unknown" command. But, all the commands that trigger the execution of the function command_unknown() are registered in register_command_handler() and have the command name prefixed with "ocd_". Due to such "ocd_" prefix in cmd_name, the condition if (strcmp(cmd_name, "unknown") == 0) { ... } is always false. Nobody complained for almost 10 years so we can proceed to remove this dead code, before merging any change that obsoletes the prefix "ocd_" and potentially makes the condition true. Remove the dead code guarded by the condition above. Change-Id: Icf11a956bb2d68fc84e6eb5779edf8e35db8fa53 Fixes: 89fa493a3bc3 ("remove unknown handler") Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5096 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-05-17helper/command: print the command output in case of errorAntonio Borneo
In case of error, a command should use command_print() to report the error message, so it get printed only on the session that run the command itself, and the message can be intercepted with the tcl command catch if it has to be handled differently. Current code drops the command output when the command returns error, claiming that it's the command that *should* have printed it already. This is true only if we *abuse* of the LOG functions, but accepting the side issue of having the LOG printed in every session and being unable to catch{} the error message. Since we have switched to command_print(), change the code to propagate the command output also in case of error. Change-Id: I95de424a65e63702bdb3b2277749a0ac6aaaa503 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5178 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-05-14helper/command: fix printing usage for incomplete commandsAntonio Borneo
The commit "helper/command: do not replace new commands with ocd_ prefix" breaks the print of usage text when a multi-word command is typed incompletely. Fix it by explicitly running the "usage" command. Change-Id: I46f8e521d9b6ac617bff8938cf8fc96f0ade45c8 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5166 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-05-14helper/command: send command output only to the right serverAntonio Borneo
When opening multiple telnet connections, the command output on one console is broadcast to all the other console. Send the command output only to the output handler that has been set for that context. For the moment, still broadcast the errors. Note that contexts which doesn't explicitly set the output handler (e.g. gdb_server), will inherit the global output handler configuration_output_handler() that will broadcast the output. Change-Id: I1f2d6e6a3bbf730f5fa77246730fce1445742a1e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5093 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-05-14helper/command: remove search for "ocd_" prefixAntonio Borneo
We do not register commands with special "ocd_" prefix anymore. Change-Id: I588816eb22c2435a97be5fbfa87ee5584274b02f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5087 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-05-14helper/command: remove command "command type"Paul Fertser
Once the wrapper "ocd_bouncer" is removed (which was the only user of this command), there is no reason to keep the command any longer. Remove it. This change was part of http://openocd.zylin.com/1815 from Paul Fertser and has been extracted and rebased to simplify the review. Change-Id: I979ce1c147babedb44dd77418751133f589f827c Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5084 Tested-by: jenkins
2019-05-14helper/command: do not replace new commands with ocd_ prefixPaul Fertser
The TCL return values are now consistent, no need anymore for the hack of registering the commands with "ocd_" prefix and override them with proc ocd_bouncer. Clean-up the command registration and remove the proc ocd_bouncer. This change was part of http://openocd.zylin.com/1815 from Paul Fertser and has been extracted and rebased to simplify the review. Change-Id: I2a467e73ecb068686ea3fda91bf961aba6db6427 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5086 Tested-by: jenkins
2019-05-14helper/command: do not capture log in script_command_run()Paul Fertser
Command's output should be put in JimTcl result. We should not anymore capture the log output and pack it as a JimTcl result. Remove the log capture feature in script_command_run(). This change was part of http://openocd.zylin.com/1815 from Paul Fertser and has been extracted and rebased to simplify the review. Change-Id: Id326c8719e1cee9156d7fc15ae8355ec79a74951 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5085 Tested-by: jenkins
2019-05-14helper/command: Handle Tcl return values consistentlyPaul Fertser
Rationale: 1. There's logging output and there're return values; 2. If a function should return something, it should do it explicitly, same for logging; 3. Interactive interfaces (telnet, Gdb and Tcl RPC) must always return the result of the evaluation for the given expression. You can suppress this output by adding ``; after 0'' to the end of your expression. 4. Some commands "throw an exception" and if you want to be able to collect both the return value (when it succeeds) and the log output (when something goes wrong) you can use do like this: set log_output [capture "catch {reset_config} return_value"] So what I'm proposing is following: 1. Every jim_handler command should set the return value the standard JimTcl way, without any tricks. If it needs to print some logging output, it should use LOG_* functions. 2. The usual commands (COMMANDS) can easily construct their return value by appending strings with command_print() and command_print_sameline(). This required changing "struct command_invocation" and passing a pointer to it to command_print* functions. The code is already functional, please test and comment. TODO items: 1. Modify all jim_handler commands to properly return or log values (some of them are commented out for now in this patch). 2. Properly document "capture" command and provide a convenience function to automate log_output + return_value gathering. 3. Add appropriate Doxygen comments. 4. Add Tcl RPC interface description to the manual, all the example clients in different languages (from the mailing list) to contrib/. This change is the core part of http://openocd.zylin.com/1815 from Paul Fertser. It has been extracted and rebased to simplify the review and provided again as 1815. Change-Id: I675c91aa9da1e4e7c6f0a8fe6112a00550b9e4db Signed-off-by: Paul Fertser <fercerpav@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/1815 Tested-by: jenkins
2019-05-14helper/command: change prototype of command_print/command_print_samelineAntonio Borneo
To prepare for handling TCL return values consistently, all calls to command_print/command_print_sameline should switch to CMD as first parameter. Change prototype of command_print() and command_print_sameline() to pass CMD instead of CMD_CTX. Since the first parameter is currently not used, the change can be done though scripts without manual coding. This patch is created using the command: sed -i PATTERN $(find src/ doc/ -type f) with all the following patters: 's/\(command_print(cmd\)->ctx,/\1,/' 's/\(command_print(CMD\)_CTX,/\1,/' 's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/' 's/\(command_print_sameline(cmd\)->ctx,/\1,/' 's/\(command_print_sameline(CMD\)_CTX,/\1,/' 's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/' This change is inspired by http://openocd.zylin.com/1815 from Paul Fertser but is now done through scripting. Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/5081 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-10helper/command: log an error for commands without usageAntonio Borneo
Every command has been fixed with proper usage field. Change LOG_DEBUG with LOG_ERROR so a developer will get a visible alert for missing usage field when adds a new command. Change-Id: I077c3745fd6265aded8e54b3f9d202d4d6516966 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5026 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-07helper/command: handle empty "usage" with add_help_text/add_usage_textAntonio Borneo
By using the command "add_help_text" to add a help text to a TCL procedure it implicitly creates a new command_registration struct that has field .usage set to NULL. This triggers a debug message BUG: command '%s' does not have the '.usage' field filled out Use an empty string if usage field is NULL. Plus, do not annoy the user with a LOG_INFO when the command "add_usage_text" replaces an empty usage. Change-Id: I4a72646e0fb704ba354f938d774055540cde3967 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5025 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-07command_registration: add empty usage field to chained commandsAntonio Borneo
Chained command require a subcommand as first argument. The usage field for chained commands is not really important because the "help" command will list all the subcommands with their respective usage. Add a empty usage field on all chained command. The command "jlink config" can be either followed by a subcommand or used alone, so use a dedicated usage string. Change-Id: I43c3f8a766f96a9bdab4e709e3c90713be41fcef Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5017 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-03-06helper/command: return proper JIM error codeAntonio Borneo
The function command_unknown() is expected to return a value recognized as JIM error code, as it is correctly done in the other cases it returns. Fix the only case in which command_unknown() does not return a JIM error code, by s/ERROR_FAIL/JIM_ERR/ Change-Id: Ib98b75755ae36870bd68c17f8839ddbfa06c6312 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4973 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-01-27command: check command mode for native jim commandsTomas Vanek
The command mode was checked only for simple type of commands. Native commands (handled by jim_handler) was treated as they had mode COMMAND_ANY Change-Id: Iab1d8cbb0b8c6f6b9f3cf942600432dec9a703ff Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4841 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2019-01-27command: Log the failed command by full nameTomas Vanek
Commit 44009186cfabe77fb260af221ebd6272d1e78f44 added logging of failed cmd name but it used c->name only. It might be confusing: Debug: 244 105 command.c:644 run_command(): Command 'init' failed with error code -4 User : 245 106 command.c:711 command_run_line(): Debug: 246 107 command.c:644 run_command(): Command 'init' failed with error code -4 The command on line 244 is 'dap init' Use full name of cmd including parents. Change-Id: Iff131ce6454ef70b353ce1bc6d0a480b92820545 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4837 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins Reviewed-by: Jean-Christian de Rivaz <jcamdr70@gmail.com>
2019-01-16helper/command: check for malloc failure in __command_nameAntonio Borneo
If malloc fails in __command_name, the following strcpy will segfault, thus preventing __command_name to return. The actual calls to command_name() implement the correct check for the NULL pointer, but propagate error -ENOMEM, that is not an error value coherent within OpenOCD. Plus, in one case it overwrites an already detected error. Check the pointer returned by malloc and, in case of failure, issue an error message and return the NULL pointer. Let the caller of command_name() to keep the already detected error or to return ERROR_FAIL in case of end of memory. Change-Id: I151a24569409777dd5bc09a3daf5dba2b8e2829b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4838 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2018-12-25command: Log the failed command nameJean-Christian de Rivaz
Change-Id: I03938a845110002755636a9514b17a213bf1cc72 Signed-off-by: Jean-Christian de Rivaz <jcamdr70@gmail.com> Reviewed-on: http://openocd.zylin.com/4808 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2018-03-03target: use correct target in target-prefixed commands and event handlersTomas Vanek
This change contains an alternative to Matthias Welwarsky's #4130 (target-prefixed commands) and to #4293 (event handlers). get_current_target() must retrieve the target associated to the current command. If no target associated, the current target of the command context is used as a fallback. Many Tcl event handlers work with the current target as if it were the target issuing the event. current_target in command_context is a number and has to be converted to a pointer in every get_current_target() call. The solution: - Replace current_target in command_context by a target pointer - Add another target pointer current_target_override - get_current_target() returns current_target_override if set, otherwise current_target - Save, set and restore current_target_override to the current prefix in run_command() - Save, set and restore current_target_override to the event invoking target in target_handle_event() While on it use calloc when allocating a new command_context. Change-Id: I9a82102e94dcac063743834a1d28da861b2e74ea Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Suggested-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com> Reviewed-on: http://openocd.zylin.com/4295 Tested-by: jenkins Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2018-01-17Fix Jim interpreter memory leakMarc Schink
Change-Id: I71d7d97e7dc315c42fc43b65cb5fcecd7bdfb581 Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/2959 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2017-10-23Fix GCC7 warnings about switch-case fallthroughsFreddie Chopin
GCC7 with -Wextra warns about switch-case blocks which fallthrough with "this statement may fall through [-Werror=implicit-fallthrough=]". This can be fixed by adding "special" comments: "/* fallthrough */". See https://gcc.gnu.org/gcc-7/changes.html Change-Id: Iba0be791dbdd86984489b2d9a0592bb59828da1e Signed-off-by: Freddie Chopin <freddie.chopin@gmail.com> Reviewed-on: http://openocd.zylin.com/4174 Tested-by: jenkins
2017-02-10target: Add 64-bit target address supportDongxue Zhang
Define a target_addr_t type to support 32-bit and 64-bit addresses at the same time. Also define matching TARGET_PRI*ADDR format macros as well as a convenient TARGET_ADDR_FMT. In targets that are 32-bit (avr32, nds32, arm7/9/11, fm4, xmc1000) be least invasive by leaving the formatting unchanged apart from the type; for generic code adopt TARGET_ADDR_FMT as unified address format. Don't silently change gdb formatting here, leave that to later. Add COMMAND_PARSE_ADDRESS() macro to abstract the address type. Implement it using its own parse_target_addr() function, in the hopes of catching pointer type mismatches better. Add '--disable-target64' configure option to revert to previous 32-bit target address behavior. Change-Id: I2e91d205862ceb14f94b3e72a7e99ee0373a85d5 Signed-off-by: Dongxue Zhang <elta.era@gmail.com> Signed-off-by: David Ung <david.ung.42@gmail.com> [AF: Default to enabling (Paul Fertser), rename macros, simplify] Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
2016-07-19Fix usage of timeval_ms()Andreas Färber
First, fix the timeval_ms() implementation to not have K&R but ANSI argument semantics by adding a missing void. timeval_ms() returns an int64_t, not uint64_t or long long. Consistently use int64_t for variables and PRI*64 as format string. While at it, change a few related variables to bool for clarity. Note that timeval_ms() may return a negative error code, but not a single caller checks for that. Change-Id: I27cf83e75b3e9a8913f6c43e98a281bea77aac13 Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-on: http://openocd.zylin.com/3499 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2016-05-24Remove FSF address from GPL noticesMarc Schink
Also make GPL notices consistent according to: https://www.gnu.org/licenses/gpl-howto.html Change-Id: I84c9df40a774958a7ed91460c5d931cfab9f45ba Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/3488 Tested-by: jenkins Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com> Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-04-14Tcl exception codes cleanup, shutdown command amendmentsPaul Fertser
This patch might influence openocd Tcl commands behaviour in subtle ways, please give it a nice testing. The idea is that if an OpenOCD Tcl command returns an error, an exception is raised, and then the return code is propogated all the way up (or to the "catch" if present). This allows to detect "shutdown" which is not actually an error but has to raise an exception to stop execution of the commands that follow it in the script. openocd_thread special-cases shutdown because it should then terminate OpenOCD with a success error code, unless shutdown was called with an optional "error" argument which means terminate with a non-zero exit code. Change-Id: I7b6fa8a2e24c947dc45d8def0008b4b007c478b3 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/2600 Tested-by: jenkins Reviewed-by: Juha Niskanen <juha.niskanen@haltian.com> Reviewed-by: Jens Bauer <jens@gpio.dk> Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2015-04-14helper: shutdown command should return with 0 exit statusJuha Niskanen
Commit a35712a85c42 caused a regression where command openocd -c "echo a1; shutdown; echo a2" always returned non-zero exit status to operating system, even when commands before shutdown all succeeded. This patch attempt to fix this. Change-Id: I3f478c2c51d100af810ea0171d2fd4c8fcc657f3 Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com> Reviewed-on: http://openocd.zylin.com/2589 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-09-22command: Fix confusing syntax error messageAndreas Fritiofson
If the user executes a command with an invalid subcommand, the error message is extremely unhelpful: > flash write test.elf flash write test.elf: command requires more arguments This is because any command line that starts with a valid command group is classified as a group, triggering ocd_bouncer to print the confusing message. Fix by requiring that to be a command group, the command line must not contain any unknown tokens after the last valid (sub-)command group. That is OK because command groups don't have handlers defined and thus can't take any parameters. Also fix the error message for "unknown" type to be similar to the error message that is printed (by Jim) for non-existent primary commands. Change-Id: I26950349f0909fd3961c4f9ab9b198c221cea9fc Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/2285 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-05-09Update to the current Jim TclPaul Fertser
This is a post-release version but hopefully some fixes that went in are worth it; also the changes here make OpenOCD compatible with stock 0.75 version if a distro maintainer decides to use it. Change-Id: I7ad1814c7c4868198475cdca4750c3d0ee4f5f8b Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/2121 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2014-01-09command: Fix formatting for empty usage stringAndreas Fritiofson
Introduced by requirement in 54d6330b. Change-Id: If3dba057127b54b15ca7f364f37c6286d34f77e0 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reported-by: Robert P. J. Day <rpjday@crashcourse.ca> Reviewed-on: http://openocd.zylin.com/1858 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-10-31Remove unnecessary castsAndreas Fritiofson
Change-Id: Ia97283707282ccccdc707c969f59337313b4e291 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/1767 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-10-31Clean up const usage to avoid excessive castingAndreas Fritiofson
Don't use const on pointers that hold heap allocated data, because that means functions that free them must cast away the const. Do use const on pointer parameters or fields that needn't be modified. Remove pointer casts that are no longer needed after fixing the constness. Change-Id: I5d206f5019982fd1950bc6d6d07b6062dc24e886 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/1668 Tested-by: jenkins Reviewed-by: Mathias Küster <kesmtp@freenet.de> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-09-08build: remove clang warning about global var 'match'Spencer Oliver
remove clang warning - "Argument to free() is the address of a global variable, which is not memory allocated by malloc()". Change-Id: I015273eafc9644207684b363434c6ae8149bfcde Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/1613 Tested-by: jenkins
2013-07-01Add support for 64 bit parameter to irscanEvan Hunter
Change-Id: I89e0422456c59ee86c4b6d9bd3b3ad32051b31ac Signed-off-by: Evan Hunter <ehunter@broadcom.com> Reviewed-on: http://openocd.zylin.com/831 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-06-05update files to correct FSF addressSpencer Oliver
Change-Id: I429f7fd51f77b0e7c86d7a7f110ca31afd76c173 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/1426 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2012-11-30Make NetBSD a recognized systemAymeric Vincent
Change-Id: I7fcb540553da7833a8b6a82335a7296539a8f491 Signed-off-by: Aymeric Vincent <vincent.aymeric@gmail.com> Reviewed-on: http://openocd.zylin.com/998 Reviewed-by: Peter Stuge <peter@stuge.se> Tested-by: jenkins
2012-08-24helper: command.c cleanupSpencer Oliver
Change-Id: I66643960e38625e843b5f54d1c072e4eee78284d Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/772 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2012-07-22Revert "When calling openocd from a shell like this:"Alex Austin
This reverts commit e8641695c634109ebf5f1149923971770da1d28a Original premise was wrong. Proper command is "shutdown", not "exit". Change-Id: I07f5fe0dda9c24abe53628da986bfda0e406bb4a Signed-off-by: Alex Austin <alex.austin@spectrumdsi.com> Reviewed-on: http://openocd.zylin.com/757 Tested-by: jenkins Reviewed-by: Peter Stuge <peter@stuge.se>
2012-07-11When calling openocd from a shell like this:Stian Skjelsad
openocd -f board/sheevaplug.cfg -c init -c exit the calling shell will believe that openocd exited with an error due to exitval will be non-zero This is not tested against incomming telnet Change-Id: I63d15715a7b46f39a7de261a45039f8c3cad7a98 Signed-off-by: Stian Skjelstad <stian@nixia.no> Reviewed-on: http://openocd.zylin.com/470 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-by: Bill Traynor <wmat@alphatroop.com> Reviewed-by: Mathias Küster <kesmtp@freenet.de> Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2012-03-31Add value "openbsd" for ocd_HOSTOS.Wim Lewis
Change-Id: I9b0dd87d85c0792730f507176001d39c44da7117 Signed-off-by: Wim Lewis <wiml@hhhh.org> Reviewed-on: http://openocd.zylin.com/547 Tested-by: jenkins Reviewed-by: Peter Stuge <peter@stuge.se>
2012-03-13ecosboard: delete bit-rotted eCos codeØyvind Harboe
Change-Id: Iff7943eb9da3f41dcc45492acd0f36cf63b3497f Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com> Reviewed-on: http://openocd.zylin.com/503 Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com> Tested-by: jenkins
2012-02-06doxygen: use correct comment syntaxSpencer Oliver
This issue was caused by uncrustify not correctly converting the doxygen comments. Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Change-Id: Ie6dc3b057a08603b670cb27312e5f0d989426e6c Reviewed-on: http://openocd.zylin.com/431 Tested-by: jenkins
2012-02-06build: cleanup src/helper directorySpencer Oliver
Change-Id: I71a312df783995e9083c345c25e73902d5aef59e Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/415 Tested-by: jenkins
2012-01-04retire ERROR_INVALID_ARGUMENTS and replace with ERROR_COMMAND_SYNTAX_ERRORØyvind Harboe
Change-Id: I6dee51e1fab1944085391f274a343cdb9014c7a4 Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com> Reviewed-on: http://openocd.zylin.com/300 Tested-by: jenkins Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2012-01-04command: print BUG warning when usage is missingMathias K
These error messages will prompt patches to be submitted for missing .usage or empty fields. All of the below must be resolved before next release. The Jim defined commands are excluded from this checklist because the help text can be set later than during command registration. strlen(.usage) == 0 means that the command expects no arguments. Updates to this patch in Gerrit to fix problems below are most welcome. Anyone can push updated versions of a patch to Gerrit. If there are no further updates to this patch within a week, it will be pushed to the master branch to prompt more fixes. These were caught by launching OpenOCD. Error: BUG: command 'command' does not have the '.usage' field filled out Error: BUG: command 'script' does not have the '.usage' field filled out Error: BUG: command 'power_restore' does not have the '.usage' field filled out Error: BUG: command 'srst_deasserted' does not have the '.usage' field filled out Error: BUG: command 'measure_clk' does not have the '.usage' field filled out Error: BUG: command 'exit' does not have the '.usage' field filled out Error: BUG: command 'shutdown' does not have the '.usage' field filled out Error: BUG: command 'gdb_sync' does not have the '.usage' field filled out Error: BUG: command 'interface_list' does not have the '.usage' field filled out Error: BUG: command 'target' does not have the '.usage' field filled out Error: BUG: command 'target init' does not have the '.usage' field filled out Error: BUG: command 'flash' does not have the '.usage' field filled out Error: BUG: command 'flash init' does not have the '.usage' field filled out Error: BUG: command 'flash banks' does not have the '.usage' field filled out Error: BUG: command 'nand' does not have the '.usage' field filled out Error: BUG: command 'nand drivers' does not have the '.usage' field filled out Error: BUG: command 'nand init' does not have the '.usage' field filled out Error: BUG: command 'pld' does not have the '.usage' field filled out Error: BUG: command 'pld init' does not have the '.usage' field filled out Error: BUG: command 'mflash' does not have the '.usage' field filled out Error: BUG: command 'mflash init' does not have the '.usage' field filled out Error: BUG: command 'dummy' does not have the '.usage' field filled out Error: BUG: command 'dummy foo' does not have the '.usage' field filled out Error: BUG: command 'scan_chain' does not have the '.usage' field filled out Error: BUG: command 'jtag' does not have the '.usage' field filled out Error: BUG: command 'jtag init' does not have the '.usage' field filled out Error: BUG: command 'arm' does not have the '.usage' field filled out Error: BUG: command 'arm reg' does not have the '.usage' field filled out Error: BUG: command 'etm' does not have the '.usage' field filled out Error: BUG: command 'arm7_9' does not have the '.usage' field filled out Error: BUG: command 'at91eb40a.cpu' does not have the '.usage' field filled out Error: BUG: command 'at91eb40a.cpu arm' does not have the '.usage' field filled out Error: BUG: command 'arm reg' does not have the '.usage' field filled out Error: BUG: command 'at91eb40a.cpu etm' does not have the '.usage' field filled out Error: BUG: command 'at91eb40a.cpu arm7_9' does not have the '.usage' field filled out Error: BUG: command 'target_request' does not have the '.usage' field filled out ^C oyvind@fierce:~/openocd$ openocd -c "interface dummy" -f board/at91eb40a.cfg 2>&1 | grep -w BUG Error: BUG: command 'command' does not have the '.usage' field filled out Error: BUG: command 'script' does not have the '.usage' field filled out Error: BUG: command 'power_restore' does not have the '.usage' field filled out Error: BUG: command 'srst_deasserted' does not have the '.usage' field filled out Error: BUG: command 'measure_clk' does not have the '.usage' field filled out Error: BUG: command 'exit' does not have the '.usage' field filled out Error: BUG: command 'shutdown' does not have the '.usage' field filled out Error: BUG: command 'gdb_sync' does not have the '.usage' field filled out Error: BUG: command 'interface_list' does not have the '.usage' field filled out Error: BUG: command 'target' does not have the '.usage' field filled out Error: BUG: command 'target init' does not have the '.usage' field filled out Error: BUG: command 'flash' does not have the '.usage' field filled out Error: BUG: command 'flash init' does not have the '.usage' field filled out Error: BUG: command 'flash banks' does not have the '.usage' field filled out Error: BUG: command 'nand' does not have the '.usage' field filled out Error: BUG: command 'nand drivers' does not have the '.usage' field filled out Error: BUG: command 'nand init' does not have the '.usage' field filled out Error: BUG: command 'pld' does not have the '.usage' field filled out Error: BUG: command 'pld init' does not have the '.usage' field filled out Error: BUG: command 'mflash' does not have the '.usage' field filled out Error: BUG: command 'mflash init' does not have the '.usage' field filled out Error: BUG: command 'dummy' does not have the '.usage' field filled out Error: BUG: command 'dummy foo' does not have the '.usage' field filled out Error: BUG: command 'scan_chain' does not have the '.usage' field filled out Error: BUG: command 'jtag' does not have the '.usage' field filled out Error: BUG: command 'jtag init' does not have the '.usage' field filled out Error: BUG: command 'arm' does not have the '.usage' field filled out Error: BUG: command 'arm reg' does not have the '.usage' field filled out Error: BUG: command 'etm' does not have the '.usage' field filled out Error: BUG: command 'arm7_9' does not have the '.usage' field filled out Error: BUG: command 'at91eb40a.cpu' does not have the '.usage' field filled out Error: BUG: command 'at91eb40a.cpu arm' does not have the '.usage' field filled out Error: BUG: command 'arm reg' does not have the '.usage' field filled out Error: BUG: command 'at91eb40a.cpu etm' does not have the '.usage' field filled out Error: BUG: command 'at91eb40a.cpu arm7_9' does not have the '.usage' field filled out Error: BUG: command 'target_request' does not have the '.usage' field filled out Change-Id: I2c3e529530a15d2295a1950ffc59e8f2fc661012 Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com> Signed-off-by: Mathias K <kesmtp@freenet.de> Reviewed-on: http://openocd.zylin.com/299 Tested-by: jenkins Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com> Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2012-01-03helper: fix arm11 help textSpencer Oliver
This fixes a long standing bug: see Trac #4 Increased help text recursion limit and added LOG_DEBUG so we can catch future errors like this. Change-Id: I5fac95c4486eaddaf1e88a27ecb1835168f87711 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com> Reviewed-on: http://openocd.zylin.com/291 Tested-by: jenkins Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2011-03-27command: fix leak when executing commandsØyvind Harboe
found via valgrind, not observed/reported. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2011-01-09nit: more LOG_* \n fixesEric Wetzel
Remove extra \n from LOG_DEBUG, LOG_INFO, and LOG_WARNING messages Remove LOG_INFO_N LOG_INFO_N was only used once and had a \n at the end Change LOG_USER_N calls that end with \n to LOG_USER