arm, objdump: print obsolote warning when 26-bit set in instructions
[binutils-gdb.git] / gdb / python / py-dap.c
blobd5555c90a11bf91ba2a3070303d1f4684025cac3
1 /* Python DAP interpreter
3 Copyright (C) 2022-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "python-internal.h"
21 #include "interps.h"
22 #include "cli-out.h"
23 #include "ui.h"
25 class dap_interp final : public interp
27 public:
29 explicit dap_interp (const char *name)
30 : interp (name),
31 m_ui_out (new cli_ui_out (gdb_stdout))
35 ~dap_interp () override = default;
37 void init (bool top_level) override;
39 void suspend () override
43 void resume () override
47 void exec (const char *command) override
49 /* Just ignore it. */
52 void set_logging (ui_file_up logfile, bool logging_redirect,
53 bool debug_redirect) override
55 /* Just ignore it. */
58 ui_out *interp_ui_out () override
60 return m_ui_out.get ();
63 void pre_command_loop () override;
65 bool supports_new_ui () const override
66 { return false; }
68 private:
70 std::unique_ptr<ui_out> m_ui_out;
74 /* Call function FN_NAME from module gdb.dap. */
76 static void
77 call_dap_fn (const char *fn_name)
79 gdbpy_enter enter_py;
81 gdbpy_ref<> dap_module (PyImport_ImportModule ("gdb.dap"));
82 if (dap_module == nullptr)
83 gdbpy_handle_exception ();
85 gdbpy_ref<> func (PyObject_GetAttrString (dap_module.get (), fn_name));
86 if (func == nullptr)
87 gdbpy_handle_exception ();
89 gdbpy_ref<> result_obj (PyObject_CallObject (func.get (), nullptr));
90 if (result_obj == nullptr)
91 gdbpy_handle_exception ();
94 void
95 dap_interp::init (bool top_level)
97 #if CXX_STD_THREAD
98 call_dap_fn ("run");
100 current_ui->input_fd = -1;
101 current_ui->m_input_interactive_p = false;
102 #else
103 error (_("GDB was compiled without threading, which DAP requires"));
104 #endif
107 void
108 dap_interp::pre_command_loop ()
110 call_dap_fn ("pre_command_loop");
113 void _initialize_py_interp ();
114 void
115 _initialize_py_interp ()
117 /* The dap code uses module typing, available starting python 3.5. */
118 #if PY_VERSION_HEX >= 0x03050000
119 interp_factory_register ("dap", [] (const char *name) -> interp *
121 return new dap_interp (name);
123 #endif