log: add const qualifier to commands struct
[openocd.git] / src / helper / startup.tcl
1 # Defines basic Tcl procs that must exist for OpenOCD scripts to work.
2 #
3 # Embedded into OpenOCD executable
4 #
5
6 # All commands are registered with an 'ocd_' prefix, while the "real"
7 # command is a wrapper that calls this function. Its primary purpose is
8 # to discard 'handler' command output.
9 # Due to the two nested proc calls, this wrapper has to explicitly run
10 # the wrapped command in the stack frame two levels above.
11 proc ocd_bouncer {name args} {
12 set cmd [format "ocd_%s" $name]
13 set type [eval ocd_command type $cmd $args]
14 set errcode error
15 set skiplevel [expr [eval info level] > 1 ? 2 : 1]
16 if {$type == "native"} {
17 return [uplevel $skiplevel $cmd $args]
18 } else {if {$type == "simple"} {
19 set errcode [catch {uplevel $skiplevel $cmd $args}]
20 if {$errcode == 0} {
21 return ""
22 } else {
23 # 'classic' commands output error message as part of progress output
24 set errmsg ""
25 }
26 } else {if {$type == "group"} {
27 catch {eval ocd_usage $name $args}
28 set errmsg [format "%s: command requires more arguments" \
29 [concat $name " " $args]]
30 } else {
31 set errmsg [format "invalid subcommand \"%s\"" $args]
32 }}}
33 return -code $errcode $errmsg
34 }
35
36 # Try flipping / and \ to find file if the filename does not
37 # match the precise spelling
38 proc find {filename} {
39 if {[catch {ocd_find $filename} t]==0} {
40 return $t
41 }
42 if {[catch {ocd_find [string map {\ /} $filename} t]==0} {
43 return $t
44 }
45 if {[catch {ocd_find [string map {/ \\} $filename} t]==0} {
46 return $t
47 }
48 # make sure error message matches original input string
49 return -code error "Can't find $filename"
50 }
51 add_usage_text find "<file>"
52 add_help_text find "print full path to file according to OpenOCD search rules"
53
54 # Find and run a script
55 proc script {filename} {
56 uplevel #0 [list source [find $filename]]
57 }
58 add_help_text script "filename of OpenOCD script (tcl) to run"
59 add_usage_text script "<file>"
60
61 #########
62

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)