15796c8dcSSimon Schubert /* MI Command Set - MI Command Parser. 2*ef5ccd6cSJohn Marino Copyright (C) 2000-2013 Free Software Foundation, Inc. 35796c8dcSSimon Schubert Contributed by Cygnus Solutions (a Red Hat company). 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GDB. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 105796c8dcSSimon Schubert (at your option) any later version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155796c8dcSSimon Schubert GNU General Public License for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert #ifndef MI_PARSE_H 215796c8dcSSimon Schubert #define MI_PARSE_H 225796c8dcSSimon Schubert 235796c8dcSSimon Schubert #include <sys/time.h> 245796c8dcSSimon Schubert 255796c8dcSSimon Schubert /* MI parser */ 265796c8dcSSimon Schubert 275796c8dcSSimon Schubert /* Timestamps for current command and last asynchronous command. */ 285796c8dcSSimon Schubert struct mi_timestamp { 295796c8dcSSimon Schubert struct timeval wallclock; 305796c8dcSSimon Schubert struct timeval utime; 315796c8dcSSimon Schubert struct timeval stime; 325796c8dcSSimon Schubert }; 335796c8dcSSimon Schubert 345796c8dcSSimon Schubert enum mi_command_type 355796c8dcSSimon Schubert { 365796c8dcSSimon Schubert MI_COMMAND, CLI_COMMAND 375796c8dcSSimon Schubert }; 385796c8dcSSimon Schubert 395796c8dcSSimon Schubert struct mi_parse 405796c8dcSSimon Schubert { 415796c8dcSSimon Schubert enum mi_command_type op; 425796c8dcSSimon Schubert char *command; 435796c8dcSSimon Schubert char *token; 445796c8dcSSimon Schubert const struct mi_cmd *cmd; 455796c8dcSSimon Schubert struct mi_timestamp *cmd_start; 465796c8dcSSimon Schubert char *args; 475796c8dcSSimon Schubert char **argv; 485796c8dcSSimon Schubert int argc; 49cf7f2e2dSJohn Marino int all; 50cf7f2e2dSJohn Marino int thread_group; /* At present, the same as inferior number. */ 515796c8dcSSimon Schubert int thread; 525796c8dcSSimon Schubert int frame; 535796c8dcSSimon Schubert }; 545796c8dcSSimon Schubert 55c50c785cSJohn Marino /* Attempts to parse CMD returning a ``struct mi_parse''. If CMD is 56c50c785cSJohn Marino invalid, an exception is thrown. For an MI_COMMAND COMMAND, ARGS 57c50c785cSJohn Marino and OP are initialized. Un-initialized fields are zero. *TOKEN is 58c50c785cSJohn Marino set to the token, even if an exception is thrown. It is allocated 59c50c785cSJohn Marino with xmalloc; it must either be freed with xfree, or assigned to 60c50c785cSJohn Marino the TOKEN field of the resultant mi_parse object, to be freed by 61c50c785cSJohn Marino mi_parse_free. */ 625796c8dcSSimon Schubert 63*ef5ccd6cSJohn Marino extern struct mi_parse *mi_parse (const char *cmd, char **token); 645796c8dcSSimon Schubert 655796c8dcSSimon Schubert /* Free a command returned by mi_parse_command. */ 665796c8dcSSimon Schubert 675796c8dcSSimon Schubert extern void mi_parse_free (struct mi_parse *cmd); 685796c8dcSSimon Schubert 695796c8dcSSimon Schubert #endif 70