gdb/exceptions.h - gdb

Data types defined

Macros defined

Source code

  1. /* Exception (throw catch) mechanism, for GDB, the GNU debugger.

  2.    Copyright (C) 1986-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef EXCEPTIONS_H
  15. #define EXCEPTIONS_H

  16. #include "ui-out.h"

  17. /* A pre-defined non-exception.  */
  18. extern const struct gdb_exception exception_none;

  19. /* If E is an exception, print it's error message on the specified
  20.    stream.  For _fprintf, prefix the message with PREFIX...  */
  21. extern void exception_print (struct ui_file *file, struct gdb_exception e);
  22. extern void exception_fprintf (struct ui_file *file, struct gdb_exception e,
  23.                                const char *prefix,
  24.                                ...) ATTRIBUTE_PRINTF (3, 4);

  25. /* Call FUNC(UIOUT, FUNC_ARGS) but wrapped within an exception
  26.    handler.  If an exception (enum return_reason) is thrown using
  27.    throw_exception() than all cleanups installed since
  28.    catch_exceptions() was entered are invoked, the (-ve) exception
  29.    value is then returned by catch_exceptions.  If FUNC() returns
  30.    normally (with a positive or zero return value) then that value is
  31.    returned by catch_exceptions().  It is an internal_error() for
  32.    FUNC() to return a negative value.

  33.    For the period of the FUNC() call: UIOUT is installed as the output
  34.    builder; ERRSTRING is installed as the error/quit message; and a
  35.    new cleanup_chain is established.  The old values are restored
  36.    before catch_exceptions() returns.

  37.    The variant catch_exceptions_with_msg() is the same as
  38.    catch_exceptions() but adds the ability to return an allocated
  39.    copy of the gdb error message.  This is used when a silent error is
  40.    issued and the caller wants to manually issue the error message.

  41.    MASK specifies what to catch; it is normally set to
  42.    RETURN_MASK_ALL, if for no other reason than that the code which
  43.    calls catch_errors might not be set up to deal with a quit which
  44.    isn't caught.  But if the code can deal with it, it generally
  45.    should be RETURN_MASK_ERROR, unless for some reason it is more
  46.    useful to abort only the portion of the operation inside the
  47.    catch_errors.  Note that quit should return to the command line
  48.    fairly quickly, even if some further processing is being done.

  49.    FIXME; cagney/2001-08-13: The need to override the global UIOUT
  50.    builder variable should just go away.

  51.    This function supersedes catch_errors().

  52.    This function uses SETJMP() and LONGJUMP().  */

  53. struct ui_out;
  54. typedef int (catch_exceptions_ftype) (struct ui_out *ui_out, void *args);
  55. extern int catch_exceptions (struct ui_out *uiout,
  56.                              catch_exceptions_ftype *func, void *func_args,
  57.                              return_mask mask);
  58. typedef void (catch_exception_ftype) (struct ui_out *ui_out, void *args);
  59. extern int catch_exceptions_with_msg (struct ui_out *uiout,
  60.                                            catch_exceptions_ftype *func,
  61.                                            void *func_args,
  62.                                            char **gdberrmsg,
  63.                                       return_mask mask);

  64. /* If CATCH_ERRORS_FTYPE throws an error, catch_errors() returns zero
  65.    otherwize the result from CATCH_ERRORS_FTYPE is returned.  It is
  66.    probably useful for CATCH_ERRORS_FTYPE to always return a non-zero
  67.    value.  It's unfortunate that, catch_errors() does not return an
  68.    indication of the exact exception that it caught - quit_flag might
  69.    help.

  70.    This function is superseded by catch_exceptions().  */

  71. typedef int (catch_errors_ftype) (void *);
  72. extern int catch_errors (catch_errors_ftype *, void *, char *, return_mask);

  73. #endif