[gdb/testsuite] Factor out proc get_portnum

In gdbserver_start, we have some code that determines what port number to use:
...
    # Port id -- either specified in baseboard file, or managed here.
    if [target_info exists gdb,socketport] {
       set portnum [target_info gdb,socketport]
    } else {
       # Bump the port number to avoid conflicts with hung ports.
       incr portnum
    }
...

Factor this out into a new proc get_portnum.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
1 file changed