/* Interface between gdb and its extension languages.
- Copyright (C) 2014-2019 Free Software Foundation, Inc.
+ Copyright (C) 2014-2020 Free Software Foundation, Inc.
This file is part of GDB.
have "ext_lang" in the name, and no other symbol in gdb does. */
#include "defs.h"
-
-/* Standard C includes. */
#include <signal.h>
-
-/* Local non-gdb includes. */
+#include "target.h"
#include "auto-load.h"
#include "breakpoint.h"
-#include "cli/cli-script.h"
#include "event-top.h"
-#include "extension-priv.h"
#include "extension.h"
-#include "guile/guile.h"
+#include "extension-priv.h"
#include "observable.h"
+#include "cli/cli-script.h"
#include "python/python.h"
-#include "target.h"
+#include "guile/guile.h"
/* Iterate over all external extension languages, regardless of whether the
support has been compiled in or not.
int i;
const struct extension_language_defn *extlang;
+ if (has_extension (file, extension_language_gdb.suffix))
+ return &extension_language_gdb;
+
ALL_EXTENSION_LANGUAGES (i, extlang)
{
if (has_extension (file, extlang->suffix))
}
}
\f
-/* Try to pretty-print a value of type TYPE located at VAL's contents
- buffer + EMBEDDED_OFFSET, which came from the inferior at address
- ADDRESS + EMBEDDED_OFFSET, onto stdio stream STREAM according to
- OPTIONS.
- VAL is the whole object that came from ADDRESS.
- Returns non-zero if the value was successfully pretty-printed.
+/* Try to pretty-print a value onto stdio stream STREAM according to
+ OPTIONS. VAL is the object to print. Returns non-zero if the
+ value was successfully pretty-printed.
Extension languages are tried in the order specified by
extension_languages. The first one to provide a pretty-printed
errors that trigger an exception in the extension language. */
int
-apply_ext_lang_val_pretty_printer (struct type *type,
- LONGEST embedded_offset, CORE_ADDR address,
+apply_ext_lang_val_pretty_printer (struct value *val,
struct ui_file *stream, int recurse,
- struct value *val,
const struct value_print_options *options,
const struct language_defn *language)
{
if (extlang->ops->apply_val_pretty_printer == NULL)
continue;
- rc = extlang->ops->apply_val_pretty_printer (extlang, type,
- embedded_offset, address,
- stream, recurse, val,
- options, language);
+ rc = extlang->ops->apply_val_pretty_printer (extlang, val, stream,
+ recurse, options, language);
switch (rc)
{
case EXT_LANG_RC_OK:
return result_type;
}
+/* See extension.h. */
+
+gdb::optional<std::string>
+ext_lang_colorize (const std::string &filename, const std::string &contents)
+{
+ int i;
+ const struct extension_language_defn *extlang;
+ gdb::optional<std::string> result;
+
+ ALL_ENABLED_EXTENSION_LANGUAGES (i, extlang)
+ {
+ if (extlang->ops->colorize == nullptr)
+ continue;
+ result = extlang->ops->colorize (filename, contents);
+ if (result.has_value ())
+ return result;
+ }
+
+ return result;
+}
+
/* Called via an observer before gdb prints its prompt.
Iterate over the extension languages giving them a chance to
change the prompt. The first one to change the prompt wins,
}
}
+void _initialize_extension ();
void
-_initialize_extension (void)
+_initialize_extension ()
{
gdb::observers::before_prompt.attach (ext_lang_before_prompt);
}