Commit Graph

107 Commits

Author SHA1 Message Date
Antonio Borneo b86f296ac6 openocd: src: replace the GPL-2.0-or-later license tag
Replace the FSF boilerplate with the SPDX tag.

The SPDX tag on files *.c is incorrect, as it should use the C99
single line comment using '//'. But current checkpatch doesn't
allow C99 comments, so keep using standard C comments, by now.

Change-Id: I30cd66ac7d737f1973c68fdbb841ffcf00e917c4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7072
Tested-by: jenkins
2022-07-23 13:59:13 +00:00
Tarek BOCHKATI d1b882f2c0 telnet_server: fix scan-build warning
fix "Declared variable-length array (VLA) has zero size" warning
raised in .../src/server/telnet_server.c:633:2:

Change-Id: Icff5228b02790c472b212a86a3849b1a3df98fdb
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6565
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-06-10 21:55:39 +00:00
Erhan Kurubas 822097a351 telnet_server: fix valgrind error
Error: Uninitialised value was created by a heap allocation
at telnet_new_connection (telnet_server.c:227)

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I698a3648be698c93a2395a718ee1ade028226995
Reviewed-on: https://review.openocd.org/c/openocd/+/7006
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-06-08 08:46:09 +00:00
Antonio Borneo 99c77806fe server: change prototype of add_service()
To easily add new methods to a service, pass all the methods
through a struct.
While there, drop the typedef for the methods and add currently
unused new methods to support keep-alive and connections during
keep-alive.

No change in functionality.

Change-Id: I2b5e7140db95021f6e7201e9d631ee340c60b453
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6838
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2022-03-19 09:05:27 +00:00
Tarek BOCHKATI a098816a65 server/telnet: add variables auto-completion
Change-Id: Ie690afad18065cde8d754c8af50dacd9f467c8e5
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6442
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-08-31 04:13:01 +00:00
Tarek BOCHKATI 259e400276 server/telnet: simplify telnet_input function
running complexity on this file tells that:
NOTE: proc telnet_input in file telnet_server.c line 576
	nesting depth reached level 8
==>	*seriously consider rewriting the procedure*.
Complexity Scores
Score | ln-ct | nc-lns| file-name(line): proc-name
  319     272     226   src/server/telnet_server.c(576): telnet_input
total nc-lns      226

so try to reduce the complexity score of telnet_input function

Change-Id: I64ecb0c54da83c27a343f2a1df99fc8f9484572a
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6440
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-08-31 04:12:52 +00:00
Tarek BOCHKATI 9a9e9e2c66 server/telnet: enhance telnet_move_cursor
instrument the telnet_move_cursor to detect when there is no change
of cursor position and if the requested new position is out of bounds.

Change-Id: I24da877e538a458da6d2f8ddc2a681eee404d2cb
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6441
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-08-30 13:54:06 +00:00
Tarek BOCHKATI 70cd395f3f server/telnet: support 'CTRL+C'
like in terminal 'CTRL+C':
 - keeps the line content so the user can refer to it (like copy/paste)
 - marks the line with '^C', as hint that the command was not executed
 - permit the user to write a new command

Change-Id: Ib784c827d64fdc439a35db461d8387a62d3bfbbf
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6439
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2021-08-30 13:53:48 +00:00
Tarek BOCHKATI efe944dfc9 server/telnet: cleanup the if statement mixed style
Change-Id: Ie5f67288511d46fa196bc9f41e6af5504244adaa
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6438
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2021-08-30 13:53:32 +00:00
Antonio Borneo 54e699b260 openocd: manually remove NULL comparisons
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-24 10:38:19 +01:00
Antonio Borneo 3917823187 openocd: remove NULL comparisons with checkpatch [1/2]
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-24 10:38:00 +01:00
Antonio Borneo 08ee7bb982 openocd: fix simple cases of NULL comparison
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-24 10:37:49 +01:00
Antonio Borneo fad1eaaa42 server/telnet: fix autocomplete for jimtcl commands
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-04 17:41:09 +01:00
Antonio Borneo 5ba8e365d9 telnet: allow hiding selected commands during auto-completion
We have TCL procedure and commands that we do not want to show in
the list of auto-completion. E.g. TCL wrappers for deprecated
commands, internal procedures that are not supposed to be exposed
to user, or even commands that the user decides to hide.

Create a TCL procedure to be called by telnet auto-complete code
in place of the hard-coded TCL command. The procedure will run the
same command and will filter-out the unwanted command names.

Initialize the list of commands to be filtered-out with the name
of the TCL procedure above, as it is considered as internal.

Change-Id: I2d83bbf8194502368c589c85cccb617e69128c69
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6194
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2021-05-08 09:48:03 +01:00
Tarek BOCHKATI d10141ef07 telnet: auto-completion of "registered" commands
auto-completion behavior:
- if there is only one matched command complete the user-command
- else if multiple matches add the common part then in second step
  list all matched commands
- sub-commands are handled in the same way
- auto-completion restarts after these characters ';', '[', '{'

Change-Id: I1b81dd19191a5785e68d0bb5cd244e01a4dd0587
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6095
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-05-01 13:53:57 +01:00
Tarek BOCHKATI 78462af05f telnet: support end and home keys
this will help navigate to the line start and end easily

Change-Id: I3f42eb5267df64c59a85ece67de5fce39a8843ec
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6094
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2021-03-19 21:58:59 +00:00
Antonio Borneo cb8e3fb2d9 server: revert commit 7e6556b3ca
With the removal of old tpiu code, commit 7e6556b3ca ("server:
permit the add_service function to return the created service")
http://openocd.zylin.com/5717/ can be reverted.

Fix also the new calls to add_service().

Change-Id: Ib7f2dfc6a9e829239e20313e0f121911085fdc00
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6031
Tested-by: jenkins
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
2021-03-10 21:34:13 +00:00
Tarek BOCHKATI 7e6556b3ca server: permit the add_service function to return the created service
returning the created service seems useful:

as the only method to get the freshly created service is by getting the
last item in the services linked list, and this seems to be like an
intrusion to service internal mechanism.

possibly, we could get the service from a connection but this is possible
only from [new_connection|input|connection_closed]_handler_t, but this is
not always practical:
  example: armv7m: add a TCP channel to stream captured trace
           http://openocd.zylin.com/#/c/5345/
           here we poll for trace and broadcast to all connections
           outside of these xxx_handler_t functions

also, storing one of the connections in new_connection_handler_t and get
the service from it is possible, but this will make the code less readable.

Change-Id: I5fef1baecec1e054953c6faf5b99d864ecc97f02
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5717
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2020-11-07 20:49:53 +00:00
Brian Brooks 9e2a0effb2 server/telnet: Handle Ctrl+K
Handle Ctrl+K shortcut which clears the line from the cursor position
to the end of line.

Change-Id: I2ecff5284473cef7c11cf9cb7e1c0c97d55f6c1c
Signed-off-by: Brian Brooks <brooks.brian@gmail.com>
Reviewed-on: http://openocd.zylin.com/5868
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
2020-10-24 23:25:33 +01:00
Antonio Borneo 4e98d44fd1 openocd: avoid checking for non NULL pointer to free it
The function free() can be called with a NULL pointer as argument,
no need to check the argument before. If the pointer is NULL, no
operation is performed by free().

Remove the occurrences of pattern:
	if (ptr)
		free(ptr);

While there replace a sequence malloc(size)+memset(,0,size) with a
calloc(1,size).
Replace a pointer assignment to '0' with an assignment to NULL.
In server/*, an error is logged if the ptr was already NULL. This
cannot happen since the pointer was already referenced few lines
before and openocd would have been already SIGSEGV in that case,
so remove the log.

Change-Id: I10822029fe8390b59edff4070575bf7f754e44ac
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5808
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
Tested-by: jenkins
2020-09-05 17:11:50 +01:00
Marc Schink 82f71aa274 server/telnet: Fix history output
Restore the prompt after the "history" command is invoked.

Change-Id: I3d0744abbc58e82b039e06f21675efa180e8e1b0
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3414
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-05-09 14:35:43 +01:00
Antonio Borneo ebc2871005 server: set tcp port and bind address before init
All the servers open the listening socket during openocd "init";
it's not possible to change the tcp port or the bind address
after "init".

In current code, the call order during "init" permits to change
the port and bind address of tcl and telnet server if the related
command is issued after "init" in the same script or on openocd
command line. This is not guaranteed to work if the call order
during "init" changes, so it's incorrect.

Change the commands "bindto" and "*_port" to COMMAND_CONFIG.

Change-Id: Id88f225a67a872b4bcaf3b799466bddedc248015
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Christopher Head <chead@zaber.com>
Fixes: https://sourceforge.net/p/openocd/tickets/264/
Reviewed-on: http://openocd.zylin.com/5595
Reviewed-by: Christopher Head <chead@zaber.com>
Tested-by: jenkins
2020-05-02 15:40:57 +01:00
Tomas Vanek 33a3355304 server: free strduped port numbers
Although the leak is negligible, the clean heap on exit will ease
valgrind testing.

Change-Id: I3a7a9c8e8dc7557aa51d0b9caa244537e5e7007d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4410
Tested-by: jenkins
2018-03-15 17:08:53 +00:00
Marc Schink 22ad1c0f60 server/telnet: Use proper data types
Change-Id: Ie7588e311fa5155d5ee73148dee3d0d931bfc7f5
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3413
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2018-01-13 15:33:52 +00:00
Marc Schink e0010c3e6f server/telnet: Handle Ctrl+A and Ctrl+E
Handle the Ctrl+A and Ctrl+E shortcuts which move the cursor to the
beginning and end of the command line, respectively.

Change-Id: I89fa5fd3c5edeb08a3f9320fda766f72ce9d7f64
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3415
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2018-01-13 09:41:26 +00:00
Karl Palsson e78b33e3ca telnet_server: drop unused options
They're never used, so just drop them.

Change-Id: Ie137deed3e7258f9d6af7e0cb508e73df0f53ee0
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-on: http://openocd.zylin.com/4131
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2017-10-03 11:16:36 +01:00
Marc Schink 3421b89c98 server/telnet: Remove exit() call
Change-Id: I8ce99d7d62dfe3cad63cf6bc68f2faf2234e395c
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3224
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2017-04-25 16:56:49 +01:00
Marc Schink b43b95e460 server/server: Remove all exit() calls
With this patch OpenOCD shuts down properly when errors occur in the
server instead of just calling exit().

Change-Id: I2ae1a6153dafc88667951cab9152941cb487be85
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3223
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2017-04-25 16:56:35 +01:00
Marc Schink d0e763ac7e Remove FSF address from GPL notices
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>
2016-05-24 22:30:01 +01:00
Marc Schink 54908d9fb9 server/telnet: Check malloc() return values
Change-Id: I598bd2dd5a65c0d1a8745bde41763057c4427a31
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3412
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2016-05-04 22:48:18 +01:00
Austin Morton 8bffcc0cd4 server: remove connection limit from tcl and telnet servers
Add constant CONNECTION_LIMIT_UNLIMITED which indicates a service
has no connection limit

Change-Id: I008d31264010c25fa44ca74eb6d5740eca38bee1
Signed-off-by: Austin Morton <austinpmorton@gmail.com>
Reviewed-on: http://openocd.zylin.com/2937
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2015-09-28 08:01:02 +01:00
Andreas Fritiofson 517ba0690d Clean up const usage to avoid excessive casting
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-10-31 20:42:34 +00:00
Spencer Oliver 08d4411b59 update files to correct FSF address
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>
2013-06-05 19:52:42 +00:00
Paul Fertser 4264431824 telnet_server: support C-p, C-n for moving through history
This modifies telnet server to allow using common readline combinations to
move up/down history, without the need to touch cursor keys.

Change-Id: Ib659075883e91794b44f391f7c29bbdfdd679d10
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1376
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2013-05-08 14:54:29 +00:00
Spencer Oliver ff1108ad38 telnet: add telnet history support
adapted from Yoshinori Sato's patch:
2f07f4600a

Change-Id: I084b86d316b0aa6e9593f007c024961dbda805e9
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/1310
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2013-04-21 07:28:32 +00:00
Spencer Oliver 40801d21ff telnet: cleanup comments
seems comments were mangled during the last cleanup.

Change-Id: If759f62032705c7baffd3973e9717eb7e8a5d17c
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/752
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2012-07-30 06:52:44 +00:00
Spencer Oliver b48d1f6637 build: cleanup src/server directory
Change-Id: I6410df28c5999f5cbee2d3bcaa02469a29ea4c15
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/412
Tested-by: jenkins
2012-02-06 10:47:01 +00:00
Spencer Oliver 0c2f8b6eb8 cmd: add missing usage vars
we should have caught them all - hopefully.

Change-Id: I35435317fccaf5ad0216244d69f76db6857bb582
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/381
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2012-01-18 21:45:02 +00:00
Øyvind Harboe 96a56ba086 pipes: add documentation for pipes
Stick with the name "gdb_port" even if this command
can be used for other things(disable, named pipes,
anonymous stdin/out pipe). "port" is correct for
probably more than 90% of use cases, if not more.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-10-01 10:26:10 +02:00
Øyvind Harboe 50d5441e2a server: add support for pipes
-p/--pipe is now deprecated. Use '-c "gdb_port pipe;log_output openocd.log"'
instead. Warning logged.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-10-01 10:26:08 +02:00
Øyvind Harboe 6c137a2fc0 server: specify port as a string
This will allow switching to using named pipes.

Split this out as a seperate commit to make changes
easier to follow.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-10-01 10:21:33 +02:00
Øyvind Harboe cb2dba2c12 server: read/write now goes through connection fn's
depending on whether the connection is over a socket
or pipe, the read is done differently.

pipes can return -1 when writing 0 bytes, make 0 byte
writes a successful no-op. 0 byte writes falls out
naturally of tcl server code.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-10-01 10:21:33 +02:00
Øyvind Harboe 5a41435e45 server: split file descriptors in in/out fd's
pipes have different fd's for in/out. This makes the
code more orthogonal and prepares for adding pipes.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-10-01 10:21:33 +02:00
Antonio Borneo 4af724df23 telnet_server: review unused symbols
Remove unused function

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-03-25 07:44:59 +01:00
Antonio Borneo ec28c674af telnet_server: review scope of functions
Add "static" qualifier to private functions.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-03-25 07:44:55 +01:00
Øyvind Harboe f68dff6690 telnet: fix strage blank spaces at beginning of telnet lines
Sometimes we saw two strange blank spaces at the beginning
of the telnet lines.

progress
  ogress
>

This patch fixes this problem:

progress
progress
>

The code changes are *reasonably* clean, but perhaps it could be
made a bit more elegant, but I didn't want to change things after
I finished diagnosis/testing & submitting the patch.

The problem was that logging can send the text and the newline
separately in two different requests and the telnet code would
incorrectly remove the prompt from the end of a line.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-01-31 15:06:02 +01:00
David Brownell fc9a2d0e6f src/server: usage/help/doc updates
Make "usage" messages use the same EBNF as the User's Guide;
no angle brackets.  Improve and correct various helptexts.

Specifically for the port commands, clarify that the number
is optional, and omitting it causes the current number to be
displayed.

Don't use "&function"; a function's name is its address.
Remove a couple instances of pointless whitespace; shrink a
few overlong lines.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-09 00:55:41 -08:00
David Brownell 08a890e4aa cygwin 1.7 build fixes
It's less accepting of signed char ... insisting that e.g. tolower()
not receive one as a parameter.

It's probably good to phase out such usage, given the number of bugs
that lurk in the vicinity (assumptions that char is unsigned), so fix
these even though such usage is actually legal.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-26 10:19:19 -08:00
Zachary T Welch 5a94612148 change #include "target_request.h" to <target/target_request.h>
Changes from the flat namespace to heirarchical one.  Instead of writing:

	#include "target_request.h"

the following form should be used.

	#include <target/target_request.h>

The exception is from .c files in the same directory.
2009-12-03 04:24:42 -08:00
Zachary T Welch b4c4b5f71e server: use register_commands
Converts server directory to use new command registration paradigm.
2009-11-24 21:37:32 -08:00