1 /* Interface between gdb and its extension languages.
3 Copyright (C) 2014-2018 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 /* Note: With few exceptions, external functions and variables in this file
21 have "ext_lang" in the name, and no other symbol in gdb does. */
26 #include "auto-load.h"
27 #include "breakpoint.h"
28 #include "event-top.h"
29 #include "extension.h"
30 #include "extension-priv.h"
31 #include "observable.h"
32 #include "cli/cli-script.h"
33 #include "python/python.h"
34 #include "guile/guile.h"
36 /* Iterate over all external extension languages, regardless of whether the
37 support has been compiled in or not.
38 This does not include GDB's own scripting language. */
40 #define ALL_EXTENSION_LANGUAGES(i, extlang) \
41 for (/*int*/ i = 0, extlang = extension_languages[0]; \
43 extlang = extension_languages[++i])
45 /* Iterate over all external extension languages that are supported.
46 This does not include GDB's own scripting language. */
48 #define ALL_ENABLED_EXTENSION_LANGUAGES(i, extlang) \
49 for (/*int*/ i = 0, extlang = extension_languages[0]; \
51 extlang = extension_languages[++i]) \
52 if (extlang->ops != NULL)
54 static script_sourcer_func source_gdb_script
;
55 static objfile_script_sourcer_func source_gdb_objfile_script
;
57 /* GDB's own scripting language.
58 This exists, in part, to support auto-loading ${prog}-gdb.gdb scripts. */
60 static const struct extension_language_script_ops
61 extension_language_gdb_script_ops
=
64 source_gdb_objfile_script
,
65 NULL
, /* objfile_script_executor */
66 auto_load_gdb_scripts_enabled
69 const struct extension_language_defn extension_language_gdb
=
75 /* We fall back to interpreting a script as a GDB script if it doesn't
76 match the other scripting languages, but for consistency's sake
77 give it a formal suffix. */
81 /* cli_control_type: This is never used: GDB's own scripting language
82 has a variety of control types (if, while, etc.). */
85 &extension_language_gdb_script_ops
,
87 /* The rest of the extension language interface isn't supported by GDB's own
88 extension/scripting language. */
92 /* NULL-terminated table of all external (non-native) extension languages.
94 The order of appearance in the table is important.
95 When multiple extension languages provide the same feature, for example
96 a pretty-printer for a particular type, which one gets used?
97 The algorithm employed here is "the first one wins". For example, in
98 the case of pretty-printers this means the first one to provide a
99 pretty-printed value is the one that is used. This algorithm is employed
102 static const struct extension_language_defn
* const extension_languages
[] =
104 /* To preserve existing behaviour, python should always appear first. */
105 &extension_language_python
,
106 &extension_language_guile
,
110 /* Return a pointer to the struct extension_language_defn object of
111 extension language LANG.
112 This always returns a non-NULL pointer, even if support for the language
113 is not compiled into this copy of GDB. */
115 const struct extension_language_defn
*
116 get_ext_lang_defn (enum extension_language lang
)
119 const struct extension_language_defn
*extlang
;
121 gdb_assert (lang
!= EXT_LANG_NONE
);
123 if (lang
== EXT_LANG_GDB
)
124 return &extension_language_gdb
;
126 ALL_EXTENSION_LANGUAGES (i
, extlang
)
128 if (extlang
->language
== lang
)
132 gdb_assert_not_reached ("unable to find extension_language_defn");
135 /* Return TRUE if FILE has extension EXTENSION. */
138 has_extension (const char *file
, const char *extension
)
140 int file_len
= strlen (file
);
141 int extension_len
= strlen (extension
);
143 return (file_len
> extension_len
144 && strcmp (&file
[file_len
- extension_len
], extension
) == 0);
147 /* Return the extension language of FILE, or NULL if
148 the extension language of FILE is not recognized.
149 This is done by looking at the file's suffix. */
151 const struct extension_language_defn
*
152 get_ext_lang_of_file (const char *file
)
155 const struct extension_language_defn
*extlang
;
157 ALL_EXTENSION_LANGUAGES (i
, extlang
)
159 if (has_extension (file
, extlang
->suffix
))
166 /* Return non-zero if support for the specified extension language
170 ext_lang_present_p (const struct extension_language_defn
*extlang
)
172 return extlang
->script_ops
!= NULL
;
175 /* Return non-zero if the specified extension language has successfully
179 ext_lang_initialized_p (const struct extension_language_defn
*extlang
)
181 if (extlang
->ops
!= NULL
)
183 /* This method is required. */
184 gdb_assert (extlang
->ops
->initialized
!= NULL
);
185 return extlang
->ops
->initialized (extlang
);
191 /* Throw an error indicating EXTLANG is not supported in this copy of GDB. */
194 throw_ext_lang_unsupported (const struct extension_language_defn
*extlang
)
196 error (_("Scripting in the \"%s\" language is not supported"
197 " in this copy of GDB."),
198 ext_lang_capitalized_name (extlang
));
201 /* Methods for GDB's own extension/scripting language. */
203 /* The extension_language_script_ops.script_sourcer "method". */
206 source_gdb_script (const struct extension_language_defn
*extlang
,
207 FILE *stream
, const char *file
)
209 script_from_file (stream
, file
);
212 /* The extension_language_script_ops.objfile_script_sourcer "method". */
215 source_gdb_objfile_script (const struct extension_language_defn
*extlang
,
216 struct objfile
*objfile
,
217 FILE *stream
, const char *file
)
219 script_from_file (stream
, file
);
222 /* Accessors for "public" attributes of struct extension_language. */
224 /* Return the "name" field of EXTLANG. */
227 ext_lang_name (const struct extension_language_defn
*extlang
)
229 return extlang
->name
;
232 /* Return the "capitalized_name" field of EXTLANG. */
235 ext_lang_capitalized_name (const struct extension_language_defn
*extlang
)
237 return extlang
->capitalized_name
;
240 /* Return the "suffix" field of EXTLANG. */
243 ext_lang_suffix (const struct extension_language_defn
*extlang
)
245 return extlang
->suffix
;
248 /* Return the "auto_load_suffix" field of EXTLANG. */
251 ext_lang_auto_load_suffix (const struct extension_language_defn
*extlang
)
253 return extlang
->auto_load_suffix
;
256 /* extension_language_script_ops wrappers. */
258 /* Return the script "sourcer" function for EXTLANG.
259 This is the function that loads and processes a script.
260 If support for this language isn't compiled in, NULL is returned. */
262 script_sourcer_func
*
263 ext_lang_script_sourcer (const struct extension_language_defn
*extlang
)
265 if (extlang
->script_ops
== NULL
)
268 /* The extension language is required to implement this function. */
269 gdb_assert (extlang
->script_ops
->script_sourcer
!= NULL
);
271 return extlang
->script_ops
->script_sourcer
;
274 /* Return the objfile script "sourcer" function for EXTLANG.
275 This is the function that loads and processes a script for a particular
277 If support for this language isn't compiled in, NULL is returned. */
279 objfile_script_sourcer_func
*
280 ext_lang_objfile_script_sourcer (const struct extension_language_defn
*extlang
)
282 if (extlang
->script_ops
== NULL
)
285 /* The extension language is required to implement this function. */
286 gdb_assert (extlang
->script_ops
->objfile_script_sourcer
!= NULL
);
288 return extlang
->script_ops
->objfile_script_sourcer
;
291 /* Return the objfile script "executor" function for EXTLANG.
292 This is the function that executes a script for a particular objfile.
293 If support for this language isn't compiled in, NULL is returned.
294 The extension language is not required to implement this function. */
296 objfile_script_executor_func
*
297 ext_lang_objfile_script_executor
298 (const struct extension_language_defn
*extlang
)
300 if (extlang
->script_ops
== NULL
)
303 return extlang
->script_ops
->objfile_script_executor
;
306 /* Return non-zero if auto-loading of EXTLANG scripts is enabled.
307 Zero is returned if support for this language isn't compiled in. */
310 ext_lang_auto_load_enabled (const struct extension_language_defn
*extlang
)
312 if (extlang
->script_ops
== NULL
)
315 /* The extension language is required to implement this function. */
316 gdb_assert (extlang
->script_ops
->auto_load_enabled
!= NULL
);
318 return extlang
->script_ops
->auto_load_enabled (extlang
);
321 /* Functions that iterate over all extension languages.
322 These only iterate over external extension languages, not including
323 GDB's own extension/scripting language, unless otherwise indicated. */
325 /* Wrapper to call the extension_language_ops.finish_initialization "method"
326 for each compiled-in extension language. */
329 finish_ext_lang_initialization (void)
332 const struct extension_language_defn
*extlang
;
334 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
336 if (extlang
->ops
->finish_initialization
!= NULL
)
337 extlang
->ops
->finish_initialization (extlang
);
341 /* Invoke the appropriate extension_language_ops.eval_from_control_command
342 method to perform CMD, which is a list of commands in an extension language.
344 This function is what implements, for example:
353 eval_ext_lang_from_control_command (struct command_line
*cmd
)
356 const struct extension_language_defn
*extlang
;
358 ALL_EXTENSION_LANGUAGES (i
, extlang
)
360 if (extlang
->cli_control_type
== cmd
->control_type
)
362 if (extlang
->ops
!= NULL
363 && extlang
->ops
->eval_from_control_command
!= NULL
)
365 extlang
->ops
->eval_from_control_command (extlang
, cmd
);
368 /* The requested extension language is not supported in this GDB. */
369 throw_ext_lang_unsupported (extlang
);
373 gdb_assert_not_reached ("unknown extension language in command_line");
376 /* Search for and load scripts for OBJFILE written in extension languages.
377 This includes GDB's own scripting language.
379 This function is what implements the loading of OBJFILE-gdb.py and
383 auto_load_ext_lang_scripts_for_objfile (struct objfile
*objfile
)
386 const struct extension_language_defn
*extlang
;
388 extlang
= &extension_language_gdb
;
389 if (ext_lang_auto_load_enabled (extlang
))
390 auto_load_objfile_script (objfile
, extlang
);
392 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
394 if (ext_lang_auto_load_enabled (extlang
))
395 auto_load_objfile_script (objfile
, extlang
);
399 /* Interface to type pretty-printers implemented in an extension language. */
401 /* Call this at the start when preparing to pretty-print a type.
402 The result is a pointer to an opaque object (to the caller) to be passed
403 to apply_ext_lang_type_printers and free_ext_lang_type_printers.
405 We don't know in advance which extension language will provide a
406 pretty-printer for the type, so all are initialized. */
408 ext_lang_type_printers::ext_lang_type_printers ()
411 const struct extension_language_defn
*extlang
;
413 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
415 if (extlang
->ops
->start_type_printers
!= NULL
)
416 extlang
->ops
->start_type_printers (extlang
, this);
420 /* Iteratively try the type pretty-printers specified by PRINTERS
421 according to the standard search order (specified by extension_languages),
422 returning the result of the first one that succeeds.
423 If there was an error, or if no printer succeeds, then NULL is returned. */
426 apply_ext_lang_type_printers (struct ext_lang_type_printers
*printers
,
430 const struct extension_language_defn
*extlang
;
432 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
437 if (extlang
->ops
->apply_type_printers
== NULL
)
439 rc
= extlang
->ops
->apply_type_printers (extlang
, printers
, type
,
444 gdb_assert (result
!= NULL
);
446 case EXT_LANG_RC_ERROR
:
448 case EXT_LANG_RC_NOP
:
451 gdb_assert_not_reached ("bad return from apply_type_printers");
458 ext_lang_type_printers::~ext_lang_type_printers ()
461 const struct extension_language_defn
*extlang
;
463 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
465 if (extlang
->ops
->free_type_printers
!= NULL
)
466 extlang
->ops
->free_type_printers (extlang
, this);
470 /* Try to pretty-print a value of type TYPE located at VAL's contents
471 buffer + EMBEDDED_OFFSET, which came from the inferior at address
472 ADDRESS + EMBEDDED_OFFSET, onto stdio stream STREAM according to
474 VAL is the whole object that came from ADDRESS.
475 Returns non-zero if the value was successfully pretty-printed.
477 Extension languages are tried in the order specified by
478 extension_languages. The first one to provide a pretty-printed
481 If an error is encountered in a pretty-printer, no further extension
483 Note: This is different than encountering a memory error trying to read a
484 value for pretty-printing. Here we're referring to, e.g., programming
485 errors that trigger an exception in the extension language. */
488 apply_ext_lang_val_pretty_printer (struct type
*type
,
489 LONGEST embedded_offset
, CORE_ADDR address
,
490 struct ui_file
*stream
, int recurse
,
492 const struct value_print_options
*options
,
493 const struct language_defn
*language
)
496 const struct extension_language_defn
*extlang
;
498 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
502 if (extlang
->ops
->apply_val_pretty_printer
== NULL
)
504 rc
= extlang
->ops
->apply_val_pretty_printer (extlang
, type
,
505 embedded_offset
, address
,
506 stream
, recurse
, val
,
512 case EXT_LANG_RC_ERROR
:
514 case EXT_LANG_RC_NOP
:
517 gdb_assert_not_reached ("bad return from apply_val_pretty_printer");
524 /* GDB access to the "frame filter" feature.
525 FRAME is the source frame to start frame-filter invocation. FLAGS is an
526 integer holding the flags for printing. The following elements of
527 the FRAME_FILTER_FLAGS enum denotes the make-up of FLAGS:
528 PRINT_LEVEL is a flag indicating whether to print the frame's
529 relative level in the output. PRINT_FRAME_INFO is a flag that
530 indicates whether this function should print the frame
531 information, PRINT_ARGS is a flag that indicates whether to print
532 frame arguments, and PRINT_LOCALS, likewise, with frame local
533 variables. ARGS_TYPE is an enumerator describing the argument
534 format, OUT is the output stream to print. FRAME_LOW is the
535 beginning of the slice of frames to print, and FRAME_HIGH is the
536 upper limit of the frames to count. Returns EXT_LANG_BT_ERROR on error,
537 or EXT_LANG_BT_COMPLETED on success.
539 Extension languages are tried in the order specified by
540 extension_languages. The first one to provide a filter "wins".
541 If there is an error (EXT_LANG_BT_ERROR) it is reported immediately
542 rather than trying filters in other extension languages. */
544 enum ext_lang_bt_status
545 apply_ext_lang_frame_filter (struct frame_info
*frame
,
546 frame_filter_flags flags
,
547 enum ext_lang_frame_args args_type
,
549 int frame_low
, int frame_high
)
552 const struct extension_language_defn
*extlang
;
554 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
556 enum ext_lang_bt_status status
;
558 if (extlang
->ops
->apply_frame_filter
== NULL
)
560 status
= extlang
->ops
->apply_frame_filter (extlang
, frame
, flags
,
562 frame_low
, frame_high
);
563 /* We use the filters from the first extension language that has
564 applicable filters. Also, an error is reported immediately
565 rather than continue trying. */
566 if (status
!= EXT_LANG_BT_NO_FILTERS
)
570 return EXT_LANG_BT_NO_FILTERS
;
573 /* Update values held by the extension language when OBJFILE is discarded.
574 New global types must be created for every such value, which must then be
575 updated to use the new types.
576 The function typically just iterates over all appropriate values and
577 calls preserve_one_value for each one.
578 COPIED_TYPES is used to prevent cycles / duplicates and is passed to
579 preserve_one_value. */
582 preserve_ext_lang_values (struct objfile
*objfile
, htab_t copied_types
)
585 const struct extension_language_defn
*extlang
;
587 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
589 if (extlang
->ops
->preserve_values
!= NULL
)
590 extlang
->ops
->preserve_values (extlang
, objfile
, copied_types
);
594 /* If there is a stop condition implemented in an extension language for
595 breakpoint B, return a pointer to the extension language's definition.
596 Otherwise return NULL.
597 If SKIP_LANG is not EXT_LANG_NONE, skip checking this language.
598 This is for the case where we're setting a new condition: Only one
599 condition is allowed, so when setting a condition for any particular
600 extension language, we need to check if any other extension language
601 already has a condition set. */
603 const struct extension_language_defn
*
604 get_breakpoint_cond_ext_lang (struct breakpoint
*b
,
605 enum extension_language skip_lang
)
608 const struct extension_language_defn
*extlang
;
610 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
612 if (extlang
->language
!= skip_lang
613 && extlang
->ops
->breakpoint_has_cond
!= NULL
614 && extlang
->ops
->breakpoint_has_cond (extlang
, b
))
621 /* Return whether a stop condition for breakpoint B says to stop.
622 True is also returned if there is no stop condition for B. */
625 breakpoint_ext_lang_cond_says_stop (struct breakpoint
*b
)
628 const struct extension_language_defn
*extlang
;
629 enum ext_lang_bp_stop stop
= EXT_LANG_BP_STOP_UNSET
;
631 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
633 /* There is a rule that a breakpoint can have at most one of any of a
634 CLI or extension language condition. However, Python hacks in "finish
635 breakpoints" on top of the "stop" check, so we have to call this for
636 every language, even if we could first determine whether a "stop"
638 if (extlang
->ops
->breakpoint_cond_says_stop
!= NULL
)
640 enum ext_lang_bp_stop this_stop
641 = extlang
->ops
->breakpoint_cond_says_stop (extlang
, b
);
643 if (this_stop
!= EXT_LANG_BP_STOP_UNSET
)
645 /* Even though we have to check every extension language, only
646 one of them can return yes/no (because only one of them
647 can have a "stop" condition). */
648 gdb_assert (stop
== EXT_LANG_BP_STOP_UNSET
);
654 return stop
== EXT_LANG_BP_STOP_NO
? 0 : 1;
657 /* ^C/SIGINT support.
658 This requires cooperation with the extension languages so the support
661 /* This flag tracks quit requests when we haven't called out to an
662 extension language. it also holds quit requests when we transition to
663 an extension language that doesn't have cooperative SIGINT handling. */
664 static int quit_flag
;
666 /* The current extension language we've called out to, or
667 extension_language_gdb if there isn't one.
668 This must be set everytime we call out to an extension language, and reset
669 to the previous value when it returns. Note that the previous value may
670 be a different (or the same) extension language. */
671 static const struct extension_language_defn
*active_ext_lang
672 = &extension_language_gdb
;
674 /* Return the currently active extension language. */
676 const struct extension_language_defn
*
677 get_active_ext_lang (void)
679 return active_ext_lang
;
682 /* Install a SIGINT handler. */
685 install_sigint_handler (const struct signal_handler
*handler_state
)
687 gdb_assert (handler_state
->handler_saved
);
689 signal (SIGINT
, handler_state
->handler
);
692 /* Install GDB's SIGINT handler, storing the previous version in *PREVIOUS.
693 As a simple optimization, if the previous version was GDB's SIGINT handler
694 then mark the previous handler as not having been saved, and thus it won't
698 install_gdb_sigint_handler (struct signal_handler
*previous
)
700 /* Save here to simplify comparison. */
701 sighandler_t handle_sigint_for_compare
= handle_sigint
;
703 previous
->handler
= signal (SIGINT
, handle_sigint
);
704 if (previous
->handler
!= handle_sigint_for_compare
)
705 previous
->handler_saved
= 1;
707 previous
->handler_saved
= 0;
710 /* Set the currently active extension language to NOW_ACTIVE.
711 The result is a pointer to a malloc'd block of memory to pass to
712 restore_active_ext_lang.
714 N.B. This function must be called every time we call out to an extension
715 language, and the result must be passed to restore_active_ext_lang
718 If there is a pending SIGINT it is "moved" to the now active extension
719 language, if it supports cooperative SIGINT handling (i.e., it provides
720 {clear,set,check}_quit_flag methods). If the extension language does not
721 support cooperative SIGINT handling, then the SIGINT is left queued and
722 we require the non-cooperative extension language to call check_quit_flag
723 at appropriate times.
724 It is important for the extension language to call check_quit_flag if it
725 installs its own SIGINT handler to prevent the situation where a SIGINT
726 is queued on entry, extension language code runs for a "long" time possibly
727 serving one or more SIGINTs, and then returns. Upon return, if
728 check_quit_flag is not called, the original SIGINT will be thrown.
729 Non-cooperative extension languages are free to install their own SIGINT
730 handler but the original must be restored upon return, either itself
731 or via restore_active_ext_lang. */
733 struct active_ext_lang_state
*
734 set_active_ext_lang (const struct extension_language_defn
*now_active
)
736 struct active_ext_lang_state
*previous
737 = XCNEW (struct active_ext_lang_state
);
739 previous
->ext_lang
= active_ext_lang
;
740 previous
->sigint_handler
.handler_saved
= 0;
741 active_ext_lang
= now_active
;
743 if (target_terminal::is_ours ())
745 /* If the newly active extension language uses cooperative SIGINT
746 handling then ensure GDB's SIGINT handler is installed. */
747 if (now_active
->language
== EXT_LANG_GDB
748 || now_active
->ops
->check_quit_flag
!= NULL
)
749 install_gdb_sigint_handler (&previous
->sigint_handler
);
751 /* If there's a SIGINT recorded in the cooperative extension languages,
752 move it to the new language, or save it in GDB's global flag if the
753 newly active extension language doesn't use cooperative SIGINT
755 if (check_quit_flag ())
762 /* Restore active extension language from PREVIOUS. */
765 restore_active_ext_lang (struct active_ext_lang_state
*previous
)
767 active_ext_lang
= previous
->ext_lang
;
769 if (target_terminal::is_ours ())
771 /* Restore the previous SIGINT handler if one was saved. */
772 if (previous
->sigint_handler
.handler_saved
)
773 install_sigint_handler (&previous
->sigint_handler
);
775 /* If there's a SIGINT recorded in the cooperative extension languages,
776 move it to the new language, or save it in GDB's global flag if the
777 newly active extension language doesn't use cooperative SIGINT
779 if (check_quit_flag ())
785 /* Set the quit flag.
786 This only sets the flag in the currently active extension language.
787 If the currently active extension language does not have cooperative
788 SIGINT handling, then GDB's global flag is set, and it is up to the
789 extension language to call check_quit_flag. The extension language
790 is free to install its own SIGINT handler, but we still need to handle
796 if (active_ext_lang
->ops
!= NULL
797 && active_ext_lang
->ops
->set_quit_flag
!= NULL
)
798 active_ext_lang
->ops
->set_quit_flag (active_ext_lang
);
803 /* Now wake up the event loop, or any interruptible_select. Do
804 this after setting the flag, because signals on Windows
805 actually run on a separate thread, and thus otherwise the
806 main code could be woken up and find quit_flag still
808 quit_serial_event_set ();
812 /* Return true if the quit flag has been set, false otherwise.
813 Note: The flag is cleared as a side-effect.
814 The flag is checked in all extension languages that support cooperative
815 SIGINT handling, not just the current one. This simplifies transitions. */
818 check_quit_flag (void)
821 const struct extension_language_defn
*extlang
;
823 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
825 if (extlang
->ops
->check_quit_flag
!= NULL
)
826 if (extlang
->ops
->check_quit_flag (extlang
) != 0)
830 /* This is written in a particular way to avoid races. */
833 /* No longer need to wake up the event loop or any
834 interruptible_select. The caller handles the quit
836 quit_serial_event_clear ();
844 /* See extension.h. */
847 get_matching_xmethod_workers (struct type
*type
, const char *method_name
,
848 std::vector
<xmethod_worker_up
> *workers
)
851 const struct extension_language_defn
*extlang
;
853 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
857 /* If an extension language does not support xmethods, ignore
859 if (extlang
->ops
->get_matching_xmethod_workers
== NULL
)
862 rc
= extlang
->ops
->get_matching_xmethod_workers (extlang
,
865 if (rc
== EXT_LANG_RC_ERROR
)
866 error (_("Error while looking for matching xmethod workers "
867 "defined in %s."), extlang
->capitalized_name
);
871 /* See extension.h. */
874 xmethod_worker::get_arg_types (int *nargs
)
876 type
**type_array
= NULL
;
878 ext_lang_rc rc
= do_get_arg_types (nargs
, &type_array
);
879 if (rc
== EXT_LANG_RC_ERROR
)
880 error (_("Error while looking for arg types of a xmethod worker "
881 "defined in %s."), m_extlang
->capitalized_name
);
886 /* See extension.h. */
889 xmethod_worker::get_result_type (value
*object
, value
**args
, int nargs
)
893 ext_lang_rc rc
= do_get_result_type (object
, args
, nargs
, &result_type
);
894 if (rc
== EXT_LANG_RC_ERROR
)
896 error (_("Error while fetching result type of an xmethod worker "
897 "defined in %s."), m_extlang
->capitalized_name
);
903 /* Called via an observer before gdb prints its prompt.
904 Iterate over the extension languages giving them a chance to
905 change the prompt. The first one to change the prompt wins,
906 and no further languages are tried. */
909 ext_lang_before_prompt (const char *current_gdb_prompt
)
912 const struct extension_language_defn
*extlang
;
914 ALL_ENABLED_EXTENSION_LANGUAGES (i
, extlang
)
918 if (extlang
->ops
->before_prompt
== NULL
)
920 rc
= extlang
->ops
->before_prompt (extlang
, current_gdb_prompt
);
924 case EXT_LANG_RC_ERROR
:
926 case EXT_LANG_RC_NOP
:
929 gdb_assert_not_reached ("bad return from before_prompt");
935 _initialize_extension (void)
937 gdb::observers::before_prompt
.attach (ext_lang_before_prompt
);