diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-12-04 16:43:54 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-12-04 16:43:54 -0500 |
commit | bab37966cfd192a12d5d1d259c7009a02cefe8b3 (patch) | |
tree | cd931b82c874bb51a037e25c5a887282f34fff4f /gdb/displaced-stepping.h | |
parent | 7def77a1cf6bfd9d3640701dc3414feb0034a858 (diff) | |
download | gdb-bab37966cfd192a12d5d1d259c7009a02cefe8b3.zip gdb-bab37966cfd192a12d5d1d259c7009a02cefe8b3.tar.gz gdb-bab37966cfd192a12d5d1d259c7009a02cefe8b3.tar.bz2 |
gdb: introduce status enum for displaced step prepare/finish
This is a preparatory patch to reduce the size of the diff of the
upcoming main patch. It introduces enum types for the return values of
displaced step "prepare" and "finish" operations. I find that this
expresses better the intention of the code, rather than returning
arbitrary integer values (-1, 0 and 1) which are difficult to remember.
That makes the code easier to read.
I put the new enum types in a new displaced-stepping.h file, because I
introduce that file in a later patch anyway. Putting it there avoids
having to move it later.
There is one change in behavior for displaced_step_finish: it currently
returns 0 if the thread wasn't doing a displaced step and 1 if the
thread was doing a displaced step which was executed successfully. It
turns out that this distinction is not needed by any caller, so I've
merged these two cases into "_OK", rather than adding an extra
enumerator.
gdb/ChangeLog:
* infrun.c (displaced_step_prepare_throw): Change return type to
displaced_step_prepare_status.
(displaced_step_prepare): Likewise.
(displaced_step_finish): Change return type to
displaced_step_finish_status.
(resume_1): Adjust.
(stop_all_threads): Adjust.
* displaced-stepping.h: New file.
Change-Id: I5c8fe07212cd398d5b486b5936d9d0807acd3788
Diffstat (limited to 'gdb/displaced-stepping.h')
-rw-r--r-- | gdb/displaced-stepping.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gdb/displaced-stepping.h b/gdb/displaced-stepping.h new file mode 100644 index 0000000..44aca74 --- /dev/null +++ b/gdb/displaced-stepping.h @@ -0,0 +1,47 @@ +/* Displaced stepping related things. + + Copyright (C) 2020 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef DISPLACED_STEPPING_H +#define DISPLACED_STEPPING_H + +enum displaced_step_prepare_status +{ + /* A displaced stepping buffer was successfully allocated and prepared. */ + DISPLACED_STEP_PREPARE_STATUS_OK, + + /* This particular instruction can't be displaced stepped, GDB should fall + back on in-line stepping. */ + DISPLACED_STEP_PREPARE_STATUS_CANT, + + /* Not enough resources are available at this time, try again later. */ + DISPLACED_STEP_PREPARE_STATUS_UNAVAILABLE, +}; + +enum displaced_step_finish_status +{ + /* Either the instruction was stepped and fixed up, or the specified thread + wasn't executing a displaced step (in which case there's nothing to + finish). */ + DISPLACED_STEP_FINISH_STATUS_OK, + + /* The thread started a displaced step, but didn't complete it. */ + DISPLACED_STEP_FINISH_STATUS_NOT_EXECUTED, +}; + +#endif /* DISPLACED_STEPPING_H */ |