mi-parse.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* MI Command Set - MI Command Parser.
  2. Copyright (C) 2000-2022 Free Software Foundation, Inc.
  3. Contributed by Cygnus Solutions (a Red Hat company).
  4. This file is part of GDB.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #ifndef MI_MI_PARSE_H
  16. #define MI_MI_PARSE_H
  17. #include "gdbsupport/run-time-clock.h"
  18. #include <chrono>
  19. #include "mi-cmds.h" /* For enum print_values. */
  20. /* MI parser */
  21. /* Timestamps for current command and last asynchronous command. */
  22. struct mi_timestamp
  23. {
  24. std::chrono::steady_clock::time_point wallclock;
  25. user_cpu_time_clock::time_point utime;
  26. system_cpu_time_clock::time_point stime;
  27. };
  28. enum mi_command_type
  29. {
  30. MI_COMMAND, CLI_COMMAND
  31. };
  32. struct mi_parse
  33. {
  34. mi_parse ();
  35. ~mi_parse ();
  36. DISABLE_COPY_AND_ASSIGN (mi_parse);
  37. enum mi_command_type op;
  38. char *command;
  39. char *token;
  40. const struct mi_command *cmd;
  41. struct mi_timestamp *cmd_start;
  42. char *args;
  43. char **argv;
  44. int argc;
  45. int all;
  46. int thread_group; /* At present, the same as inferior number. */
  47. int thread;
  48. int frame;
  49. /* The language that should be used to evaluate the MI command.
  50. Ignored if set to language_unknown. */
  51. enum language language;
  52. };
  53. /* Attempts to parse CMD returning a ``struct mi_parse''. If CMD is
  54. invalid, an exception is thrown. For an MI_COMMAND COMMAND, ARGS
  55. and OP are initialized. Un-initialized fields are zero. *TOKEN is
  56. set to the token, even if an exception is thrown. It is allocated
  57. with xmalloc; it must either be freed with xfree, or assigned to
  58. the TOKEN field of the resultant mi_parse object, to be freed by
  59. mi_parse_free. */
  60. extern std::unique_ptr<struct mi_parse> mi_parse (const char *cmd,
  61. char **token);
  62. /* Parse a string argument into a print_values value. */
  63. enum print_values mi_parse_print_values (const char *name);
  64. /* Split ARGS into argc/argv and store the result in PARSE. */
  65. extern void mi_parse_argv (const char *args, struct mi_parse *parse);
  66. #endif /* MI_MI_PARSE_H */