GDB (xrefs)
Loading...
Searching...
No Matches
/tmp/gdb-13.1/gdb/language.h
Go to the documentation of this file.
1/* Source-language-related definitions for GDB.
2
3 Copyright (C) 1991-2023 Free Software Foundation, Inc.
4
5 Contributed by the Department of Computer Science at the State University
6 of New York at Buffalo.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22
23#if !defined (LANGUAGE_H)
24#define LANGUAGE_H 1
25
26#include "symtab.h"
27#include "gdbsupport/function-view.h"
28#include "expression.h"
29
30/* Forward decls for prototypes. */
31struct value;
32struct objfile;
33class frame_info_ptr;
34struct ui_file;
37struct lang_varobj_ops;
38struct parser_state;
42
43#define MAX_FORTRAN_DIMS 7 /* Maximum number of F77 array dims. */
44
45/* range_check ==
46 range_check_on: Ranges are checked in GDB expressions, producing errors.
47 range_check_warn: Ranges are checked, producing warnings.
48 range_check_off: Ranges are not checked in GDB expressions. */
49
50extern enum range_check
51 {
53 }
55
56/* array_ordering ==
57 array_row_major: Arrays are in row major order.
58 array_column_major: Arrays are in column major order. */
59
60extern enum array_ordering
61 {
63 }
65
66
67/* case_sensitivity ==
68 case_sensitive_on: Case sensitivity in name matching is used.
69 case_sensitive_off: Case sensitivity in name matching is not used. */
70
72 {
74 }
76
77
78/* macro_expansion ==
79 macro_expansion_no: No macro expansion is available.
80 macro_expansion_c: C-like macro expansion is available. */
81
83 {
85 };
86
87
88/* Per architecture (OS/ABI) language information. */
89
91{
92 /* A default constructor. */
93 language_arch_info () = default;
94
96
97 /* Set the default boolean type to be TYPE. If NAME is not nullptr then
98 before using TYPE a symbol called NAME will be looked up, and the type
99 of this symbol will be used instead. Should only be called once when
100 performing setup for a particular language in combination with a
101 particular gdbarch. */
102 void set_bool_type (struct type *type, const char *name = nullptr)
103 {
104 gdb_assert (m_bool_type_default == nullptr);
105 gdb_assert (m_bool_type_name == nullptr);
106 gdb_assert (type != nullptr);
109 }
110
111 /* Set the type to be used for characters within a string. Should only
112 be called once when performing setup for a particular language in
113 combination with a particular gdbarch. */
115 {
116 gdb_assert (m_string_char_type == nullptr);
117 gdb_assert (type != nullptr);
119 }
120
121 /* Return the type for characters within a string. */
122 struct type *string_char_type () const
123 { return m_string_char_type; }
124
125 /* Return the type to be used for booleans. */
126 struct type *bool_type () const;
127
128 /* Add TYPE to the list of primitive types for this particular language,
129 with this OS/ABI combination. */
131 {
132 gdb_assert (type != nullptr);
134 }
135
136 /* Lookup a primitive type called NAME. Will return nullptr if no
137 matching type is found. */
138 struct type *lookup_primitive_type (const char *name);
139
140 /* Lookup a primitive type for which FILTER returns true. Will return
141 nullptr if no matching type is found. */
143 (gdb::function_view<bool (struct type *)> filter);
144
145 /* Lookup a primitive type called NAME and return the type as a symbol.
146 LANG is the language for which type is being looked up. */
147 struct symbol *lookup_primitive_type_as_symbol (const char *name,
148 enum language lang);
149private:
150
151 /* A structure storing a type and a corresponding symbol. The type is
152 defined at construction time, while the symbol is lazily created only
153 when asked for, but is then cached for future use. */
155 {
156 /* Constructor. */
157 explicit type_and_symbol (struct type *type)
158 : m_type (type)
159 { /* Nothing. */ }
160
161 /* Default move constructor. */
163
165
166 /* Return the type from this object. */
167 struct type *type () const
168 { return m_type; }
169
170 /* Create and return a symbol wrapping M_TYPE from this object. */
171 struct symbol *symbol (enum language lang)
172 {
173 if (m_symbol == nullptr)
175 return m_symbol;
176 }
177
178 private:
179 /* The type primitive type. */
180 struct type *m_type = nullptr;
181
182 /* A symbol wrapping M_TYPE, only created when first asked for. */
183 struct symbol *m_symbol = nullptr;
184
185 /* Helper function for type lookup as a symbol. Create the symbol
186 corresponding to type TYPE in language LANG. */
187 static struct symbol *alloc_type_symbol (enum language lang,
188 struct type *type);
189 };
190
191 /* Lookup a type_and_symbol entry from the primitive_types_and_symbols
192 vector for a type matching NAME. Return a pointer to the
193 type_and_symbol object from the vector. This will return nullptr if
194 there is no type matching NAME found. */
196
197 /* Vector of the primitive types added through add_primitive_type. These
198 types can be specified by name in parsing types in expressions,
199 regardless of whether the program being debugged actually defines such
200 a type.
201
202 Within the vector each type is paired with a lazily created symbol,
203 which can be fetched by the symbol lookup machinery, should they be
204 needed. */
205 std::vector<type_and_symbol> primitive_types_and_symbols;
206
207 /* Type of elements of strings. */
208 struct type *m_string_char_type = nullptr;
209
210 /* Symbol name of type to use as boolean type, if defined. */
211 const char *m_bool_type_name = nullptr;
212
213 /* Otherwise, this is the default boolean builtin type. */
214 struct type *m_bool_type_default = nullptr;
215};
216
217/* In a language (particularly C++) a function argument of an aggregate
218 type (i.e. class/struct/union) may be implicitly passed by reference
219 even though it is declared a call-by-value argument in the source.
220 The struct below puts together necessary information for GDB to be
221 able to detect and carry out pass-by-reference semantics for a
222 particular type. This type is referred as T in the inlined comments
223 below.
224
225 The default values of the fields are chosen to give correct semantics
226 for primitive types and for simple aggregate types, such as
227
228 class T {
229 int x;
230 }; */
231
233{
234 /* True if an argument of type T can be passed to a function by value
235 (i.e. not through an implicit reference). False, otherwise. */
237
238 /* True if a copy of a value of type T can be initialized by
239 memcpy'ing the value bit-by-bit. False, otherwise.
240 E.g. If T has a user-defined copy ctor, this should be false. */
242
243 /* True if a value of type T can be destructed simply by reclaiming
244 the memory area occupied by the value. False, otherwise.
245 E.g. If T has a user-defined destructor, this should be false. */
247
248 /* True if it is allowed to create a copy of a value of type T.
249 False, otherwise.
250 E.g. If T has a deleted copy ctor, this should be false. */
252
253 /* True if a value of type T can be destructed. False, otherwise.
254 E.g. If T has a deleted destructor, this should be false. */
255 bool destructible = true;
256};
257
258/* Splitting strings into words. */
259extern const char *default_word_break_characters (void);
260
261/* Base class from which all other language classes derive. */
262
264{
266 : la_language (lang)
267 {
268 /* We should only ever create one instance of each language. */
269 gdb_assert (languages[lang] == nullptr);
270 languages[lang] = this;
271 }
272
273 /* Which language this is. */
274
276
277 /* Name of the language. */
278
279 virtual const char *name () const = 0;
280
281 /* Natural or official name of the language. */
282
283 virtual const char *natural_name () const = 0;
284
285 /* Digit separator of the language. */
286
287 virtual const char *get_digit_separator () const
288 {
289 return " ";
290 }
291
292 /* Return a vector of file extensions for this language. The extension
293 must include the ".", like ".c". If this language doesn't need to
294 provide any filename extensions, this may be an empty vector (which is
295 the default). */
296
297 virtual const std::vector<const char *> &filename_extensions () const
298 {
299 static const std::vector<const char *> no_extensions;
300 return no_extensions;
301 }
302
303 /* Print the index of an element of an array. This default
304 implementation prints using C99 syntax. */
305
306 virtual void print_array_index (struct type *index_type,
307 LONGEST index_value,
308 struct ui_file *stream,
309 const value_print_options *options) const;
310
311 /* Given a symbol VAR, the corresponding block VAR_BLOCK (if any) and a
312 stack frame id FRAME, read the value of the variable and return (pointer
313 to a) struct value containing the value.
314
315 VAR_BLOCK is needed if there's a possibility for VAR to be outside
316 FRAME. This is what happens if FRAME correspond to a nested function
317 and VAR is defined in the outer function. If callers know that VAR is
318 located in FRAME or is global/static, NULL can be passed as VAR_BLOCK.
319
320 Throw an error if the variable cannot be found. */
321
322 virtual struct value *read_var_value (struct symbol *var,
323 const struct block *var_block,
324 frame_info_ptr frame) const;
325
326 /* Return information about whether TYPE should be passed
327 (and returned) by reference at the language level. The default
328 implementation returns a LANGUAGE_PASS_BY_REF_INFO initialised in its
329 default state. */
330
332 (struct type *type) const
333 {
334 return {};
335 }
336
337 /* Return true if SYMBOL represents an entity that is not
338 supposed to be seen by the user. To be used to filter symbols
339 during printing. */
340 virtual bool symbol_printing_suppressed (struct symbol *symbol) const
341 {
342 return false;
343 }
344
345 /* The per-architecture (OS/ABI) language information. */
346
347 virtual void language_arch_info (struct gdbarch *,
348 struct language_arch_info *) const = 0;
349
350 /* Find the definition of the type with the given name. */
351
352 virtual struct type *lookup_transparent_type (const char *name) const
353 {
355 }
356
357 /* Find all symbols in the current program space matching NAME in
358 DOMAIN, according to this language's rules.
359
360 The search is done in BLOCK only.
361 The caller is responsible for iterating up through superblocks
362 if desired.
363
364 For each one, call CALLBACK with the symbol. If CALLBACK
365 returns false, the iteration ends at that point.
366
367 This field may not be NULL. If the language does not need any
368 special processing here, 'iterate_over_symbols' should be
369 used as the definition. */
371 (const struct block *block, const lookup_name_info &name,
372 domain_enum domain,
373 gdb::function_view<symbol_found_callback_ftype> callback) const
374 {
375 return ::iterate_over_symbols (block, name, domain, callback);
376 }
377
378 /* Return a pointer to the function that should be used to match a
379 symbol name against LOOKUP_NAME, according to this language's
380 rules. The matching algorithm depends on LOOKUP_NAME. For
381 example, on Ada, the matching algorithm depends on the symbol
382 name (wild/full/verbatim matching), and on whether we're doing
383 a normal lookup or a completion match lookup.
384
385 As Ada wants to capture symbol matching for all languages in some
386 cases, then this method is a non-overridable interface. Languages
387 should override GET_SYMBOL_NAME_MATCHER_INNER if they need to. */
388
390 (const lookup_name_info &lookup_name) const;
391
392 /* If this language allows compilation from the gdb command line,
393 then this method will return an instance of struct gcc_context
394 appropriate to the language. If compilation for this language is
395 generally supported, but something goes wrong then an exception
396 is thrown. If compilation is not supported for this language
397 then this method returns NULL. */
398
399 virtual std::unique_ptr<compile_instance> get_compile_instance () const;
400
401 /* This method must be overridden if 'get_compile_instance' is
402 overridden.
403
404 This takes the user-supplied text and returns a new bit of code
405 to compile.
406
407 INST is the compiler instance being used.
408 INPUT is the user's input text.
409 GDBARCH is the architecture to use.
410 EXPR_BLOCK is the block in which the expression is being
411 parsed.
412 EXPR_PC is the PC at which the expression is being parsed. */
413
414 virtual std::string compute_program (compile_instance *inst,
415 const char *input,
416 struct gdbarch *gdbarch,
417 const struct block *expr_block,
418 CORE_ADDR expr_pc) const
419 {
420 gdb_assert_not_reached ("language_defn::compute_program");
421 }
422
423 /* Hash the given symbol search name. */
424 virtual unsigned int search_name_hash (const char *name) const;
425
426 /* Demangle a symbol according to this language's rules. Unlike
427 la_demangle, this does not take any options.
428
429 *DEMANGLED will be set by this function.
430
431 If this function returns false, then *DEMANGLED must always be set
432 to NULL.
433
434 If this function returns true, the implementation may set this to
435 a xmalloc'd string holding the demangled form. However, it is
436 not required to. The string, if any, is owned by the caller.
437
438 The resulting string should be of the form that will be
439 installed into a symbol. */
441 (const char *mangled, gdb::unique_xmalloc_ptr<char> *demangled) const
442 {
443 *demangled = nullptr;
444 return false;
445 }
446
447 /* Return demangled language symbol version of MANGLED, or NULL. */
448 virtual gdb::unique_xmalloc_ptr<char> demangle_symbol (const char *mangled,
449 int options) const
450 {
451 return nullptr;
452 }
453
454 /* Return true if this class' implementation of print_type can
455 handle the /o modifier. */
456 virtual bool can_print_type_offsets () const
457 {
458 return false;
459 }
460
461 /* Print TYPE to STREAM using syntax appropriate for this language.
462 LEVEL is the depth to indent lines by. VARSTRING, if not NULL or the
463 empty string, is the name of a variable and TYPE should be printed in
464 the form of a declaration of a variable named VARSTRING. */
465
466 virtual void print_type (struct type *type, const char *varstring,
467 struct ui_file *stream, int show, int level,
468 const struct type_print_options *flags) const = 0;
469
470 /* PC is possibly an unknown languages trampoline.
471 If that PC falls in a trampoline belonging to this language, return
472 the address of the first pc in the real function, or 0 if it isn't a
473 language tramp for this language. */
474 virtual CORE_ADDR skip_trampoline (frame_info_ptr fi, CORE_ADDR pc) const
475 {
476 return (CORE_ADDR) 0;
477 }
478
479 /* Return class name of a mangled method name or NULL. */
480 virtual char *class_name_from_physname (const char *physname) const
481 {
482 return nullptr;
483 }
484
485 /* The list of characters forming word boundaries. */
486 virtual const char *word_break_characters (void) const
487 {
489 }
490
491 /* Add to the completion tracker all symbols which are possible
492 completions for TEXT. WORD is the entire command on which the
493 completion is being made. If CODE is TYPE_CODE_UNDEF, then all
494 symbols should be examined; otherwise, only STRUCT_DOMAIN symbols
495 whose type has a code of CODE should be matched. */
496
498 (completion_tracker &tracker,
500 symbol_name_match_type name_match_type,
501 const char *text,
502 const char *word,
503 enum type_code code) const
504 {
506 (tracker, mode, name_match_type, text, word, "", code);
507 }
508
509 /* This is a function that lookup_symbol will call when it gets to
510 the part of symbol lookup where C looks up static and global
511 variables. This default implements the basic C lookup rules. */
512
514 (const char *name,
515 const struct block *block,
516 const domain_enum domain) const;
517
518 /* Return an expression that can be used for a location
519 watchpoint. TYPE is a pointer type that points to the memory
520 to watch, and ADDR is the address of the watched memory. */
521 virtual gdb::unique_xmalloc_ptr<char> watch_location_expression
522 (struct type *type, CORE_ADDR addr) const;
523
524 /* List of all known languages. */
525 static const struct language_defn *languages[nr_languages];
526
527 /* Print a top-level value using syntax appropriate for this language. */
528 virtual void value_print (struct value *val, struct ui_file *stream,
529 const struct value_print_options *options) const;
530
531 /* Print a value using syntax appropriate for this language. RECURSE is
532 the recursion depth. It is zero-based. */
533 virtual void value_print_inner
534 (struct value *val, struct ui_file *stream, int recurse,
535 const struct value_print_options *options) const;
536
537 /* Parser function. */
538
539 virtual int parser (struct parser_state *ps) const;
540
541 /* Print the character CH (of type CHTYPE) on STREAM as part of the
542 contents of a literal string whose delimiter is QUOTER. */
543
544 virtual void emitchar (int ch, struct type *chtype,
545 struct ui_file *stream, int quoter) const;
546
547 virtual void printchar (int ch, struct type *chtype,
548 struct ui_file * stream) const;
549
550/* Print the character string STRING, printing at most LENGTH characters.
551 Printing stops early if the number hits print_max; repeat counts
552 are printed as appropriate. Print ellipses at the end if we
553 had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
554
555 virtual void printstr (struct ui_file *stream, struct type *elttype,
556 const gdb_byte *string, unsigned int length,
557 const char *encoding, int force_ellipses,
558 const struct value_print_options *options) const;
559
560
561 /* Print a typedef using syntax appropriate for this language.
562 TYPE is the underlying type. NEW_SYMBOL is the symbol naming
563 the type. STREAM is the output stream on which to print. */
564
565 virtual void print_typedef (struct type *type, struct symbol *new_symbol,
566 struct ui_file *stream) const;
567
568 /* Return true if TYPE is a string type. */
569 virtual bool is_string_type_p (struct type *type) const;
570
571 /* Return a string that is used by the 'set print max-depth' setting.
572 When GDB replaces a struct or union (during value printing) that is
573 "too deep" this string is displayed instead. The default value here
574 suits most languages. If overriding then the string here should
575 ideally be similar in style to the default; an opener, three '.', and
576 a closer. */
577
578 virtual const char *struct_too_deep_ellipsis () const
579 { return "{...}"; }
580
581 /* If this returns non-NULL then the string returned specifies the name
582 of the implicit local variable that refers to the current object
583 instance. Return NULL (the default) for languages that have no name
584 for the current object instance. */
585
586 virtual const char *name_of_this () const
587 { return nullptr; }
588
589 /* Return false if the language has first-class arrays. Return true if
590 there are no array values, and array objects decay to pointers, as in
591 C. The default is true as currently most supported languages behave
592 in this manner. */
593
594 virtual bool c_style_arrays_p () const
595 { return true; }
596
597 /* Return the index to use for extracting the first element of a string,
598 or as the lower bound when creating a new string. The default of
599 choosing 0 or 1 based on C_STYLE_ARRAYS_P works for all currently
600 supported languages except Modula-2. */
601
602 virtual char string_lower_bound () const
603 { return c_style_arrays_p () ? 0 : 1; }
604
605 /* Returns true if the symbols names should be stored in GDB's data
606 structures for minimal/partial/full symbols using their linkage (aka
607 mangled) form; false if the symbol names should be demangled first.
608
609 Most languages implement symbol lookup by comparing the demangled
610 names, in which case it is advantageous to store that information
611 already demangled, and so would return false, which is the default.
612
613 On the other hand, some languages have opted for doing symbol lookups
614 by comparing mangled names instead, for reasons usually specific to
615 the language. Those languages should override this function and
616 return true.
617
618 And finally, other languages such as C or Asm do not have the concept
619 of mangled vs demangled name, so those languages should also override
620 this function and return true, to prevent any accidental demangling
621 through an unrelated language's demangler. */
622
624 { return false; }
625
626 /* Default range checking preference. The return value from this
627 function provides the automatic setting for 'set check range'. As a
628 consequence a user is free to override this setting if they want. */
629
630 virtual bool range_checking_on_by_default () const
631 { return false; }
632
633 /* Is this language case sensitive? The return value from this function
634 provides the automativ setting for 'set case-sensitive', as a
635 consequence, a user is free to override this setting if they want. */
636
637 virtual enum case_sensitivity case_sensitivity () const
638 { return case_sensitive_on; }
639
640
641 /* Multi-dimensional array ordering. */
642
643 virtual enum array_ordering array_ordering () const
644 { return array_row_major; }
645
646 /* Style of macro expansion, if any, supported by this language. The
647 default is no macro expansion. */
648
649 virtual enum macro_expansion macro_expansion () const
650 { return macro_expansion_no; }
651
652 /* Return a structure containing various operations on varobj specific
653 for this language. */
654
655 virtual const struct lang_varobj_ops *varobj_ops () const;
656
657protected:
658
659 /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
660 See that method for a description of the arguments. */
661
663 (const lookup_name_info &lookup_name) const;
664};
665
666/* Pointer to the language_defn for our current language. This pointer
667 always points to *some* valid struct; it can be used without checking
668 it for validity.
669
670 The current language affects expression parsing and evaluation
671 (FIXME: it might be cleaner to make the evaluation-related stuff
672 separate exp_opcodes for each different set of semantics. We
673 should at least think this through more clearly with respect to
674 what happens if the language is changed between parsing and
675 evaluation) and printing of things like types and arrays. It does
676 *not* affect symbol-reading-- each source file in a symbol-file has
677 its own language and we should keep track of that regardless of the
678 language when symbols are read. If we want some manual setting for
679 the language of symbol files (e.g. detecting when ".c" files are
680 C++), it should be a separate setting from the current_language. */
681
682extern const struct language_defn *current_language;
683
684/* Pointer to the language_defn expected by the user, e.g. the language
685 of main(), or the language we last mentioned in a message, or C. */
686
687extern const struct language_defn *expected_language;
688
689/* Warning issued when current_language and the language of the current
690 frame do not match. */
691
692extern const char lang_frame_mismatch_warn[];
693
694/* language_mode ==
695 language_mode_auto: current_language automatically set upon selection
696 of scope (e.g. stack frame)
697 language_mode_manual: current_language set only by user. */
698
699extern enum language_mode
700 {
704
705/* Return the type that should be used for booleans for language L in
706 GDBARCH. */
707
708struct type *language_bool_type (const struct language_defn *l,
709 struct gdbarch *gdbarch);
710
711/* Return the type that should be used for characters within a string for
712 language L in GDBARCH. */
713
714struct type *language_string_char_type (const struct language_defn *l,
715 struct gdbarch *gdbarch);
716
717/* Look up a type from the set of OS/ABI specific types defined in
718 GDBARCH for language L. NAME is used for selecting the matching
719 type, and is passed through to the corresponding
720 lookup_primitive_type member function inside the language_arch_info
721 class. */
722
723struct type *language_lookup_primitive_type (const struct language_defn *l,
724 struct gdbarch *gdbarch,
725 const char *name);
726
727/* Look up a type from the set of OS/ABI specific types defined in
728 GDBARCH for language L. FILTER is used for selecting the matching
729 type, and is passed through to the corresponding
730 lookup_primitive_type member function inside the language_arch_info
731 class. */
732
734 (const struct language_defn *la,
735 struct gdbarch *gdbarch,
736 gdb::function_view<bool (struct type *)> filter);
737
738/* Wrapper around language_lookup_primitive_type to return the
739 corresponding symbol. */
740
741struct symbol *
743 struct gdbarch *gdbarch,
744 const char *name);
745
746
747/* These macros define the behaviour of the expression
748 evaluator. */
749
750/* Should we range check values against the domain of their type? */
751#define RANGE_CHECK (range_check != range_check_off)
752
753/* "cast" really means conversion. */
754/* FIXME -- should be a setting in language_defn. */
755#define CAST_IS_CONVERSION(LANG) ((LANG)->la_language == language_c || \
756 (LANG)->la_language == language_cplus || \
757 (LANG)->la_language == language_objc)
758
759/* Print out the current language settings: language, range and
760 type checking. */
761
762extern void language_info ();
763
764extern enum language set_language (enum language);
765
766
767/* Test a character to decide whether it can be printed in literal form
768 or needs to be printed in another representation. For example,
769 in C the literal form of the character with octal value 141 is 'a'
770 and the "other representation" is '\141'. The "other representation"
771 is program language dependent. */
772
773#define PRINT_LITERAL_FORM(c) \
774 ((c) >= 0x20 \
775 && ((c) < 0x7F || (c) >= 0xA0) \
776 && (!sevenbit_strings || (c) < 0x80))
777
778/* Error messages */
779
780extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
781
782/* Misc: The string representing a particular enum language. */
783
784extern enum language language_enum (const char *str);
785
786extern const struct language_defn *language_def (enum language);
787
788extern const char *language_str (enum language);
789
790/* Check for a language-specific trampoline. */
791
792extern CORE_ADDR skip_language_trampoline (frame_info_ptr, CORE_ADDR pc);
793
794/* Return demangled language symbol, or NULL. */
795extern gdb::unique_xmalloc_ptr<char> language_demangle
796 (const struct language_defn *current_language,
797 const char *mangled, int options);
798
799/* Return information about whether TYPE should be passed
800 (and returned) by reference at the language level. */
802
803void c_get_string (struct value *value,
804 gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
805 int *length, struct type **char_type,
806 const char **charset);
807
808/* Get LANG's symbol_name_matcher method for LOOKUP_NAME. Returns
809 default_symbol_name_matcher if not set. LANG is used as a hint;
810 the function may ignore it depending on the current language and
811 LOOKUP_NAME. Specifically, if the current language is Ada, this
812 may return an Ada matcher regardless of LANG. */
814 (const language_defn *lang, const lookup_name_info &lookup_name);
815
816/* Save the current language and restore it upon destruction. */
817
819{
820public:
821
823 : m_lang (current_language->la_language)
824 {
825 }
826
828 {
829 set_language (m_lang);
830 }
831
833 = delete;
835 (const scoped_restore_current_language &) = delete;
836
837private:
838
840};
841
842/* If language_mode is language_mode_auto,
843 then switch current language to the language of SYM
844 and restore current language upon destruction.
845
846 Else do nothing. */
847
849{
850public:
851
853 {
855 {
857 m_switched = true;
858 set_language (sym->language ());
859 }
860 else
861 {
862 m_switched = false;
863 /* Assign to m_lang to silence a GCC warning. See
864 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635. */
866 }
867 }
868
870 {
871 if (m_switched)
873 }
874
876
877private:
880};
881
882#endif /* defined (LANGUAGE_H) */
const char *const name
Definition: aarch64-tdep.c:67
int code
Definition: ada-lex.l:688
scoped_restore_current_language(const scoped_restore_current_language &)=delete
scoped_switch_to_sym_language_if_auto(const struct symbol *sym)
Definition: language.h:852
DISABLE_COPY_AND_ASSIGN(scoped_switch_to_sym_language_if_auto)
static struct symbol * new_symbol(struct ctf_context *cp, struct type *type, ctf_id_t tid)
Definition: ctfread.c:468
language
Definition: defs.h:211
@ language_unknown
Definition: defs.h:212
@ nr_languages
Definition: defs.h:227
static void ATTRIBUTE_PRINTF(1, 0)
Definition: gdb_bfd.c:1150
type_code
Definition: gdbtypes.h:99
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
Definition: gnu-nat.c:1862
array_ordering
Definition: language.h:61
@ array_row_major
Definition: language.h:62
@ array_column_major
Definition: language.h:62
const char lang_frame_mismatch_warn[]
Definition: language.c:102
void c_get_string(struct value *value, gdb::unique_xmalloc_ptr< gdb_byte > *buffer, int *length, struct type **char_type, const char **charset)
Definition: c-lang.c:243
macro_expansion
Definition: language.h:83
@ macro_expansion_no
Definition: language.h:84
@ macro_expansion_c
Definition: language.h:84
const struct language_defn * current_language
Definition: language.c:83
CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR pc)
Definition: language.c:531
gdb::unique_xmalloc_ptr< char > language_demangle(const struct language_defn *current_language, const char *mangled, int options)
Definition: language.c:551
range_check
Definition: language.h:51
@ range_check_warn
Definition: language.h:52
@ range_check_on
Definition: language.h:52
@ range_check_off
Definition: language.h:52
void enum language language_enum(const char *str)
Definition: language.c:427
const char * language_str(enum language)
Definition: language.c:452
struct language_pass_by_ref_info language_pass_by_reference(struct type *type)
Definition: language.c:563
enum language set_language(enum language)
Definition: language.c:361
void language_info()
Definition: language.c:375
struct type * language_lookup_primitive_type(const struct language_defn *l, struct gdbarch *gdbarch, const char *name)
Definition: language.c:1053
const struct language_defn * expected_language
Definition: language.c:89
case_sensitivity
Definition: language.h:72
@ case_sensitive_on
Definition: language.h:73
@ case_sensitive_off
Definition: language.h:73
symbol_name_matcher_ftype * get_symbol_name_matcher(const language_defn *lang, const lookup_name_info &lookup_name)
language_mode
Definition: language.h:700
@ language_mode_auto
Definition: language.h:701
@ language_mode_manual
Definition: language.h:701
struct type * language_bool_type(const struct language_defn *l, struct gdbarch *gdbarch)
Definition: language.c:935
struct type * language_string_char_type(const struct language_defn *l, struct gdbarch *gdbarch)
Definition: language.c:925
const struct language_defn * language_def(enum language)
Definition: language.c:442
const char * default_word_break_characters(void)
Definition: language.c:573
struct symbol * language_lookup_primitive_type_as_symbol(const struct language_defn *l, struct gdbarch *gdbarch, const char *name)
Definition: language.c:1073
void range_error(const char *,...) ATTRIBUTE_PRINTF(1
Definition: auto-load.h:28
Definition: block.h:109
enum language language() const
Definition: symtab.h:501
DISABLE_COPY_AND_ASSIGN(type_and_symbol)
type_and_symbol(type_and_symbol &&)=default
struct type * type() const
Definition: language.h:167
static struct symbol * alloc_type_symbol(enum language lang, struct type *type)
Definition: language.c:967
type_and_symbol(struct type *type)
Definition: language.h:157
struct symbol * symbol(enum language lang)
Definition: language.h:171
struct type * m_bool_type_default
Definition: language.h:214
struct type * bool_type() const
Definition: language.c:945
void set_string_char_type(struct type *type)
Definition: language.h:114
void add_primitive_type(struct type *type)
Definition: language.h:130
struct symbol * lookup_primitive_type_as_symbol(const char *name, enum language lang)
Definition: language.c:1028
std::vector< type_and_symbol > primitive_types_and_symbols
Definition: language.h:205
language_arch_info()=default
const char * m_bool_type_name
Definition: language.h:211
void set_bool_type(struct type *type, const char *name=nullptr)
Definition: language.h:102
struct type * m_string_char_type
Definition: language.h:208
type_and_symbol * lookup_primitive_type_and_symbol(const char *name)
Definition: language.c:988
struct type * lookup_primitive_type(const char *name)
Definition: language.c:1002
DISABLE_COPY_AND_ASSIGN(language_arch_info)
struct type * string_char_type() const
Definition: language.h:122
virtual bool is_string_type_p(struct type *type) const
Definition: language.c:643
virtual symbol_name_matcher_ftype * get_symbol_name_matcher_inner(const lookup_name_info &lookup_name) const
Definition: language.c:702
virtual const struct lang_varobj_ops * varobj_ops() const
Definition: language.c:710
virtual struct language_pass_by_ref_info pass_by_reference_info(struct type *type) const
Definition: language.h:332
virtual std::string compute_program(compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, CORE_ADDR expr_pc) const
Definition: language.h:414
virtual void emitchar(int ch, struct type *chtype, struct ui_file *stream, int quoter) const
Definition: c-lang.c:147
enum language la_language
Definition: language.h:275
virtual const char * name_of_this() const
Definition: language.h:586
virtual gdb::unique_xmalloc_ptr< char > watch_location_expression(struct type *type, CORE_ADDR addr) const
Definition: language.c:595
language_defn(enum language lang)
Definition: language.h:265
virtual const char * natural_name() const =0
virtual bool can_print_type_offsets() const
Definition: language.h:456
virtual void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const =0
virtual bool sniff_from_mangled_name(const char *mangled, gdb::unique_xmalloc_ptr< char > *demangled) const
Definition: language.h:441
virtual const char * name() const =0
virtual void print_array_index(struct type *index_type, LONGEST index_value, struct ui_file *stream, const value_print_options *options) const
Definition: language.c:581
symbol_name_matcher_ftype * get_symbol_name_matcher(const lookup_name_info &lookup_name) const
Definition: language.c:686
virtual bool symbol_printing_suppressed(struct symbol *symbol) const
Definition: language.h:340
virtual const char * struct_too_deep_ellipsis() const
Definition: language.h:578
virtual CORE_ADDR skip_trampoline(frame_info_ptr fi, CORE_ADDR pc) const
Definition: language.h:474
virtual char * class_name_from_physname(const char *physname) const
Definition: language.h:480
virtual void value_print(struct value *val, struct ui_file *stream, const struct value_print_options *options) const
Definition: language.c:607
virtual bool store_sym_names_in_linkage_form_p() const
Definition: language.h:623
static const struct language_defn * languages[nr_languages]
Definition: language.h:525
virtual bool range_checking_on_by_default() const
Definition: language.h:630
virtual bool iterate_over_symbols(const struct block *block, const lookup_name_info &name, domain_enum domain, gdb::function_view< symbol_found_callback_ftype > callback) const
Definition: language.h:371
virtual struct block_symbol lookup_symbol_nonlocal(const char *name, const struct block *block, const domain_enum domain) const
Definition: symtab.c:2442
virtual int parser(struct parser_state *ps) const
Definition: language.c:616
virtual void printstr(struct ui_file *stream, struct type *elttype, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, const struct value_print_options *options) const
Definition: c-lang.c:193
virtual struct type * lookup_transparent_type(const char *name) const
Definition: language.h:352
virtual void printchar(int ch, struct type *chtype, struct ui_file *stream) const
Definition: c-lang.c:159
virtual void collect_symbol_completion_matches(completion_tracker &tracker, complete_symbol_mode mode, symbol_name_match_type name_match_type, const char *text, const char *word, enum type_code code) const
Definition: language.h:498
virtual void language_arch_info(struct gdbarch *, struct language_arch_info *) const =0
virtual struct value * read_var_value(struct symbol *var, const struct block *var_block, frame_info_ptr frame) const
Definition: findvar.c:552
virtual enum array_ordering array_ordering() const
Definition: language.h:643
virtual enum case_sensitivity case_sensitivity() const
Definition: language.h:637
virtual const char * get_digit_separator() const
Definition: language.h:287
virtual gdb::unique_xmalloc_ptr< char > demangle_symbol(const char *mangled, int options) const
Definition: language.h:448
virtual unsigned int search_name_hash(const char *name) const
Definition: dictionary.c:721
virtual const char * word_break_characters(void) const
Definition: language.h:486
virtual void print_typedef(struct type *type, struct symbol *new_symbol, struct ui_file *stream) const
Definition: language.c:634
virtual char string_lower_bound() const
Definition: language.h:602
virtual void value_print_inner(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) const
Definition: language.c:625
virtual std::unique_ptr< compile_instance > get_compile_instance() const
Definition: language.c:651
virtual bool c_style_arrays_p() const
Definition: language.h:594
virtual const std::vector< const char * > & filename_extensions() const
Definition: language.h:297
virtual enum macro_expansion macro_expansion() const
Definition: language.h:649
Definition: gdbtypes.h:922
Definition: value.c:181
struct type * basic_lookup_transparent_type(const char *name)
Definition: symtab.c:2739
void default_collect_symbol_completion_matches_break_on(completion_tracker &tracker, complete_symbol_mode mode, symbol_name_match_type name_match_type, const char *text, const char *word, const char *break_on, enum type_code code)
Definition: symtab.c:5732
symbol_name_match_type
Definition: symtab.h:62
bool() symbol_name_matcher_ftype(const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res)
Definition: symtab.h:398
domain_enum
Definition: symtab.h:871
complete_symbol_mode
Definition: symtab.h:2320