Annotation of qemu/roms/ipxe/src/hci/commands/gdbstub_cmd.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (C) 2008 Stefan Hajnoczi <[email protected]>.
                      3:  *
                      4:  * This program is free software; you can redistribute it and/or
                      5:  * modify it under the terms of the GNU General Public License as
                      6:  * published by the Free Software Foundation; either version 2 of the
                      7:  * License, or any later version.
                      8:  *
                      9:  * This program is distributed in the hope that it will be useful, but
                     10:  * WITHOUT ANY WARRANTY; without even the implied warranty of
                     11:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                     12:  * General Public License for more details.
                     13:  *
                     14:  * You should have received a copy of the GNU General Public License
                     15:  * along with this program; if not, write to the Free Software
                     16:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                     17:  */
                     18: 
                     19: FILE_LICENCE ( GPL2_OR_LATER );
                     20: 
                     21: #include <stdio.h>
                     22: #include <errno.h>
                     23: #include <assert.h>
                     24: #include <getopt.h>
                     25: #include <ipxe/command.h>
                     26: #include <ipxe/parseopt.h>
                     27: #include <ipxe/gdbstub.h>
                     28: 
                     29: /** @file
                     30:  *
                     31:  * GDB stub command
                     32:  *
                     33:  */
                     34: 
                     35: /**
                     36:  * Parse GDB transport name
                     37:  *
                     38:  * @v text             Text
                     39:  * @ret trans          GDB transport
                     40:  * @ret rc             Return status code
                     41:  */
                     42: static int parse_gdb_transport ( const char *text,
                     43:                                 struct gdb_transport **trans ) {
                     44: 
                     45:        /* Sanity check */
                     46:        assert ( text != NULL );
                     47: 
                     48:        /* Find transport */
                     49:        *trans = find_gdb_transport ( text );
                     50:        if ( ! *trans ) {
                     51:                printf ( "\"%s\": no such transport (is it compiled in?)\n",
                     52:                         text );
                     53:                return -ENOTSUP;
                     54:        }
                     55: 
                     56:        return 0;
                     57: }
                     58: 
                     59: /** "gdbstub" options */
                     60: struct gdbstub_options {};
                     61: 
                     62: /** "gdbstub" option list */
                     63: static struct option_descriptor gdbstub_opts[] = {};
                     64: 
                     65: /** "gdbstub" command descriptor */
                     66: static struct command_descriptor gdbstub_cmd =
                     67:        COMMAND_DESC ( struct gdbstub_options, gdbstub_opts, 1, MAX_ARGUMENTS,
                     68:                       "<transport> [<options>...]" );
                     69: 
                     70: /**
                     71:  * The "gdbstub" command
                     72:  *
                     73:  * @v argc             Argument count
                     74:  * @v argv             Argument list
                     75:  * @ret rc             Return status code
                     76:  */
                     77: static int gdbstub_exec ( int argc, char **argv ) {
                     78:        struct gdbstub_options opts;
                     79:        struct gdb_transport *trans;
                     80:        int rc;
                     81: 
                     82:        /* Parse options */
                     83:        if ( ( rc = parse_options ( argc, argv, &gdbstub_cmd, &opts ) ) != 0 )
                     84:                return rc;
                     85: 
                     86:        /* Parse transport name */
                     87:        if ( ( rc = parse_gdb_transport ( argv[optind++], &trans ) ) != 0 )
                     88:                return rc;
                     89: 
                     90:        /* Initialise transport */
                     91:        if ( trans->init ) {
                     92:                if ( ( rc = trans->init ( argc - optind,
                     93:                                          &argv[optind] ) ) != 0 ) {
                     94:                        return rc;
                     95:                }
                     96:        }
                     97: 
                     98:        /* Enter GDB stub */
                     99:        gdbstub_start ( trans );
                    100: 
                    101:        return 0;
                    102: }
                    103: 
                    104: /** GDB stub commands */
                    105: struct command gdbstub_commands[] __command = {
                    106:        {
                    107:                .name = "gdbstub",
                    108:                .exec = gdbstub_exec,
                    109:        },
                    110: };

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.