gdbstub_cmd.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <stdio.h>
00020 #include <getopt.h>
00021 #include <gpxe/command.h>
00022 #include <gpxe/gdbstub.h>
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 static void gdbstub_syntax ( char **argv ) {
00036 printf ( "Usage:\n"
00037 " %s <transport> [<options>...]\n"
00038 "\n"
00039 "Start remote debugging using one of the following transports:\n"
00040 " serial use serial port (if compiled in)\n"
00041 " udp <interface> use UDP over network interface (if compiled in)\n",
00042 argv[0] );
00043 }
00044
00045
00046
00047
00048
00049
00050
00051
00052 static int gdbstub_exec ( int argc, char **argv ) {
00053 static struct option longopts[] = {
00054 { "help", 0, NULL, 'h' },
00055 { NULL, 0, NULL, 0 },
00056 };
00057 const char *trans_name;
00058 struct gdb_transport *trans;
00059 int c;
00060
00061
00062 while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
00063 switch ( c ) {
00064 case 'h':
00065
00066 default:
00067
00068 gdbstub_syntax ( argv );
00069 return 1;
00070 }
00071 }
00072
00073
00074 if ( optind == argc ) {
00075 gdbstub_syntax ( argv );
00076 return 1;
00077 }
00078
00079 trans_name = argv[optind++];
00080
00081
00082 trans = find_gdb_transport ( trans_name );
00083 if ( !trans ) {
00084 printf ( "%s: no such transport (is it compiled in?)\n", trans_name );
00085 return 1;
00086 }
00087
00088 if ( trans->init ) {
00089 if ( trans->init ( argc - optind, &argv[optind] ) != 0 ) {
00090 return 1;
00091 }
00092 }
00093
00094
00095 gdbstub_start ( trans );
00096 return 0;
00097 }
00098
00099
00100 struct command gdbstub_commands[] __command = {
00101 {
00102 .name = "gdbstub",
00103 .exec = gdbstub_exec,
00104 },
00105 };