Some gdb_exception{,error,quit} tweaks
authorPedro Alves <palves@redhat.com>
Mon, 8 Apr 2019 12:03:54 +0000 (13:03 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 8 Apr 2019 19:13:32 +0000 (20:13 +0100)
commit56be6ea89cdf94078d5dff3734b8c1970dbf52fa
tree72a8d6b1b905e36c0f59f3d522130598be0d221e
parent3ae61bb67d62eb53d110835b8b7c3a289e6bce45
Some gdb_exception{,error,quit} tweaks

- Explicitly include <string> for std::string.

- Use std::make_shared to construct gdb_exception::message instead of
  operator new, avoiding one heap allocation (2 instead of 3).  Add
  'const char *fmt, va_list ap' parameters to
  gdb_exception{,error,quit}'s ctors, and do the std::make_shared in
  the gdb_exception ctor.

- gdb_exception_error's constructor does not need to have an 'enum
  return_reason' parameter, since it is always RETURN_ERROR, by
  definition.

- Similarly, gdb_exception_quit's contructor does not need to have
  'enum return_reason'/'enum errors' parameters.

- In the gdb_exception_{quit,_error} ctors that take a gdb_exception
  as argument, assert that they're being passed a gdb_exception object
  of the right 'reason'.

gdb/ChangeLog:
2019-04-08  Pedro Alves  <palves@redhat.com>

* common/common-exceptions.c (throw_exception): Don't create
named object to throw; throw directly.
(throw_it): Likewise.  Don't initialize gdb_exception::message
here, with new; pass FMT and AP to the ctor instead.
* common/common-exceptions.h: Include <string>.
(gdb_exception::gdb_exception(enum return_reason, enum errors,
const char *, va_list)): New ctor.  Use std::make_shared.
(gdb_exception_error::gdb_exception_error(enum return_reason, enum
errors)): Delete.
(gdb_exception_error::gdb_exception_error(enum errors, const char
*, va_list)): New.
(gdb_exception_error::gdb_exception_error(const gdb_exception &)):
Add assertion.
(gdb_exception_quit::gdb_exception_quit(enum return_reason, enum
errors)): Delete.
(gdb_exception_quit::gdb_exception_quit(const char *, va_list)): New.
(gdb_exception_quit::gdb_exception_quit(const gdb_exception &)):
Add assertion.
gdb/ChangeLog
gdb/common/common-exceptions.c
gdb/common/common-exceptions.h
This page took 0.024829 seconds and 4 git commands to generate.