aboutsummaryrefslogtreecommitdiff
path: root/src/helper
AgeCommit message (Collapse)Author
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-05-14helper/command: add macro CMDAntonio Borneo
Accessing the variable "cmd" in a COMMAND_HANDLER is confusing because the variable definition is not visible in the prototype, thus "cmd" can be identified by the reader as a global variable defined somewhere else. Add the new macro CMD to make more evident it is a part of the COMMAND_HANDLER. Change-Id: I8f63da593a931045cc404323f143b88c5c80ab5e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5047 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-10fix for sanitizer errors in left shiftsMete Balci
The modified lines cause "runtime error: left shift of <X> by <Y> places cannot be represented in type 'int'", because integer literal is cast to int by default. Change-Id: Ie38119b5eb46ee470e0d149959e523b48ac4d66d Signed-off-by: Mete Balci <metebalci@gmail.com> Reviewed-on: http://openocd.zylin.com/5005 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-07Set empty usage field for commands that do not need parametersAntonio Borneo
The missing field causes runtime debug message BUG: command '%s' does not have the '.usage' field filled out While there, fix some minor typo in the help messages: s/deasert/deassert/ s/Deasert/Deassert/ Change-Id: If3dd18265cda103ca0d05609f67f4ca58e7cbb27 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5024 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-04-07log: add const qualifier to commands structAntonio Borneo
The struct log_command_handlers[] is never modified. Add const qualifier to it. Change-Id: I5785aeb09ae9c23eaf7c34a05b88d0c7285f2d78 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5009 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2019-04-03helper/startup.tcl: remove proc exitAntonio Borneo
The TCL command exit is already replaced by the OpenOCD command exit in server/telnet_server.c, no need to redefine it in the script. Moreover, the implementation is broken because the proc ocd_throw has been removed in mid 2008 with pre-git-era commit dfbb9f3e89ae in svn rev 849. Remove completely the unused proc exit. Change-Id: I0365d740eccc47631eb459aab77b865b0877c1f7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4986 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-12-15helper/startup.tcl: fix execution stack frame of wrapped commandsAntonio Borneo
The OpenOCD commands that have been wrapped with 'ocd_bouncer' are executed within two levels of nested proc's: # see register_command_handler() in src/helper/command.c proc my_command {args} {eval ocd_bouncer my_command $args} # see ocd_bouncer in src/helper/startup.tcl proc ocd_bouncer {name args} { ... [eval ocd_my_command $args] ... } This causes the stack frame of 'ocd_my_command' to be the same one of proc 'ocd_bouncer', thus two levels below the stack frame of the caller of 'my_command'. This is an issue with commands that receive a variable by name and have to resolve them to access the value. E.g. the command <target> mem2array arrayname bitwidth address count is wrapped; it receives the name of the array but fails to resolve it in the current stack frame. Instead, the commands mem2array arrayname bitwidth address count ocd_<target> mem2array arrayname bitwidth address count are not wrapped and can directly access the array because they share the same stack frame of the caller. Same situation with the symmetric commands 'array2mem'. How to test: within a telnet connection, run the following set of commands, eventually replacing the address 0x08000000 with a valid readable address of your <target>, unset -nocomplain v1 v2 v3 info vars v? mem2array v1 32 0x08000000 1 <target> mem2array v2 32 0x08000000 1 ocd_<target> mem2array v3 32 0x08000000 1 info vars v? and notice that only v1 and v3 are now allocated. The array v2 has been allocated in the temporarily stack frame of proc ocd_bouncer, together with its local variables, and then lost when proc ended. Fixed by executing the wrapped commands with the command 'uplevel' instead of 'eval'. The amount of levels to skip is checked to avoid errors in the unusual case 'ocd_bouncer' is called directly without the first level of wrapper. Change-Id: Iff90fb8921faf9b5ab04f61062a530578cc20d78 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4731 Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2018-12-11helper/log: remove dead code in log_forward()Antonio Borneo
Commit f1be0e6af2e204805a8bc2e8cadf828b9fa46c98 ("HELPER/LOG: review unused symbols") removed a set of unused functions and, as consequence, there is no code anymore that sets the variable "log_forward_count". But, the commit above did not removed the code (now dead) that depends on "log_forward_count" set. Remove the code dependant on "log_forward_count" set and the variable itself. Change-Id: I6efe93d1dccbe13c409c5bc55ba47a2684c0e3ac Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4779 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2018-07-24Add RISC-V support.Tim Newsome
This supports both 0.11 and 0.13 versions of the debug spec. Support for `-rtos riscv` will come in a separate commit since it was easy to separate out, and is likely to be more controversial. Flash support for the SiFive boards will also come in a later commit. Change-Id: I1d38fe669c2041b4e21a5c54a091594aac3e2190 Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: http://openocd.zylin.com/4578 Tested-by: jenkins Reviewed-by: Liviu Ionescu <ilg@livius.net> Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
2018-03-12helper/types: cast to uint32_t,uint16_t to avoid UB by shifting int too farCody P Schafer
Without this, we have some types promoted to `int` when they need to be `unsigned int`. Here's some ubsan output hitting this: Unfortunately, what happens is that things get promoted to `int`, but need to be `unsigned int`. Here's the ubsan output: src/helper/types.h:126:65: runtime error: left shift of 255 by 24 places cannot be represented in type 'int' #0 0x55978a612060 in le_to_h_u32 src/helper/types.h:126 #1 0x55978a61ff9e in stlink_usb_read_reg src/jtag/drivers/stlink_usb.c:1539 #2 0x55978a8cfd45 in adapter_load_core_reg_u32 src/target/hla_target.c:67 #3 0x55978a9f48e3 in armv7m_read_core_reg src/target/armv7m.c:236 #4 0x55978a8d24fc in adapter_load_context src/target/hla_target.c:372 #5 0x55978a8d261b in adapter_debug_entry src/target/hla_target.c:396 #6 0x55978a8d3123 in adapter_poll src/target/hla_target.c:457 #7 0x55978a528357 in target_poll src/target/target.c:535 #8 0x55978a539fd4 in target_wait_state src/target/target.c:2914 #9 0x55978a556e20 in jim_target_wait_state src/target/target.c:5256 #10 0x55978a5cca62 in command_unknown src/helper/command.c:1030 #11 0x55978aaed894 in JimInvokeCommand /home/cody/d/openocd-code/jimtcl/jim.c:10364 Change-Id: I24f6abfd26b6980100657397d69c84f2b80a005a Signed-off-by: Cody P Schafer <openocd@codyps.com> Reviewed-on: http://openocd.zylin.com/4455 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com>
2018-03-07helper/configuration: free script_search_dirs and config_file_namesTomas Vanek
Although the leak is negligible, the clean heap on exit will ease valgrind testing. Change-Id: If43f02fe594c30ceb1bea3259ea3e098d4b2d239 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4408 Tested-by: jenkins Reviewed-by: Marc Schink <openocd-dev@marcschink.de>
2018-03-07helper/command.h: Add missing #include for target_addr_tMarc Schink
Change-Id: Ic406257c0da6e1889d4434cc98cf59c2b97aa30c Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/4052 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2018-03-07helper/types.h: Add missing #includesMarc Schink
Change-Id: I02ae0fb9527c4b87308da9c2cab66c80d84579eb Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/4050 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2018-03-07helper/command.h: Add missing #includesMarc Schink
Change-Id: I84650a51cdb015f5e8ae933a3288f6e87f9fb80b Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/4049 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2018-03-07helper/replacements.h: Add missing #includeMarc Schink
Change-Id: Ic6c47f7fbc999d00ef3211c1fa44867e3aabc321 Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/4057 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
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-02-14Handle improperly build image files gracefullyAndreas Bolsch
Images build improperly (by simply concatenating separate images) were accepted, but anything after the first end-of-file record *silently* ignored. Now emit warning for intel and motorola images upon non-whitespace after first end-of-file record but continue reading anyway. ST ships some images broken that way in their CubeMX packages ... Change-Id: I0c5d08fa90070fed11fb805c5f0dc39817048176 Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com> Reviewed-on: http://openocd.zylin.com/4281 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2018-01-25Add read buffer to bitbang, improving performance.Tim Newsome
Previously for every bit scanned OpenOCD would write the bit, wait for that bit to be scanned, and then read the result. This involves at least 2 context switches. Most of the time the next bit scanned does not depend on the last bit we read, so with a buffer we now write a bunch of bits to be scanned all at once, and then we wait for them all to be scanned and have a result. This reduces the time for one testcase where OpenOCD connects to a simulator from 12.30s to 5.35s! Running all our tests went from 13m13s to 3m55s. Change-Id: Ie9fcea043ac1d7877a521125334ed47d4b3e1615 Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: http://openocd.zylin.com/4312 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2018-01-25Add timeval_compare helper functionChristopher Head
Change-Id: Id75727a150912ff778a4fa32ad56467da33a6324 Signed-off-by: Christopher Head <chead@zaber.com> Reviewed-on: http://openocd.zylin.com/4379 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
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-10-03Fix typo in comment.Tim Newsome
Change-Id: I6567f85f399315e1dac98881765dfaa6eab5facb Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: http://openocd.zylin.com/4238 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2017-10-03helper/options: Add missing #include for MinGW and MSYS2Marc Schink
Change-Id: I3bb295f52706b641661241e3e047306811ca915e Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/4201 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2017-08-10log: Add a new debug level (4) for verbose I/O debugAndreas Fritiofson
Change ftdi SWD driver and CMSIS-DAP to use it instead of LOG_DEBUG(). Change-Id: I17ba3de2086c7159209db61fba3faf067dfc5023 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/3805 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2017-04-23help/log.c: better error handling for "log_output"Girts
* Close previous log file if one was opened before. * Return error if opening file fails. Change-Id: I103025cd86bcac785fe39e13bc7d5f79d78e38e7 Signed-off-by: Girts Folkmanis <opensource@girts.me> Reviewed-on: http://openocd.zylin.com/3878 Tested-by: jenkins Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2017-04-23helper/options.c: fail if unexpected cmdline arguments are presentGirts
Previously openocd would silently ignore any incorrect arguments. Change-Id: Ibb40b57b8a9e07d191215486f3b3c4920a9963c7 Signed-off-by: Girts Folkmanis <opensource@girts.me> Reviewed-on: http://openocd.zylin.com/3879 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2017-04-23help/options.c: add error handling for -d argGirts
Fail if we fail to set debug level. Also, clarify in usage string that -d<n> doesn't accept spaces. Change-Id: I9ea9945dc068e3e7cfd18b16ffa2a29366d6e4d1 Signed-off-by: Girts Folkmanis <opensource@girts.me> Reviewed-on: http://openocd.zylin.com/3880 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
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>
2017-01-15helper,rtos,server: Restore missing warning flagsAndreas Fritiofson
These libraries override the used CFLAGS without adding the defaults. This didn't have any effect until change http://openocd.zylin.com/3870 (ef4c139). Restore by adding AM_CLAGS to the per-target CFLAGS. Interestingly, automake seems to clear the CFLAGS for the target even if the override variable is only mentioned within a non-active conditional branch, such as the IS_MINGW for the affected libraries. Change-Id: I805206865e59e3fa33a7ea3c0d3472e51219351c Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/3927 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2016-12-25Search for scripts relative to the executable on all(?) platformsAndreas Fritiofson
Add a helper to hide the platform-dependent method to get a canonical, absolute, /-separated path to the executable. Use this and the relative path from BINDIR to PKGDATADIR to construct a search path that finds the scripts even if the installation dir is moved, as long as the structure below $prefix is maintained. This method should fully support all the tricks you can to with autotools to customize the installed layout such as overriding the default directories at configure-time and overriding the configured directories at build-time. The exe path detection methods are combined from http://openocd.zylin.com/3388 by Rick Foos and http://openocd.zylin.com/3537 by Steven Stallion, as well as tips found all over internet. Change-Id: Ifc9cc9dd0bf52fbd67b1b0f2383318cda0c422c4 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Signed-off-by: Steven Stallion <sstallion@gmail.com> Reviewed-on: http://openocd.zylin.com/3889 Tested-by: jenkins Reviewed-by: Rick Foos <rfoos@solengtech.com> Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2016-12-08Convert to non-recursive makeAndreas Fritiofson
Change-Id: I11f8bc8553957e2ff083c09e72e16881e4d3bb6f Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/3865 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2016-12-08helper: Code cleanup for hexify()Marc Schink
Simplify hexify() and do not longer use 0 as special case for the parameter 'count' to determine the string length of the binary input. Instead, use strlen() outside of the function if needed. Additionally, fix the return value and return the length of the converted string. The old function always returned 2 * count. Also, use more appropriate data types for the function parameters and add a small documentation. Change-Id: I133a8ab786b8f7c1296afcaf9c0a0b43881e5112 Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/3793 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2016-12-08helper: Update jep106 database to JEP106ATAndreas Fritiofson
Change-Id: I2dac416189d16938597c073fd35ad654bca7484c Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-on: http://openocd.zylin.com/3871 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>