diff options
author | Lancelot Six <lancelot.six@amd.com> | 2023-10-13 09:27:48 +0000 |
---|---|---|
committer | Lancelot Six <lancelot.six@amd.com> | 2023-11-21 11:52:35 +0000 |
commit | 6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b (patch) | |
tree | 07259601270022a6cbeb89826560262f015e1589 /gdb/python | |
parent | 6b62451ad08056f0ba02e192ec34ef67c4294ef4 (diff) | |
download | gdb-6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b.zip gdb-6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b.tar.gz gdb-6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b.tar.bz2 |
gdb: Replace gdb::optional with std::optional
Since GDB now requires C++17, we don't need the internally maintained
gdb::optional implementation. This patch does the following replacing:
- gdb::optional -> std::optional
- gdb::in_place -> std::in_place
- #include "gdbsupport/gdb_optional.h" -> #include <optional>
This change has mostly been done automatically. One exception is
gdbsupport/thread-pool.* which did not use the gdb:: prefix as it
already lives in the gdb namespace.
Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-disasm.c | 22 | ||||
-rw-r--r-- | gdb/python/py-framefilter.c | 10 | ||||
-rw-r--r-- | gdb/python/py-inferior.c | 2 | ||||
-rw-r--r-- | gdb/python/py-mi.c | 2 | ||||
-rw-r--r-- | gdb/python/py-utils.c | 4 | ||||
-rw-r--r-- | gdb/python/python-internal.h | 4 | ||||
-rw-r--r-- | gdb/python/python.c | 8 |
7 files changed, 26 insertions, 26 deletions
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c index 6f0fed1..7a13b81 100644 --- a/gdb/python/py-disasm.c +++ b/gdb/python/py-disasm.c @@ -176,7 +176,7 @@ struct gdbpy_disassembler : public gdb_disassemble_info /* Return a reference to an optional that contains the address at which a memory error occurred. The optional will only have a value if a memory error actually occurred. */ - const gdb::optional<CORE_ADDR> &memory_error_address () const + const std::optional<CORE_ADDR> &memory_error_address () const { return m_memory_error_address; } /* Return the content of the disassembler as a string. The contents are @@ -221,7 +221,7 @@ private: /* When the user indicates that a memory error has occurred then the address of the memory error is stored in here. */ - gdb::optional<CORE_ADDR> m_memory_error_address; + std::optional<CORE_ADDR> m_memory_error_address; /* When the user calls the builtin_disassemble function, if they pass a memory source object then a pointer to the object is placed in here, @@ -245,7 +245,7 @@ private: /* Store a single exception. This is used to pass Python exceptions back from ::memory_read to disasmpy_builtin_disassemble. */ - gdb::optional<gdbpy_err_fetch> m_stored_exception; + std::optional<gdbpy_err_fetch> m_stored_exception; }; /* Return true if OBJ is still valid, otherwise, return false. A valid OBJ @@ -1215,7 +1215,7 @@ private: /* See python-internal.h. */ -gdb::optional<int> +std::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, disassemble_info *info) { @@ -1294,7 +1294,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, addr = disasm_info->address; info->memory_error_func (-1, addr, info); - return gdb::optional<int> (-1); + return std::optional<int> (-1); } else if (PyErr_ExceptionMatches (gdbpy_gdberror_exc)) { @@ -1302,12 +1302,12 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, gdb::unique_xmalloc_ptr<char> msg = err.to_string (); info->fprintf_func (info->stream, "%s", msg.get ()); - return gdb::optional<int> (-1); + return std::optional<int> (-1); } else { gdbpy_print_stack (); - return gdb::optional<int> (-1); + return std::optional<int> (-1); } } @@ -1326,7 +1326,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, PyErr_SetString (PyExc_TypeError, _("Result is not a DisassemblerResult.")); gdbpy_print_stack (); - return gdb::optional<int> (-1); + return std::optional<int> (-1); } /* The result from the Python disassembler has the correct type. Convert @@ -1345,7 +1345,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, (PyExc_ValueError, _("Invalid length attribute: length must be greater than 0.")); gdbpy_print_stack (); - return gdb::optional<int> (-1); + return std::optional<int> (-1); } if (length > max_insn_length) { @@ -1354,7 +1354,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, _("Invalid length attribute: length %d greater than architecture maximum of %d"), length, max_insn_length); gdbpy_print_stack (); - return gdb::optional<int> (-1); + return std::optional<int> (-1); } /* It is impossible to create a DisassemblerResult object with an empty @@ -1390,7 +1390,7 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, } } - return gdb::optional<int> (length); + return std::optional<int> (length); } /* The tp_dealloc callback for the DisassemblerResult type. Takes care of diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index e555dc3..dc7e47d 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -32,7 +32,7 @@ #include "demangle.h" #include "mi/mi-cmds.h" #include "python-internal.h" -#include "gdbsupport/gdb_optional.h" +#include <optional> #include "cli/cli-style.h" enum mi_print_types @@ -322,7 +322,7 @@ py_print_single_arg (struct ui_out *out, else val = fv; - gdb::optional<ui_out_emit_tuple> maybe_tuple; + std::optional<ui_out_emit_tuple> maybe_tuple; /* MI has varying rules for tuples, but generally if there is only one element in each item in the list, do not start a tuple. The @@ -562,7 +562,7 @@ enumerate_locals (PyObject *iter, struct symbol *sym; const struct block *sym_block; int local_indent = 8 + (8 * indent); - gdb::optional<ui_out_emit_tuple> tuple; + std::optional<ui_out_emit_tuple> tuple; gdbpy_ref<> item (PyIter_Next (iter)); if (item == NULL) @@ -773,7 +773,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, get_user_print_options (&opts); if (print_frame_info) { - gdb::optional<enum print_what> user_frame_info_print_what; + std::optional<enum print_what> user_frame_info_print_what; get_user_print_what_frame_info (&user_frame_info_print_what); if (!out->is_mi_like_p () && user_frame_info_print_what.has_value ()) @@ -808,7 +808,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, return EXT_LANG_BT_OK; } - gdb::optional<ui_out_emit_tuple> tuple; + std::optional<ui_out_emit_tuple> tuple; /* -stack-list-locals does not require a wrapping frame attribute. */ diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index c0bd6a6..ed153d6 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -364,7 +364,7 @@ add_thread_object (struct thread_info *tp) static void delete_thread_object (thread_info *tp, - gdb::optional<ULONGEST> /* exit_code */, + std::optional<ULONGEST> /* exit_code */, bool /* silent */) { if (!gdb_python_initialized) diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c index aaa225d..d38a0ff 100644 --- a/gdb/python/py-mi.c +++ b/gdb/python/py-mi.c @@ -145,7 +145,7 @@ private: /* If an error occurred, this holds the exception information for use by the 'release' method. */ - gdb::optional<gdbpy_err_fetch> m_error; + std::optional<gdbpy_err_fetch> m_error; /* Return a reference to the object under construction. */ object_desc ¤t () diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index 1552084..f1ca9ea 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -469,12 +469,12 @@ gdbpy_fix_doc_string_indentation (gdb::unique_xmalloc_ptr<char> doc) (user left a single stray space at the start of an otherwise blank line), we don't consider lines without content when updating the MIN_WHITESPACE value. */ - gdb::optional<int> min_whitespace; + std::optional<int> min_whitespace; /* The index into WS_INFO at which the processing of DOC can be considered "all done", that is, after this point there are no further lines with useful content and we should just stop. */ - gdb::optional<size_t> all_done_idx; + std::optional<size_t> all_done_idx; /* White-space information for each line in DOC. */ std::vector<line_whitespace> ws_info; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 847bed8..86eb543 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -732,7 +732,7 @@ class gdbpy_enter /* An optional is used here because we don't want to call PyErr_Fetch too early. */ - gdb::optional<gdbpy_err_fetch> m_error; + std::optional<gdbpy_err_fetch> m_error; }; /* Like gdbpy_enter, but takes a varobj. This is a subclass just to @@ -953,7 +953,7 @@ extern gdb::unique_xmalloc_ptr<char> gdbpy_fix_doc_string_indentation If no instruction can be disassembled then return an empty value. */ -extern gdb::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch, +extern std::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR address, disassemble_info *info); diff --git a/gdb/python/python.c b/gdb/python/python.c index 7e48165..8a36673 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -124,9 +124,9 @@ static void gdbpy_set_quit_flag (const struct extension_language_defn *); static int gdbpy_check_quit_flag (const struct extension_language_defn *); static enum ext_lang_rc gdbpy_before_prompt_hook (const struct extension_language_defn *, const char *current_gdb_prompt); -static gdb::optional<std::string> gdbpy_colorize +static std::optional<std::string> gdbpy_colorize (const std::string &filename, const std::string &contents); -static gdb::optional<std::string> gdbpy_colorize_disasm +static std::optional<std::string> gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch); static ext_lang_missing_debuginfo_result gdbpy_handle_missing_debuginfo (const struct extension_language_defn *extlang, struct objfile *objfile); @@ -1198,7 +1198,7 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang, /* This is the extension_language_ops.colorize "method". */ -static gdb::optional<std::string> +static std::optional<std::string> gdbpy_colorize (const std::string &filename, const std::string &contents) { if (!gdb_python_initialized) @@ -1275,7 +1275,7 @@ gdbpy_colorize (const std::string &filename, const std::string &contents) /* This is the extension_language_ops.colorize_disasm "method". */ -static gdb::optional<std::string> +static std::optional<std::string> gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch) { if (!gdb_python_initialized) |