Age | Commit message (Collapse) | Author | Files | Lines |
|
This adds new is_array_like and to_array methods to language_defn.
This will be used in a subsequent patch that generalizes the new
Python array- and string-handling code.
|
|
History Of This Patch
=====================
This commit aims to address PR gdb/21699. There have now been a
couple of attempts to fix this issue. Simon originally posted two
patches back in 2021:
https://sourceware.org/pipermail/gdb-patches/2021-July/180894.html
https://sourceware.org/pipermail/gdb-patches/2021-July/180896.html
Before Pedro then posted a version of his own:
https://sourceware.org/pipermail/gdb-patches/2021-July/180970.html
After this the conversation halted. Then in 2023 I (Andrew) also took
a look at this bug and posted two versions:
https://sourceware.org/pipermail/gdb-patches/2023-April/198570.html
https://sourceware.org/pipermail/gdb-patches/2023-April/198680.html
The approach taken in my first patch was pretty similar to what Simon
originally posted back in 2021. My second attempt was only a slight
variation on the first.
Pedro then pointed out his older patch, and so we arrive at this
patch. The GDB changes here are mostly Pedro's work, but updated by
me (Andrew), any mistakes are mine.
The tests here are a combinations of everyone's work, and the commit
message is new, but copies bits from everyone's earlier work.
Problem Description
===================
Bug PR gdb/21699 makes the observation that using $_as_string with
GDB's printf can cause GDB to print unexpected data from the
inferior. The reproducer is pretty simple:
#include <stddef.h>
static char arena[100];
/* Override malloc() so value_coerce_to_target() gets a known
pointer, and we know we"ll see an error if $_as_string() gives
a string that isn't null terminated. */
void
*malloc (size_t size)
{
memset (arena, 'x', sizeof (arena));
if (size > sizeof (arena))
return NULL;
return arena;
}
int
main ()
{
return 0;
}
And then in a GDB session:
$ gdb -q test
Reading symbols from /tmp/test...
(gdb) start
Temporary breakpoint 1 at 0x4004c8: file test.c, line 17.
Starting program: /tmp/test
Temporary breakpoint 1, main () at test.c:17
17 return 0;
(gdb) printf "%s\n", $_as_string("hello")
"hello"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(gdb) quit
The problem above is caused by how value_cstring is used within
py-value.c, but once we understand the issue then it turns out that
value_cstring is used in an unexpected way in many places within GDB.
Within py-value.c we have a null-terminated C-style string. We then
pass a pointer to this string, along with the length of this
string (so not including the null-character) to value_cstring.
In value_cstring GDB allocates an array value of the given character
type, and copies in requested number of characters. However
value_cstring does not add a null-character of its own. This means
that the value created by calling value_cstring is only
null-terminated if the null-character is included in the passed in
length. In py-value.c this is not the case, and indeed, in most uses
of value_cstring, this is not the case.
When GDB tries to print one of these strings the value contents are
pushed to the inferior, and then read back as a C-style string, that
is, GDB reads inferior memory until it finds a null-terminator. For
the py-value.c case, no null-terminator is pushed into the inferior,
so GDB will continue reading inferior memory until a null-terminator
is found, with unpredictable results.
Patch Description
=================
The first thing this patch does is better define what the arguments
for the two function value_cstring and value_string should represent.
The comments in the header file are updated to describe whether the
length argument should, or should not, include a null-character.
Also, the data argument is changed to type gdb_byte. The functions as
they currently exist will handle wide-characters, in which case more
than one 'char' would be needed for each character. As such using
gdb_byte seems to make more sense.
To avoid adding casts throughout GDB, I've also added an overload that
still takes a 'char *', but asserts that the character type being used
is of size '1'.
The value_cstring function is now responsible for adding a null
character at the end of the string value it creates.
However, once we start looking at how value_cstring is used, we
realise there's another, related, problem. Not every language's
strings are null terminated. Fortran and Ada strings, for example,
are just an array of characters, GDB already has the function
value_string which can be used to create such values.
Consider this example using current GDB:
(gdb) set language ada
(gdb) p $_gdb_setting("arch")
$1 = (97, 117, 116, 111)
(gdb) ptype $
type = array (1 .. 4) of char
(gdb) p $_gdb_maint_setting("test-settings string")
$2 = (0)
(gdb) ptype $
type = array (1 .. 1) of char
This shows two problems, first, the $_gdb_setting and
$_gdb_maint_setting functions are calling value_cstring using the
builtin_char character, rather than a language appropriate type. In
the first call, the 'arch' case, the value_cstring call doesn't
include the null character, so the returned array only contains the
expected characters. But, in the $_gdb_maint_setting example we do
end up including the null-character, even though this is not expected
for Ada strings.
This commit adds a new language method language_defn::value_string,
this function takes a pointer and length and creates a language
appropriate value that represents the string. For C, C++, etc this
will be a null-terminated string (by calling value_cstring), and for
Fortran and Ada this can be a bounded array of characters with no null
terminator. Additionally, this new language_defn::value_string
function is responsible for selecting a language appropriate character
type.
After this commit the only calls to value_cstring are from the C
expression evaluator and from the default language_defn::value_string.
And the only calls to value_string are from Fortan, Ada, and ObjectC
related code.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21699
Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Co-Authored-By: Pedro Alves <pedro@palves.net>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
Fix a few typos:
- implemention -> implementation
- convertion(s) -> conversion(s)
- backlashes -> backslashes
- signoring -> ignoring
- (un)ambigious -> (un)ambiguous
- occured -> occurred
- hidding -> hiding
- temporarilly -> temporarily
- immediatelly -> immediately
- sillyness -> silliness
- similiar -> similar
- porkuser -> pokeuser
- thats -> that
- alway -> always
- supercede -> supersede
- accomodate -> accommodate
- aquire -> acquire
- priveleged -> privileged
- priviliged -> privileged
- priviledges -> privileges
- privilige -> privilege
- recieve -> receive
- (p)refered -> (p)referred
- succesfully -> successfully
- successfuly -> successfully
- responsability -> responsibility
- wether -> whether
- wich -> which
- disasbleable -> disableable
- descriminant -> discriminant
- construcstor -> constructor
- underlaying -> underlying
- underyling -> underlying
- structureal -> structural
- appearences -> appearances
- terciarily -> tertiarily
- resgisters -> registers
- reacheable -> reachable
- likelyhood -> likelihood
- intepreter -> interpreter
- disassemly -> disassembly
- covnersion -> conversion
- conviently -> conveniently
- atttribute -> attribute
- struction -> struct
- resonable -> reasonable
- popupated -> populated
- namespaxe -> namespace
- intialize -> initialize
- identifer(s) -> identifier(s)
- expection -> exception
- exectuted -> executed
- dungerous -> dangerous
- dissapear -> disappear
- completly -> completely
- (inter)changable -> (inter)changeable
- beakpoint -> breakpoint
- automativ -> automatic
- alocating -> allocating
- agressive -> aggressive
- writting -> writing
- reguires -> requires
- registed -> registered
- recuding -> reducing
- opeartor -> operator
- ommitted -> omitted
- modifing -> modifying
- intances -> instances
- imbedded -> embedded
- gdbaarch -> gdbarch
- exection -> execution
- direcive -> directive
- demanged -> demangled
- decidely -> decidedly
- argments -> arguments
- agrument -> argument
- amespace -> namespace
- targtet -> target
- supress(ed) -> suppress(ed)
- startum -> stratum
- squence -> sequence
- prompty -> prompt
- overlow -> overflow
- memember -> member
- languge -> language
- geneate -> generate
- funcion -> function
- exising -> existing
- dinking -> syncing
- destroh -> destroy
- clenaed -> cleaned
- changep -> changedp (name of variable)
- arround -> around
- aproach -> approach
- whould -> would
- symobl -> symbol
- recuse -> recurse
- outter -> outer
- freeds -> frees
- contex -> context
Tested on x86_64-linux.
Reviewed-By: Tom Tromey <tom@tromey.com>
|
|
g++ 13.1.1 produces a -Werror=dangling-pointer=
In file included from ../../binutils-gdb/gdb/frame.h:75,
from ../../binutils-gdb/gdb/symtab.h:40,
from ../../binutils-gdb/gdb/language.c:33:
In member function ‘void intrusive_list<T, AsNode>::push_empty(T&) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’,
inlined from ‘void intrusive_list<T, AsNode>::push_back(reference) [with T = frame_info_ptr; AsNode = intrusive_base_node<frame_info_ptr>]’ at gdbsupport/intrusive_list.h:332:24,
inlined from ‘frame_info_ptr::frame_info_ptr(const frame_info_ptr&)’ at gdb/frame.h:241:26,
inlined from ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’ at gdb/language.c:530:49:
gdbsupport/intrusive_list.h:415:12: error: storing the address of local variable ‘<anonymous>’ in ‘frame_info_ptr::frame_list.intrusive_list<frame_info_ptr>::m_back’ [-Werror=dangling-pointer=]
415 | m_back = &elem;
| ~~~~~~~^~~~~~~
gdb/language.c: In function ‘CORE_ADDR skip_language_trampoline(frame_info_ptr, CORE_ADDR)’:
gdb/language.c:530:49: note: ‘<anonymous>’ declared here
530 | CORE_ADDR real_pc = lang->skip_trampoline (frame, pc);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
gdb/frame.h:359:41: note: ‘frame_info_ptr::frame_list’ declared here
359 | static intrusive_list<frame_info_ptr> frame_list;
| ^~~~~~~~~~
Each new frame_info_ptr is being pushed on a static frame list and g++
cannot see why that is safe in case the frame_info_ptr is created and
destroyed immediately when passed as value.
It isn't clear why only in this one place g++ sees the issue (probably
because it can inline enough code in this specific case).
Since passing the frame_info_ptr as const reference is cheaper, use
that as workaround for this warning.
PR build/30413
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30413
Tested-by: Kevin Buettner <kevinb@redhat.com>
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
Reviewed-by: Tom Tromey <tom@tromey.com>
|
|
set_language returns the previous language, but nothing uses it. Remove
the return value. This lets us remove the assignment to
current_language, in _initialize_language.
Change-Id: Ifccf9b488434c1addf4626130a74e159a37d8c17
Reviewed-By: Tom Tromey <tom@tromey.com>
|
|
I noticed that language_demangle shadows the global
"current_language". When I went to fix this, though, I then saw that
language_demangle is only called in two places, and has a comment
saying it should be removed. This patch removes it. Note that the
NULL check in language_demangle is not needed by either of the
existing callers.
Regression tested on x86-64 Fedora 36.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This commit splits the `set/show print elements' option into two. We
retain `set/show print elements' for controlling how many elements of an
array we print, but a new `set/show print characters' setting is added
which is used for controlling how many characters of a string are
printed.
The motivation behind this change is to allow users a finer level of
control over how data is printed, reflecting that, although strings can
be thought of as arrays of characters, users often want to treat these
two things differently.
For compatibility reasons by default the `set/show print characters'
option is set to `elements', which makes the limit for character strings
follow the setting of the `set/show print elements' option, as it used
to. Using `set print characters' with any other value makes the limit
independent from the `set/show print elements' setting, however it can
be restored to the default with the `set print characters elements'
command at any time.
A corresponding `-characters' option for the `print' command is added,
with the same semantics, i.e. one can use `elements' to make a given
`print' invocation follow the limit of elements, be it set with the
`-elements' option also given with the same invocation or taken from the
`set/show print elements' setting, for characters as well regardless of
the current setting of the `set/show print characters' option.
The GDB changes are all pretty straightforward, just changing references
to the old 'print_max' to use a new `get_print_max_chars' helper which
figures out which of the two of `print_max' and `print_max_chars' values
to use.
Likewise, the documentation is just updated to reference the new setting
where appropriate.
To make people's life easier the message shown by `show print elements'
now indicates if the setting also applies to character strings:
(gdb) set print characters elements
(gdb) show print elements
Limit on string chars or array elements to print is 200.
(gdb) set print characters unlimited
(gdb) show print elements
Limit on array elements to print is 200.
(gdb)
and the help text shows the dependency as well:
(gdb) help set print elements
Set limit on array elements to print.
"unlimited" causes there to be no limit.
This setting also applies to string chars when "print characters"
is set to "elements".
(gdb)
In the testsuite there are two minor updates, one to add `-characters'
to the list of completions now shown for the `print' command, and a bare
minimum pair of checks for the right handling of `set print characters'
and `show print characters', copied from the corresponding checks for
`set print elements' and `show print elements' respectively.
Co-Authored-By: Maciej W. Rozycki <macro@embecosm.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
|
|
This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.
|
|
PR exp/28359 points out that 'ptype/o' does not work when the current
language is "asm".
I tracked this down to a hard-coded list of languages in typeprint.c.
This patch replaces this list with a method on 'language_defn'
instead. If all languages are ever updated to have this feature, the
method could be removed; but in the meantime this lets each language
control what happens.
I looked at having each print_type method simply modify the flags
itself, but this doesn't work very well with the feature that disables
method-printing by default (but allows it via a flag).
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28359
Approved-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Keith Seitz <keiths@redhat.com>
|
|
Fix some whitespace issues introduced with the frame_info_ptr patch.
Change-Id: I158d30d8108c97564276c647fc98283ff7b12163
|
|
This changes GDB to use frame_info_ptr instead of frame_info *
The substitution was done with multiple sequential `sed` commands:
sed 's/^struct frame_info;/class frame_info_ptr;/'
sed 's/struct frame_info \*/frame_info_ptr /g' - which left some
issues in a few files, that were manually fixed.
sed 's/\<frame_info \*/frame_info_ptr /g'
sed 's/frame_info_ptr $/frame_info_ptr/g' - used to remove whitespace
problems.
The changed files were then manually checked and some 'sed' changes
undone, some constructors and some gets were added, according to what
made sense, and what Tromey originally did
Co-Authored-By: Bruno Larsen <blarsen@redhat.com>
Approved-by: Tom Tomey <tom@tromey.com>
|
|
Make an introduction of a new print setting that can be set by 'set
print nibbles [on|off]'. The default value if OFF, which can be changed
by user manually. Of course, 'show print nibbles' is also included in
the patch.
The new feature displays binary values by group, with four bits per
group. The motivation for this work is to enhance the readability of
binary values.
Here's a GDB session before this patch is applied.
(gdb) print var_a
$1 = 1230
(gdb) print/t var_a
$2 = 10011001110
With this patch applied, we can use the new print setting to display the
new form of the binary values.
(gdb) print var_a
$1 = 1230
(gdb) print/t var_a
$2 = 10011001110
(gdb) set print nibbles on
(gdb) print/t var_a
$3 = 0100 1100 1110
Tested on x86_64 openSUSE Tumbleweed.
|
|
This removes the LA_PRINT_STRING macro, in favor of using ordinary
method calls.
|
|
This removes the LA_PRINT_CHAR macro, in favor of using ordinary
method calls.
|
|
This removes the LA_PRINT_TYPE macro, in favor of using ordinary
method calls.
|
|
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.
For the avoidance of doubt, all changes in this commits were
performed by the script.
|
|
I noticed that some methods in language_defn could use
unique_xmalloc_ptr<char> rather than a plain 'char *'. This patch
implements this change, fixing up the fallout and changing
gdb_demangle to also return this type. In one spot, std::string is
used to simplify some related code, and in another, an auto_obstack is
used to avoid manual management.
Regression tested on x86-64 Fedora 34.
|
|
In a recent commit I used 'manor' in some comments rather than
'manner'. This commit fixes those two mistakes.
I also looked through the gdb/ tree and found one additional instance
of this mistake that this commit also fixes.
|
|
I noticed that value_true is declared in language.h and defined in
language.c. However, as part of the value API, I think it would be
better in one of those files. And, because it is very short, I
changed it to be an inline function in value.h. I've also removed a
comment from the implementation, on the basis that it seems obsolete
-- if the change it suggests was needed, it probably would have been
done by now; and if it is needed in the future, odds are it would be
done differently anyway.
Finally, this patch also changes value_true and value_logical_not to
return a bool, and updates some uses.
|
|
I noticed that pointer_type is declared in language.h and defined in
language.c. However, it really has to do with types, so it should
have been in gdbtypes.h all along.
This patch changes it to be a method on struct type. And, I went
through uses of TYPE_IS_REFERENCE and updated many spots to use the
new method as well. (I didn't update ones that were in arch-specific
code, as I couldn't readily test that.)
|
|
With current master and gcc 7.5.0/8.5.0, we have this timeout:
...
(gdb) print s^M
Multiple matches for s^M
[0] cancel^M
[1] s at src/gdb/testsuite/gdb.ada/interface/foo.adb:20^M
[2] s at src/gdb/testsuite/gdb.ada/interface/foo.adb:?^M
> FAIL: gdb.ada/interface.exp: print s (timeout)
...
[ The FAIL doesn't reproduce with gcc 9.3.1. This difference in
behaviour bisects to gcc commit d70ba0c10de.
The FAIL with earlier gcc bisects to gdb commit ba8694b650b. ]
The FAIL is caused by gcc generating this debug info describing a named
artificial variable:
...
<2><1204>: Abbrev Number: 31 (DW_TAG_variable)
<1205> DW_AT_name : s.14
<1209> DW_AT_type : <0x1213>
<120d> DW_AT_artificial : 1
<120d> DW_AT_location : 5 byte block: 91 e0 7d 23 18 \
(DW_OP_fbreg: -288; DW_OP_plus_uconst: 24)
...
An easy way to fix this would be to simply not put named artificial variables
into the symbol table. However, that causes regressions for Ada. It relies
on being able to get the value from such variables, using a named reference.
Fix this instead by marking the symbol as artificial, and:
- ignoring such symbols in ada_resolve_variable, which fixes the FAIL
- ignoring such ada symbols in do_print_variable_and_value, which prevents
them from showing up in "info locals"
Note that a fix for the latter was submitted here (
https://sourceware.org/pipermail/gdb-patches/2008-January/054994.html ), and
this patch borrows from it.
Tested on x86_64-linux.
Co-Authored-By: Joel Brobecker <brobecker@adacore.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28180
|
|
I noticed that language_info is only ever called with a value of '1'.
This patch removes the parameter.
2021-03-29 Tom Tromey <tromey@adacore.com>
* top.c (check_frame_language_change): Update.
* language.c (language_info): Remove parameter.
* language.h (language_info): Remove parameter.
|
|
This removes union exp_element functions that either create such
elements or walk them. struct expression no longer holds
exp_elements. A couple of language_defn methods are also removed, as
they are obsolete.
Note that this patch also removes the print_expression code. The only
in-tree caller of this was from dump_prefix_expression, which is only
called when expression debugging is enabled. Implementing this would
involve a fair amount of code, and it seems to me that prefix dumping
is preferable anyway, as it is unambiguous. So, I have not
reimplemented this feature.
gdb/ChangeLog
2021-03-08 Tom Tromey <tom@tromey.com>
* value.h (evaluate_subexp_with_coercion): Don't declare.
* parse.c (exp_descriptor_standard): Remove.
(expr_builder::expr_builder, expr_builder::release): Update.
(expression::expression): Remove size_t parameter.
(expression::~expression): Simplify.
(expression::resize): Remove.
(write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym)
(write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile)
(write_exp_elt_longcst, write_exp_elt_floatcst)
(write_exp_elt_type, write_exp_elt_intern, write_exp_string)
(write_exp_string_vector, write_exp_bitstring): Remove.
* p-lang.h (class pascal_language) <opcode_print_table,
op_print_tab>: Remove.
* p-lang.c (pascal_language::op_print_tab): Remove.
* opencl-lang.c (class opencl_language) <opcode_print_table>:
Remove.
* objc-lang.c (objc_op_print_tab): Remove.
(class objc_language) <opcode_print_table>: Remove.
* m2-lang.h (class m2_language) <opcode_print_table,
op_print_tab>: Remove.
* m2-lang.c (m2_language::op_print_tab): Remove.
* language.h (struct language_defn) <post_parser, expression_ops,
opcode_print_table>: Remove.
* language.c (language_defn::expression_ops)
(auto_or_unknown_language::opcode_print_table): Remove.
* go-lang.h (class go_language) <opcode_print_table,
op_print_tab>: Remove.
* go-lang.c (go_language::op_print_tab): Remove.
* f-lang.h (class f_language) <opcode_print_table>: Remove
<op_print_tab>: Remove.
* f-lang.c (f_language::op_print_tab): Remove.
* expression.h (union exp_element): Remove.
(struct expression): Remove size_t parameter from constructor.
<resize>: Remove.
<first_opcode>: Update.
<nelts, elts>: Remove.
(EXP_ELEM_TO_BYTES, BYTES_TO_EXP_ELEM): Remove.
(evaluate_subexp_standard, print_expression, op_string)
(dump_raw_expression): Don't declare.
* expprint.c (print_expression, print_subexp)
(print_subexp_funcall, print_subexp_standard, op_string)
(dump_raw_expression, dump_subexp, dump_subexp_body)
(dump_subexp_body_funcall, dump_subexp_body_standard): Remove.
(dump_prefix_expression): Update.
* eval.c (evaluate_subexp): Remove.
(evaluate_expression, evaluate_type): Update.
(evaluate_subexpression_type): Remove.
(fetch_subexp_value): Remove "pc" parameter. Update.
(extract_field_op, evaluate_struct_tuple, evaluate_funcall)
(evaluate_subexp_standard, evaluate_subexp_for_address)
(evaluate_subexp_with_coercion, evaluate_subexp_for_sizeof)
(evaluate_subexp_for_cast): Remove.
(parse_and_eval_type): Update.
* dtrace-probe.c (dtrace_probe::compile_to_ax): Update.
* d-lang.c (d_op_print_tab): Remove.
(class d_language) <opcode_print_table>: Remove.
* c-lang.h (c_op_print_tab): Don't declare.
* c-lang.c (c_op_print_tab): Remove.
(class c_language, class cplus_language, class asm_language, class
minimal_language) <opcode_print_table>: Remove.
* breakpoint.c (update_watchpoint, watchpoint_check)
(watchpoint_exp_is_const, watch_command_1): Update.
* ax-gdb.h (union exp_element): Don't declare.
* ax-gdb.c (const_var_ref, const_expr, maybe_const_expr)
(gen_repeat, gen_sizeof, gen_expr_for_cast, gen_expr)
(gen_expr_binop_rest): Remove.
(gen_trace_for_expr, gen_eval_for_expr, gen_printf): Update.
* ada-lang.c (ada_op_print_tab): Remove.
(class ada_language) <post_parser, opcode_print_table>: Remove.
|
|
This changes language_defn::get_compile_context to return a
unique_ptr. This makes the ownership transfer clear.
gdb/ChangeLog
2021-02-05 Tom Tromey <tom@tromey.com>
* compile/compile-c-support.c (get_compile_context)
(c_get_compile_context, cplus_get_compile_context): Change return
type.
* language.c (language_defn::get_compile_instance): New method.
* language.h (language_defn::get_compile_instance): Change return
type. No longer inline.
* c-lang.c (c_language::get_compile_instance): Change return type.
(cplus_language::get_compile_instance): Change return type.
* c-lang.h (c_get_compile_context, cplus_get_compile_context):
Change return type.
* compile/compile.c (compile_to_object): Update.
|
|
This commits the result of running gdb/copyright.py as per our Start
of New Year procedure...
gdb/ChangeLog
Update copyright year range in copyright header of all GDB files.
|
|
Now that every use of the LA_EMIT_CHAR macro is within a language_defn
member function we can simply call the emitchar member function
directly instead of using the LA_EMIT_CHAR macro.
If we are ever inside a language object, for example, cplus_language,
while current_language points at something other than cplus_language
then this commit will result in a change in behaviour. However, I
believe if we did have such a difference then this would be a bug in
GDB. AS such I'm going to claim there _should_ be no user visible
changes from this commit.
gdb/ChangeLog:
* c-lang.c (language_defn::printchar): Call emitchar, not
LA_EMIT_CHAR.
* f-lang.h (f_language::printchar): Likewise.
* language.h (LA_EMIT_CHAR): Delete macro.
* rust-lang.c (rust_language::printchar): Call emitchar, not
LA_EMIT_CHAR.
|
|
In the expression rewrite, Ada type resolution will be done at parse
time rather than in a post-parse pass. At this point,
language_defn::post_parser will be removed. However, for this to
work, the information available to post_parser must be made available
during the actual parse.
This patch refactors this code slightly to make this possible. In
particular, "void_context_p" is passed to the parser_state
constructor, and the parser state is then passed to the post_parser
method.
gdb/ChangeLog
2020-12-16 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_lex_tests): Update.
* parser-defs.h (parser_state): Add void_p parameter.
<void_context_p>: New member.
* parse.c (parse_exp_in_context): Update.
* language.h (language_defn::post_parser): Remove void_context_p,
completing, tracker parameters. Add parser state.
* ada-lang.c (ada_language::post_parser): Update.
|
|
This patch changes void_context_p to bool, as a prerequisite to the
change to post_parser that I submitted here:
https://sourceware.org/pipermail/gdb-patches/2020-December/174080.html
Tested by rebuilding.
Note that nothing in-tree passes true here. I don't know why this is,
but there is a use of this internally in AdaCore's tree. I will try
to submit that patch, if it is needed. (And if not, I will come back
around and remove this.)
gdb/ChangeLog
2020-12-16 Tom Tromey <tom@tromey.com>
* parse.c (parse_exp_1, parse_expression_for_completion): Update.
(parse_exp_in_context): Change void_context_p to bool.
* language.h (struct language_defn) <post_parser>: Change
void_context_p to bool.
* ada-lang.c (class ada_language) <post_parser>: Update.
|
|
gdb/ChangeLog:
* language.c (language_arch_info::lookup_primitive_type): Use
gdb::function_view instead of gdb::function.
(template language_lookup_primitive_type): Rename to ...
(language_lookup_primitive_type_1): ... this, and make static.
(language_lookup_primitive_type(const struct language_defn *,
struct gdbarch *, const char *): Make non-template.
(language_lookup_primitive_type(const struct language_defn *,
struct gdbarch *, std::function<bool (struct type *)>): Make
non-template and use gdb::function_view.
* language.h (language_arch_info::lookup_primitive_type): Use
gdb::function_view instead of std::function.
(language_lookup_primitive_type): No longer template.
* opencl-lang.c (lookup_opencl_vector_type): 'filter' is now a
lambda instead of a std::function.
|
|
Consider the following GDB session:
$ gdb
(gdb) set language c
(gdb) ptype void
type = void
(gdb) set language fortran
(gdb) ptype void
No symbol table is loaded. Use the "file" command.
(gdb)
With no symbol file loaded GDB and the language set to C GDB knows
about the type void, while when the language is set to Fortran GDB
doesn't know about the void, why is that?
In f-lang.c, f_language::language_arch_info, we do have this line:
lai->primitive_type_vector [f_primitive_type_void]
= builtin->builtin_void;
where we add the void type to the list of primitive types that GDB
should always know about, so what's going wrong?
It turns out that the primitive types are stored in a C style array,
indexed by an enum, so Fortran uses `enum f_primitive_types'. The
array is allocated and populated in each languages language_arch_info
member function. The array is allocated with an extra entry at the
end which is left as a NULL value, and this indicates the end of the
array of types.
Unfortunately for Fortran, a type is not assigned for each element in
the enum. As a result the final populated array has gaps in it, gaps
which are initialised to NULL, and so every time we iterate over the
list (for Fortran) we stop early, and never reach the void type.
This has been the case since 2007 when this functionality was added to
GDB in commit cad351d11d6c3f6487cd.
Obviously I could just fix Fortran by ensuring that either the enum is
trimmed, or we create types for the missing types. However, I think a
better approach would be to move to C++ data structures and removed
the fixed enum indexing into the array approach.
After this commit the primitive types are pushed into a vector, and
GDB just iterates over the vector in the obvious way when it needs to
hunt for a type. After this commit all the currently defined
primitive types can be found when the language is set to Fortran, for
example:
$ gdb
(gdb) set language fortran
(gdb) ptype void
type = void
(gdb)
A new test checks this functionality.
I didn't see any other languages with similar issues, but I could have
missed something.
gdb/ChangeLog:
* ada-exp.y (find_primitive_type): Make parameter const.
* ada-lang.c (enum ada_primitive_types): Delete.
(ada_language::language_arch_info): Update.
* c-lang.c (enum c_primitive_types): Delete.
(c_language_arch_info): Update.
(enum cplus_primitive_types): Delete.
(cplus_language::language_arch_info): Update.
* d-lang.c (enum d_primitive_types): Delete.
(d_language::language_arch_info): Update.
* f-lang.c (enum f_primitive_types): Delete.
(f_language::language_arch_info): Update.
* go-lang.c (enum go_primitive_types): Delete.
(go_language::language_arch_info): Update.
* language.c (auto_or_unknown_language::language_arch_info):
Update.
(language_gdbarch_post_init): Use obstack_new, use array indexing.
(language_string_char_type): Add header comment, call function in
language_arch_info.
(language_bool_type): Likewise
(language_arch_info::bool_type): Define.
(language_lookup_primitive_type_1): Delete.
(language_lookup_primitive_type): Rewrite as a templated function
to call function in language_arch_info, then instantiate twice.
(language_arch_info::type_and_symbol::alloc_type_symbol): Define.
(language_arch_info::lookup_primitive_type_and_symbol): Define.
(language_arch_info::lookup_primitive_type): Define twice with
different signatures.
(language_arch_info::lookup_primitive_type_as_symbol): Define.
(language_lookup_primitive_type_as_symbol): Rewrite to call a
member function in language_arch_info.
* language.h (language_arch_info): Complete rewrite.
(language_lookup_primitive_type): Make templated.
* m2-lang.c (enum m2_primitive_types): Delete.
(m2_language::language_arch_info): Update.
* opencl-lang.c (OCL_P_TYPE): Delete.
(enum opencl_primitive_types): Delete.
(opencl_type_data): Delete.
(builtin_opencl_type): Delete.
(lookup_opencl_vector_type): Update.
(opencl_language::language_arch_info): Update, lots of content
moved from...
(build_opencl_types): ...here. This function is now deleted.
(_initialize_opencl_language): Delete.
* p-lang.c (enum pascal_primitive_types): Delete.
(pascal_language::language_arch_info): Update.
* rust-lang.c (enum rust_primitive_types): Delete.
(rust_language::language_arch_info): Update.
gdb/testsuite/ChangeLog:
* gdb.fortran/types.exp: Add more tests.
|
|
Improves the comment at the declaration of language_defn::print_type.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* language.h (language_defn::print_type): Add variable names in
declaration, and update header comment.
|
|
GDB already has a global symbol `demangle` (a boolean), having a
language method called `demangle` is not a good idea as we often want
to reference `demangle` the control variable inside `demangle` the
member function.
This commit renames `demangle` the member function to
`demangle_symbol`.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language::demangle): Rename to...
(ada_language::demangle_symbol): ...this.
* c-lang.c (cplus_language::demangle): Rename to...
(cplus_language::demangle_symbol): ...this.
* d-lang.c (d_language::demangle): Rename to...
(d_language::demangle_symbol): ...this.
* f-lang.c (f_language::demangle): Rename to...
(f_language::demangle_symbol): ...this.
* go-lang.c (go_language::demangle): Rename to...
(go_language::demangle_symbol): ...this.
* language.c (language_demangle): Update call to demangle_symbol.
(auto_or_unknown_language::demangle): Rename to...
(auto_or_unknown_language::demangle_symbol): ...this.
* language.h (language_defn::demangle): Rename to...
(language_defn::demangle_symbol): ...this.
* objc-lang.c (objc_language::demangle): Rename to...
(objc_language::demangle_symbol): ...this.
* rust-lang.c (rust_language::demangle): Rename to...
(rust_language::demangle_symbol): ...this.
|
|
Replace the single use of the LA_ITERATE_OVER_SYMBOLS macro with the
macro's definition, and delete the macro.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* language.h (LA_ITERATE_OVER_SYMBOLS): Delete.
(iterate_over_file_blocks): Replace use of macro with the macros
definition.
|
|
Replace the single use of the LA_PRINT_ARRAY_INDEX macro with the
macro's definition, and delete the macro.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* language.h (LA_PRINT_ARRAY_INDEX): Delete.
* valprint.c (maybe_print_array_index): Replace use of macro with
the macros definition.
|
|
Remove the LA_VALUE_PRINT macro, and replace its uses with direct
calls to the value_print member function on an appropriate language.
In the global 'value_print' function, we call the value_print method
on the current_language, this is a direct inline replacement of the
old LA_VALUE_PRINT macro.
However, in ada-lang.c, and language.c the macro was being used
within the print_array_index member function of a language class. In
these cases we now call the value_print member function of the current
language class.
In theory, when we are inside (for example) the
ada_language::print_array_index function the current_language should
always be set to Ada, so this change should have no effect. However,
if we ever could get into ada_language::print_array_index with the
current language set to something else (which I think would have been
a bug) then we would now see a change in behaviour. I couldn't find
any cases where this happened though.
There should be no user visible changes after this commit, but it is
not impossible in some edge cases.
gdb/ChangeLog:
* ada-lang.c (ada_language::print_array_index): Call value_print
directly.
* language.c (language_defn::print_array_index): Likewise.
* language.h (LA_VALUE_PRINT): Delete.
* valprint.c (value_print): Call value_print on the
current_language directly.
|
|
Remove the LA_PRINT_TYPEDEF macro, replace the single use with the
macros definition.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* language.h (LA_PRINT_TYPEDEF): Delete.
* typeprint.c (typedef_print): Call print_typedef directly on the
current_language object.
|
|
The language_data type, from which language_defn inherits, is now
empty, and this commit removes it.
Each language is updated to no longer create and use a language_data
struct.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete.
(ada_language): Remove references to ada_language_data.
* c-lang.c (c_language_data): Delete.
(c_language): Remove references to c_language_data.
(cplus_language_data): Delete.
(cplus_language): Remove references to cplus_language_data.
(asm_language_data): Delete.
(asm_language): Remove references to asm_language_data.
(minimal_language_data): Delete.
(minimal_language): Remove references to minimal_language_data.
* d-lang.c (d_language_data): Delete.
(d_language): Remove references to d_language_data.
* f-lang.c (f_language_data): Delete.
(f_language): Remove references to f_language_data.
* go-lang.c (go_language_data): Delete.
(go_language): Remove references to go_language_data.
* language.c (unknown_language_data): Delete.
(unknown_language): Remove references to unknown_language_data.
(auto_language_data): Delete.
(auto_language): Remove references to auto_language_data.
* language.h (language_data): Delete struct.
(language_defn): No longer inherit from language_data.
* m2-lang.c (m2_language_data): Delete.
(m2_language): Remove references to m2_language_data.
* objc-lang.c (objc_language_data): Delete.
(objc_language): Remove references to objc_language_data.
* opencl-lang.c (opencl_language_data): Delete.
(opencl_language): Remove references to opencl_language_data.
* p-lang.c (pascal_language_data): Delete.
(pascal_language): Remove references to pascal_language_data.
* rust-lang.c (rust_language_data): Delete.
(rust_language): Remove references to rust_language_data.
|
|
Convert language_data::la_op_print_tab member variable to a virtual
method language_defn::opcode_print_table. I changed the name in order
to make it clearer (I hope) what the method does.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_op_print_tab
initializer.
(ada_language::opcode_print_table): New member function.
* c-lang.c (c_language_data): Remove la_op_print_tab initializer.
(c_language::opcode_print_table): New member function.
(cplus_language_data): Remove la_op_print_tab initializer.
(cplus_language::opcode_print_table): New member function.
(asm_language_data): Remove la_op_print_tab initializer.
(asm_language::opcode_print_table): New member function.
(minimal_language_data): Remove la_op_print_tab initializer.
(minimal_language::opcode_print_table): New member function.
* d-lang.c (d_language_data): Remove la_op_print_tab initializer.
(d_language::opcode_print_table): New member function.
* expprint.c (print_subexp_standard): Update call to
opcode_print_table.
(op_string): Likewise.
* f-lang.c (f_language_data): Remove la_op_print_tab initializer.
(f_language::opcode_print_table): New member function.
* go-lang.c (go_language_data): Remove la_op_print_tab
initializer.
(go_language::opcode_print_table): New member function.
* language.c (unknown_language_data): Remove la_op_print_tab
initializer.
(unknown_language::opcode_print_table): New member function.
(auto_language_data): Remove la_op_print_tab initializer.
(auto_language::opcode_print_table): New member function.
* language.h (language_data): Remove la_op_print_tab field.
(language_defn::opcode_print_table): Declare new member function.
* m2-lang.c (m2_language_data): Remove la_op_print_tab
initializer.
(m2_language::opcode_print_table): New member function.
* objc-lang.c (objc_language_data): Remove la_op_print_tab
initializer.
(objc_language::opcode_print_table): New member function.
* opencl-lang.c (opencl_language_data): Remove la_op_print_tab
initializer.
(opencl_language::opcode_print_table): New member function.
* p-lang.c (pascal_language_data): Remove la_op_print_tab
initializer.
(pascal_language::opcode_print_table): New member function.
* rust-lang.c (rust_language_data): Remove la_op_print_tab
initializer.
(rust_language::opcode_print_table): New member function.
|
|
Convert language_data::la_exp_desc member variable to a virtual
method language_defn::expression_ops. The change of names brings this
method more into line with the existing varobj_ops method, that also
returns a table of function pointers.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_exp_desc initializer.
(ada_language::expression_ops): New member function.
* c-lang.c (c_language_data): Remove la_exp_desc initializer.
(c_language::expression_ops): New member function.
(cplus_language_data): Remove la_exp_desc initializer.
(cplus_language::expression_ops): New member function.
(asm_language_data): Remove la_exp_desc initializer.
(asm_language::expression_ops): New member function.
(minimal_language_data): Remove la_exp_desc initializer.
(minimal_language::expression_ops): New member function.
* d-lang.c (d_language_data): Remove la_exp_desc initializer.
(d_language::expression_ops): New member function.
* eval.c (evaluate_subexp): Update call to expression_ops.
* expprint.c (print_subexp): Likewise.
(op_name): Likewise.
(dump_subexp_body): Likewise.
* f-lang.c (f_language_data): Remove la_exp_desc initializer.
(f_language::expression_ops): New member function.
* go-lang.c (go_language_data): Remove la_exp_desc initializer.
(go_language::expression_ops): New member function.
* language.c (language_defn::expression_ops): New function.
(unknown_language_data): Remove la_exp_desc initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_exp_desc field.
(language_defn::expression_ops): Declare new member function.
* m2-lang.c (m2_language_data): Remove la_exp_desc initializer.
(m2_language::expression_ops): New member function.
* objc-lang.c (objc_language_data): Remove la_exp_desc
initializer.
* opencl-lang.c (opencl_language_data): Remove la_exp_desc
initializer.
(opencl_language::expression_ops): New member function.
* p-lang.c (pascal_language_data): Remove la_exp_desc initializer.
* parse.c (operator_length): Update call to expression_ops.
(exp_iterate): Likewise.
* rust-lang.c (rust_language_data): Remove la_exp_desc
initializer.
(ruse_language::expression_ops): New member function.
|
|
Convert language_data::la_varobj_ops member variable to a virtual
method language_defn::varobj_ops.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_varobj_ops
initializer.
(ada_language::varobj_ops): New member function.
* c-lang.c (c_language_data): Remove la_varobj_ops
initializer.
(cplus_language_data): Likewise.
(cplus_language::varobj_ops): New member function.
(asm_language_data): Remove la_varobj_ops initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (language_defn::varobj_ops): New function.
(unknown_language_data): Remove la_varobj_ops
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_varobj_ops field.
(language_defn::varobj_ops): Declare new member function.
* m2-lang.c (m2_language_data): Remove la_varobj_ops initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* varobj.c (varobj_create): Update call to varobj_ops.
* varobj.h (default_varobj_ops): Delete define.
|
|
Convert language_data::la_macro_expansion member variable to a virtual
method language_defn::macro_expansion.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_macro_expansion
initializer.
* c-lang.c (c_language_data): Likewise.
(c_language::macro_expansion): New member function.
(cplus_language_data): Likewise.
(cplus_language::macro_expansion): New member function.
(asm_language_data): Likewise.
(asm_language::macro_expansion): New member function.
(minimal_language_data): Likewise.
(minimal_language::macro_expansion): New member function.
* d-lang.c (d_language_data): Remove la_macro_expansion
initializer.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_macro_expansion field.
(language_defn::macro_expansion): New member function.
* m2-lang.c (m2_language_data): Remove la_macro_expansion
initializer.
* objc-lang.c (objc_language_data): Likewise.
(objc_language::macro_expansion): New member function.
* opencl-lang.c (opencl_language_data): Likewise.
(opencl_language::macro_expansion): New member function.
* p-lang.c (pascal_language_data): Remove la_macro_expansion
initializer.
* rust-lang.c (rust_language_data): Likewise.
* symtab.c (default_collect_symbol_completion_matches_break_on):
Update call to macro_expansion.
|
|
Convert language_data::la_array_ordering member variable to a virtual
method language_defn::array_ordering.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_array_ordering
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* dwarf2/read.c (read_array_order): Update for call to
array_ordering.
* f-lang.c (f_language_data): Remove la_array_ordering
initializer.
(f_language::array_ordering): New member function.
* go-lang.c (go_language_data): Remove la_array_ordering
initializer.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_array_ordering field.
(language_defn::array_ordering): New member function.
* m2-lang.c (m2_language_data): Remove la_array_ordering
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
|
|
Convert language_data::la_case_sensitivity member variable to a virtual
method language_defn::case_sensitivity.
This is mostly straight forward. The only slight problem is that I
ended up deleting this comment from ada-lang.c:
/* Yes, Ada is case-insensitive, but that's not quite what this
means. */
However, as the comment (which has existed since Ada support was first
added to GDB) doesn't explain _why_ Ada sets case sensitivity to on
despite being a generally case insensitive language, this doesn't
really help me much.
If I understood _why_ the setting doesn't quite mean what it seems to
mean (at least as far as Ada is concerned) then I would extend the
comment on language_defn::case_sensitivity (in language.h) to include
the detail, and note how this impacts Ada. But as it stands I've just
deleted the comment for now.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_case_sensitivity
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::case_sensitivity): New member function.
* go-lang.c (go_language_data): Remove la_case_sensitivity
initializer.
* language.c (enum case_mode): Moved here from language.h.
(case_mode): Make static.
(show_case_command): Update for case_sensitivity being a method.
(set_case_command): Likewise.
(set_range_case): Likewise.
(unknown_language_data): Remove la_case_sensitivity initializer.
(auto_language_data): Likewise.
* language.h (case_mode): Delete, move enum declaration to
language.c.
(language_data): Delete la_case_sensitivity field.
(language_defn::case_sensitivity): New member function.
* m2-lang.c (m2_language_data): Remove la_case_sensitivity
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
|
|
Convert language_data::la_range_check member variable to a virtual
method language_defn::range_checking_on_by_default.
Where the previous member variable was of type 'enum range_check', the
new member function returns a boolean that selects between range
checking being on or off. This removes the possibility of a language
having its default be the third enum state, range_check_warn, which
no language currently used.
This all makes sense I think, the language's true/false provides the
default when the global 'set check range' is set to 'auto'.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_range_check
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::range_checking_on_by_default): New member function.
* go-lang.c (go_language_data): Remove la_range_check initializer.
* language.c (enum range_mode): Moved here from language.h.
(range_mode): Made static.
(show_range_command): Update to use
range_checking_on_by_default.
(set_range_command): Likewise.
(set_range_case): Likewise.
(unknown_language_data): Remove la_range_check initializer.
(auto_language_data): Likewise.
* language.h (range_mode): Delete. Enum definition moved to
language.c.
(language_data): Remove la_range_check field.
(language_defn::range_checking_on_by_default): New member
function.
* m2-lang.c (m2_language_data): Remove la_range_check initializer.
(m2_language::range_checking_on_by_default): New member function.
* objc-lang.c (objc_language_data): Remove la_range_check
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::range_checking_on_by_default): New member
function.
* rust-lang.c (rust_language_data): Remove la_range_check
initializer.
(rust_language::range_checking_on_by_default): New member
function.
|
|
Convert language_data::la_store_sym_names_in_linkage_form_p member
variable to language_defn::store_sym_names_in_linkage_form_p virtual
function.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(ada_language::store_sym_names_in_linkage_form_p): New member
function.
* c-lang.c (c_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(c_language::store_sym_names_in_linkage_form_p): New member
function.
(cplus_language_data): Remove la_store_sym_names_in_linkage_form_p
initializer.
(asm_language_data): Likewise.
(asm_language::store_sym_names_in_linkage_form_p): New member
function.
(minimal_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(minimal_language::store_sym_names_in_linkage_form_p): New member
function.
* d-lang.c (d_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* dwarf2/read.c (dwarf2_physname): Update call to
store_sym_names_in_linkage_form_p.
* f-lang.c (f_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* go-lang.c (go_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* language.c (unknown_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
(unknown_language::store_sym_names_in_linkage_form_p): New member
function.
(auto_language_data): Remove la_store_sym_names_in_linkage_form_p
initializer.
(auto_language::store_sym_names_in_linkage_form_p): New member
function.
* language.h (language_data): Remove
la_store_sym_names_in_linkage_form_p member variable.
(language_defn::store_sym_names_in_linkage_form_p): New member
function.
* m2-lang.c (m2_language_data): Remove
la_store_sym_names_in_linkage_form_p initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
|
|
Convert language_data::string_lower_bound member variable to a virtual
method language_defn::string_lower_bound.
Over all of the languages we currently support there are currently
only two values for the lower bound, 0 or 1. I noticed that in all
cases, if a language has C style arrays then the lower bound is 0,
otherwise the lower bound is 1. So the default for the virtual method
in language.h makes use of this, which means languages don't have to
worry about providing a string_lower_bound method at all.
Except for Modula2. This language is defined to not have C style
arrays, but has a string_lower_bound index of 0, this behaviour is
maintained after this commit by having Modula2 be the only language
that overrides the string_lower_bound method.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove string_lower_bound
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove string_lower_bound field.
(language_defn::string_lower_bound): New member function.
* m2-lang.c (m2_language_data): Remove string_lower_bound
initializer.
(m2_language::string_lower_bound): New member function.
* objc-lang.c (objc_language_data): Remove string_lower_bound
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valops.c (value_cstring): Update call to string_lower_bound.
(value_string): Likewise.
* value.c (allocate_repeated_value): Likewise.
|
|
Convert language_data::c_style_arrays member variable to a virtual
method language_defn::c_style_arrays_p.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove c_style_arrays
initializer.
(ada_language::c_style_arrays_p): New member fuction.
* c-lang.c (c_language_data): Remove c_style_arrays
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* eval.c (ptrmath_type_p): Update call to c_style_arrays_p.
* f-lang.c (f_language_data): Remove c_style_arrays initializer.
(f_language::c_style_arrays_p): New member function.
* go-lang.c (go_language_data): Remove c_style_arrays initializer.
* infcall.c (value_arg_coerce): Update call to c_style_arrays_p.
* language.c (unknown_language_data): Remove c_style_arrays
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove c_style_arrays field.
(language_defn::c_style_arrays_p): New member function.
* m2-lang.c (m2_language_data): Remove c_style_arrays initializer.
(m2_language::c_style_arrays_p): New member function.
* objc-lang.c (objc_language_data): Remove c_style_arrays
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valarith.c (value_subscript): Update call to c_style_arrays_p,
and update local variable to a bool.
* valops.c (value_cast): Update call to c_style_arrays_p.
(value_array): Likewise.
* value.c (coerce_array): Likewise.
|
|
Move the language_data::la_language member variable into the
langage_defn class.
I have not made the la_language member variable a method of
langage_defn simply because of the large number of places that
la_language is referenced throughout GDB. I have made the new member
variable constant though, so this should prevent accidental
assignment.
In the future we might consider converting la_language to a method,
but right now my goal is to remove the langage_data class, so I'm
happy to leave la_language as a constant member variable.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_language initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_language field.
(language_defn::language_defn): Initialise la_language field.
(language_defn::la_language): New member variable.
* m2-lang.c (m2_language_data): Remove la_language field.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
|
|
Convert language_data::la_filename_extensions member variable to a
virtual method language_defn::filename_extensions.
The new method returns a vector of filename extensions, which means
that where previously we needed a NULL marker on the end of the list,
we can now discard this.
All of the old arrays that contained the extensions now become static
data within each languages filename_extensions method.
I've updated the single use of the filename_extensions method to make
use of this method returning a vector. And, just in case anyone
accidentally adds a NULL marked into a languages extensions list, I've
added a new assert in add_filename_language (symtab.c) to catch this.
gdb/ChangeLog:
* ada-lang.c (ada_extensions): Delete, moved into
ada_language::filename_extensions.
(ada_language_data): Remove la_filename_extensions initializer.
(ada_language::filename_extensions): New member function.
* c-lang.c (c_extensions): Delete, moved into
c_language::filename_extensions.
(c_language_data): Remove la_filename_extensions initializer.
(c_language::filename_extensions): New member function.
(cplus_extensions): Delete, moved into
cplus_language::filename_extensions.
(cplus_language_data): Remove la_filename_extensions initializer.
(cplus_language::filename_extensions): New member function.
(asm_extensions): Delete, moved into
asm_language::filename_extensions.
(asm_language_data): Remove la_filename_extensions initializer.
(asm_language::filename_extensions): New member function.
(minimal_language_data): Remove la_filename_extensions
initializer.
* d-lang.c (d_extensions): Delete, moved into
d_language::filename_extensions.
(d_language_data): Remove la_filename_extensions initializer.
(d_language::filename_extensions): New member function.
* f-lang.c (f_extensions): Delete, moved into
f_language::filename_extensions.
(f_language_data): Remove la_filename_extensions initializer.
(f_language::filename_extensions): New member function.
* go-lang.c (go_language_data): Remove la_filename_extensions
initializer.
* language.c (add_set_language_command): Update now that
filename_extensions returns a vector.
(unknown_language_data): Remove la_filename_extensions
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Remove la_filename_extensions field.
(language_defn::filename_extensions): New member function.
* m2-lang.c (m2_language_data): Remove la_filename_extensions
initializer.
* objc-lang.c (objc_extensions): Delete, moved into
objc_language::filename_extensions.
(objc_language_data): Remove la_filename_extensions initializer.
(objc_language::filename_extensions): New member function.
* opencl-lang.c (opencl_language_data): Remove
la_filename_extensions initializer.
* p-lang.c (pascal_extensions): Delete, moved into
pascal_language::filename_extensions.
(pascal_language_data): Remove la_filename_extensions initializer.
(pascal_language::filename_extensions): New member function.
* rust-lang.c (rust_extensions): Delete, moved into
rust_language::filename_extensions.
(rust_language_data): Remove la_filename_extensions initializer.
(rust_language::filename_extensions): New member function.
* symfile.c (add_filename_language): Add new assert.
|
|
Convert the two language_data member variables la_name and
la_natural_name to virtual methods in language_defn struct called name
and natural_name respectively.
The virtual methods in the language_defn base class are pure virtual,
as every language must implement these, and as every language has a
unique name there's no sensible default here.
Given that every language must implement these methods I did wonder
about making this data passed into the base class constructor, but in
the end I went with the virtual method approach. I'm open to changing
this approach if people prefer the constructor approach.
During updating the calls to language_defn::name I found in
add_set_language_command a place where we took la_name and then
capitalised the first letter to create a language name that could be
used in the documentation string. I replaced this with a use of
natural_name instead as this seemed a better choice, in most cases
this will make no difference, as for most languages the natural_name
is just the name with the first character in upper case, but for some
languages, for example 'Open-CL' and 'Objective-C' this is not the
case.
In the case of asm_language the name is 'asm', while the natural_name
was previously 'assembly'. I changed the natural name to 'Assembly',
this makes the documentation string case above cleaner, however, this
will change the MI output for -var-info-expression, where the 'lang'
field will change from 'assembly' to 'Assembly'. It is possible this
could be a breaking change if a front-end is relying on the existing
name.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Remove la_name and
la_natural_name initializers.
(ada_language::name): New member function.
(ada_language::natural_name): New member function.
* c-lang.c (c_language_data): Remove la_name and
la_natural_name initializers.
(c_language::name): New member function.
(c_language::natural_name): New member function.
(cplus_language_data): Remove la_name and
la_natural_name initializers.
(cplus_language::name): New member function.
(cplus_language::natural_name): New member function.
(asm_language_data): Remove la_name and
la_natural_name initializers.
(asm_language::name): New member function.
(asm_language::natural_name): New member function.
(minimal_language_data): Remove la_name and
la_natural_name initializers.
(minimal_language::name): New member function.
(minimal_language::natural_name): New member function.
* compile/compile.c (compile_to_object): Update call to
lanugage_defn::name.
* d-lang.c (d_language_data): Remove la_name and
la_natural_name initializers.
(d_language::name): New member function.
(d_language::natural_name): New member function.
* expprint.c (print_subexp_standard): Update call to
language_defn::name.
(dump_raw_expression): Likewise
(dump_prefix_expression): Likewise.
* f-lang.c (f_language_data): Remove la_name and
la_natural_name initializers.
(f_language::name): New member function.
(f_language::natural_name): New member function.
* go-lang.c (go_language_data): Remove la_name and
la_natural_name initializers.
(go_language::name): New member function.
(go_language::natural_name): New member function.
* language.c (show_language_command): Update call to
language_defn::name.
(set_language_command): Likewise.
(language_enum): Likewise.
(language_str): Likewise.
(add_set_language_command): Likewise, use
language_defn::natural_name in the doc string.
(unknown_language_data): Remove la_name and
la_natural_name initializers.
(unknown_language::name): New member function.
(unknown_language::natural_name): New member function.
(auto_language_data): Remove la_name and
la_natural_name initializers.
(auto_language::name): New member function.
(auto_language::natural_name): New member function.
(language_lookup_primitive_type_as_symbol): Update call to
language_defn::name.
* language.h (language_data): Remove la_name and la_natural_name
member variables.
(language_defn::name): New member function.
(language_defn::natural_name): New member function.
* m2-lang.c (m2_language_data): Remove la_name and
la_natural_name initializers.
(m2_language::name): New member function.
(m2_language::natural_name): New member function.
* mi/mi-cmd-var.c (mi_cmd_var_info_expression): Update call to
language_defn::natural_name.
* objc-lang.c (objc_language_data): Remove la_name and
la_natural_name initializers.
(objc_language::name): New member function.
(objc_language::natural_name): New member function.
* opencl-lang.c (opencl_language_data): Remove la_name and
la_natural_name initializers.
(opencl_language::name): New member function.
(opencl_language::natural_name): New member function.
* p-lang.c (pascal_language_data): Remove la_name and
la_natural_name initializers.
(pascal_language::name): New member function.
(pascal_language::natural_name): New member function.
* rust-lang.c (rust_language_data): Remove la_name and
la_natural_name initializers.
(rust_language::name): New member function.
(rust_language::natural_name): New member function.
* symtab.c (lookup_language_this): Update call to
language_defn::name.
|