2010-11-05 22:31:30 +08:00
|
|
|
/* OpenCL language support for GDB, the GNU debugger.
|
2020-01-01 14:20:01 +08:00
|
|
|
Copyright (C) 2010-2020 Free Software Foundation, Inc.
|
2010-11-05 22:31:30 +08:00
|
|
|
|
|
|
|
Contributed by Ken Werner <ken.werner@de.ibm.com>.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
#include "symtab.h"
|
|
|
|
#include "expression.h"
|
|
|
|
#include "parser-defs.h"
|
|
|
|
#include "language.h"
|
2013-10-17 21:15:21 +08:00
|
|
|
#include "varobj.h"
|
2010-11-05 22:31:30 +08:00
|
|
|
#include "c-lang.h"
|
Don't include gdbarch.h from defs.h
I touched symtab.h and was surprised to see how many files were
rebuilt. I looked into it a bit, and found that defs.h includes
gdbarch.h, which in turn includes many things.
gdbarch.h is only needed by a minority ofthe files in gdb, so this
patch removes the include from defs.h and updates the fallout.
I did "wc -l" on the files in build/gdb/.deps; this patch reduces the
line count from 139935 to 137030; so there are definitely future
build-time savings here.
Note that while I configured with --enable-targets=all, it's possible
that some *-nat.c file needs an update. I could not test all of
these. The buildbot caught a few problems along these lines.
gdb/ChangeLog
2019-07-10 Tom Tromey <tom@tromey.com>
* defs.h: Don't include gdbarch.h.
* aarch64-ravenscar-thread.c, aarch64-tdep.c, alpha-bsd-tdep.h,
alpha-linux-tdep.c, alpha-mdebug-tdep.c, arch-utils.h, arm-tdep.h,
ax-general.c, btrace.c, buildsym-legacy.c, buildsym.h, c-lang.c,
cli/cli-decode.h, cli/cli-dump.c, cli/cli-script.h,
cli/cli-style.h, coff-pe-read.h, compile/compile-c-support.c,
compile/compile-cplus.h, compile/compile-loc2c.c, corefile.c,
cp-valprint.c, cris-linux-tdep.c, ctf.c, d-lang.c, d-namespace.c,
dcache.c, dicos-tdep.c, dictionary.c, disasm-selftests.c,
dummy-frame.c, dummy-frame.h, dwarf2-frame-tailcall.c,
dwarf2expr.c, expression.h, f-lang.c, frame-base.c,
frame-unwind.c, frv-linux-tdep.c, gdbarch-selftests.c, gdbtypes.h,
go-lang.c, hppa-nbsd-tdep.c, hppa-obsd-tdep.c, i386-dicos-tdep.c,
i386-tdep.h, ia64-vms-tdep.c, interps.h, language.c,
linux-record.c, location.h, m2-lang.c, m32r-linux-tdep.c,
mem-break.c, memattr.c, mn10300-linux-tdep.c, nios2-linux-tdep.c,
objfiles.h, opencl-lang.c, or1k-linux-tdep.c, p-lang.c,
parser-defs.h, ppc-tdep.h, probe.h, python/py-record-btrace.c,
record-btrace.c, record.h, regcache-dump.c, regcache.h,
riscv-fbsd-tdep.c, riscv-linux-tdep.c, rust-exp.y,
sh-linux-tdep.c, sh-nbsd-tdep.c, source-cache.c,
sparc-nbsd-tdep.c, sparc-obsd-tdep.c, sparc-ravenscar-thread.c,
sparc64-fbsd-tdep.c, std-regs.c, target-descriptions.h,
target-float.c, tic6x-linux-tdep.c, tilegx-linux-tdep.c, top.c,
tracefile.c, trad-frame.c, type-stack.h, ui-style.c, utils.c,
utils.h, valarith.c, valprint.c, varobj.c, x86-tdep.c,
xml-support.h, xtensa-linux-tdep.c, cli/cli-cmds.h: Update.
* s390-linux-nat.c, procfs.c, inf-ptrace.c: Likewise.
2019-06-10 05:21:02 +08:00
|
|
|
#include "gdbarch.h"
|
2010-11-05 22:31:30 +08:00
|
|
|
|
|
|
|
/* This macro generates enum values from a given type. */
|
|
|
|
|
|
|
|
#define OCL_P_TYPE(TYPE)\
|
|
|
|
opencl_primitive_type_##TYPE,\
|
|
|
|
opencl_primitive_type_##TYPE##2,\
|
|
|
|
opencl_primitive_type_##TYPE##3,\
|
|
|
|
opencl_primitive_type_##TYPE##4,\
|
|
|
|
opencl_primitive_type_##TYPE##8,\
|
|
|
|
opencl_primitive_type_##TYPE##16
|
|
|
|
|
|
|
|
enum opencl_primitive_types {
|
|
|
|
OCL_P_TYPE (char),
|
|
|
|
OCL_P_TYPE (uchar),
|
|
|
|
OCL_P_TYPE (short),
|
|
|
|
OCL_P_TYPE (ushort),
|
|
|
|
OCL_P_TYPE (int),
|
|
|
|
OCL_P_TYPE (uint),
|
|
|
|
OCL_P_TYPE (long),
|
|
|
|
OCL_P_TYPE (ulong),
|
|
|
|
OCL_P_TYPE (half),
|
|
|
|
OCL_P_TYPE (float),
|
|
|
|
OCL_P_TYPE (double),
|
|
|
|
opencl_primitive_type_bool,
|
|
|
|
opencl_primitive_type_unsigned_char,
|
|
|
|
opencl_primitive_type_unsigned_short,
|
|
|
|
opencl_primitive_type_unsigned_int,
|
|
|
|
opencl_primitive_type_unsigned_long,
|
|
|
|
opencl_primitive_type_size_t,
|
|
|
|
opencl_primitive_type_ptrdiff_t,
|
|
|
|
opencl_primitive_type_intptr_t,
|
|
|
|
opencl_primitive_type_uintptr_t,
|
|
|
|
opencl_primitive_type_void,
|
|
|
|
nr_opencl_primitive_types
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gdbarch_data *opencl_type_data;
|
|
|
|
|
2012-03-01 Pedro Alves <palves@redhat.com>
* amd64-linux-tdep.c (amd64_linux_record_signal): Make static.
* breakpoint.c (create_exception_master_breakpoint, trace_command)
(ftrace_command, strace_command): Make static.
* d-lang.c (_initialize_d_language): Declare.
* dwarf2expr.c (_initialize_dwarf2expr): Declare.
* dwarf2loc.c (_initialize_dwarf2loc):
* dwarf2read.c (process_psymtab_comp_unit): Make static.
* exec.c (exec_get_section_table): Make static.
* i386-linux-tdep.c (i386_linux_record_signal): Make static.
* infcmd.c (ensure_valid_thread, ensure_not_tfind_mode): Make static.
* inferior.c (remove_inferior_command, add_inferior_command)
(clone_inferior_command): Make static.
* linux-nat.c (linux_nat_thread_address_space)
(linux_nat_core_of_thread): Make static.
* linux-tdep.c (_initialize_linux_tdep): Declare.
* objc-lang.c (_initialize_objc_lang): Declare.
* opencl-lang.c (builtin_opencl_type, opencl_language_arch_info):
Make static.
(_initialize_opencl_language): Declare.
* record.c (_initialize_record): Declare.
* remote.c (demand_private_info, remote_get_tib_address)
(remote_supports_cond_tracepoints)
(remote_supports_fast_tracepoints, remote_get_tracepoint_status):
Make static.
* skip.c (_initialize_step_skip): Declare.
* symtab.c (skip_prologue_using_lineinfo): Make static.
* tracepoint.c (delete_trace_state_variable)
(trace_variable_command, delete_trace_variable_command)
(get_uploaded_tsv, find_matching_tracepoint_location)
(find_matching_tsv, create_tsv_from_upload, get_traceframe_info):
Make static.
* value.c (pack_unsigned_long): Make static.
* varobj.c (varobj_ensure_python_env): Make static.
* windows-tdep.c (_initialize_windows_tdep): Declare.
* xml-syscall.c (make_cleanup_free_syscalls_info): Make static.
2012-03-02 05:14:00 +08:00
|
|
|
static struct type **
|
2010-11-05 22:31:30 +08:00
|
|
|
builtin_opencl_type (struct gdbarch *gdbarch)
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
return (struct type **) gdbarch_data (gdbarch, opencl_type_data);
|
2010-11-05 22:31:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the corresponding OpenCL vector type from the given type code,
|
|
|
|
the length of the element type, the unsigned flag and the amount of
|
|
|
|
elements (N). */
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
lookup_opencl_vector_type (struct gdbarch *gdbarch, enum type_code code,
|
|
|
|
unsigned int el_length, unsigned int flag_unsigned,
|
|
|
|
int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned int length;
|
|
|
|
struct type *type = NULL;
|
2011-02-21 23:53:10 +08:00
|
|
|
struct type **types = builtin_opencl_type (gdbarch);
|
2010-11-05 22:31:30 +08:00
|
|
|
|
|
|
|
/* Check if n describes a valid OpenCL vector size (2, 3, 4, 8, 16). */
|
|
|
|
if (n != 2 && n != 3 && n != 4 && n != 8 && n != 16)
|
|
|
|
error (_("Invalid OpenCL vector size: %d"), n);
|
|
|
|
|
|
|
|
/* Triple vectors have the size of a quad vector. */
|
|
|
|
length = (n == 3) ? el_length * 4 : el_length * n;
|
|
|
|
|
|
|
|
for (i = 0; i < nr_opencl_primitive_types; i++)
|
|
|
|
{
|
|
|
|
LONGEST lowb, highb;
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
if (types[i]->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (types[i])
|
2010-11-05 22:31:30 +08:00
|
|
|
&& get_array_bounds (types[i], &lowb, &highb)
|
2020-05-15 01:46:38 +08:00
|
|
|
&& TYPE_TARGET_TYPE (types[i])->code () == code
|
2010-11-05 22:31:30 +08:00
|
|
|
&& TYPE_UNSIGNED (TYPE_TARGET_TYPE (types[i])) == flag_unsigned
|
|
|
|
&& TYPE_LENGTH (TYPE_TARGET_TYPE (types[i])) == el_length
|
|
|
|
&& TYPE_LENGTH (types[i]) == length
|
|
|
|
&& highb - lowb + 1 == n)
|
|
|
|
{
|
|
|
|
type = types[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns nonzero if the array ARR contains duplicates within
|
|
|
|
the first N elements. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
array_has_dups (int *arr, int n)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
for (j = i + 1; j < n; j++)
|
|
|
|
{
|
|
|
|
if (arr[i] == arr[j])
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The OpenCL component access syntax allows to create lvalues referring to
|
|
|
|
selected elements of an original OpenCL vector in arbitrary order. This
|
|
|
|
structure holds the information to describe such lvalues. */
|
|
|
|
|
|
|
|
struct lval_closure
|
|
|
|
{
|
|
|
|
/* Reference count. */
|
|
|
|
int refc;
|
|
|
|
/* The number of indices. */
|
|
|
|
int n;
|
|
|
|
/* The element indices themselves. */
|
|
|
|
int *indices;
|
|
|
|
/* A pointer to the original value. */
|
|
|
|
struct value *val;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Allocates an instance of struct lval_closure. */
|
|
|
|
|
|
|
|
static struct lval_closure *
|
|
|
|
allocate_lval_closure (int *indices, int n, struct value *val)
|
|
|
|
{
|
2013-12-29 06:31:01 +08:00
|
|
|
struct lval_closure *c = XCNEW (struct lval_closure);
|
2010-11-05 22:31:30 +08:00
|
|
|
|
|
|
|
c->refc = 1;
|
|
|
|
c->n = n;
|
replace XCALLOC with XCNEWVEC or XCNEW
This removes XCALLOC and replaces it either with XCNEWVEC, or, if the
number of elements being requested was 1, with XCNEW.
2014-01-13 Tom Tromey <tromey@redhat.com>
* defs.h (XCALLOC): Remove.
* bcache.c (bcache_xmalloc): Use XCNEW, not XCALLOC.
(print_bcache_statistics): Use XCNEWVEC, not XCALLOC.
* dwarf2loc.c (allocate_piece_closure): Likewise.
* elfread.c (elf_symfile_segments): Likewise.
(elf_symfile_segments): Likewise.
* gdbtypes.c (copy_type_recursive): Likewise.
* i386-tdep.c (i386_gdbarch_init): Use XCNEW, not XCALLOC.
* jit.c (jit_frame_sniffer): Use XCNEWVEC, not XCALLOC.
* minsyms.c (prim_record_minimal_symbol_full): Use XCNEW, not
XCALLOC.
* mt-tdep.c (mt_gdbarch_init): Likewise.
* opencl-lang.c (allocate_lval_closure): Use XCNEWVEC, not
XCALLOC.
* psymtab.c (psymbol_compare): Use XCNEW, not XCALLOC.
* regcache.c (regcache_xmalloc_1): Use XCNEWVEC, not XCALLOC.
* registry.c (registry_alloc_data): Likewise.
* rs6000-tdep.c (rs6000_gdbarch_init): Use XCNEW, not XCALLOC.
* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
* serial.c (serial_fdopen_ops): Likewise.
* solib-aix.c (solib_aix_get_section_offsets): Use XCNEWVEC, not
XCALLOC.
* spu-tdep.c (spu_gdbarch_init): Use XCNEW, not XCALLOC.
* symfile.c (default_symfile_segments): Use XCNEW and XCNEWVEC,
not XCALLOC.
2013-12-29 06:32:27 +08:00
|
|
|
c->indices = XCNEWVEC (int, n);
|
2010-11-05 22:31:30 +08:00
|
|
|
memcpy (c->indices, indices, n * sizeof (int));
|
|
|
|
value_incref (val); /* Increment the reference counter of the value. */
|
|
|
|
c->val = val;
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lval_func_read (struct value *v)
|
|
|
|
{
|
|
|
|
struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
|
|
|
|
struct type *type = check_typedef (value_type (v));
|
|
|
|
struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
|
2016-04-13 03:02:57 +08:00
|
|
|
LONGEST offset = value_offset (v);
|
|
|
|
LONGEST elsize = TYPE_LENGTH (eltype);
|
2010-11-05 22:31:30 +08:00
|
|
|
int n, i, j = 0;
|
|
|
|
LONGEST lowb = 0;
|
|
|
|
LONGEST highb = 0;
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
if (type->code () == TYPE_CODE_ARRAY
|
2010-11-05 22:31:30 +08:00
|
|
|
&& !get_array_bounds (type, &lowb, &highb))
|
|
|
|
error (_("Could not determine the vector bounds"));
|
|
|
|
|
|
|
|
/* Assume elsize aligned offset. */
|
|
|
|
gdb_assert (offset % elsize == 0);
|
|
|
|
offset /= elsize;
|
|
|
|
n = offset + highb - lowb + 1;
|
|
|
|
gdb_assert (n <= c->n);
|
|
|
|
|
|
|
|
for (i = offset; i < n; i++)
|
|
|
|
memcpy (value_contents_raw (v) + j++ * elsize,
|
|
|
|
value_contents (c->val) + c->indices[i] * elsize,
|
|
|
|
elsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lval_func_write (struct value *v, struct value *fromval)
|
|
|
|
{
|
|
|
|
struct value *mark = value_mark ();
|
|
|
|
struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
|
|
|
|
struct type *type = check_typedef (value_type (v));
|
|
|
|
struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
|
2016-04-13 03:02:57 +08:00
|
|
|
LONGEST offset = value_offset (v);
|
|
|
|
LONGEST elsize = TYPE_LENGTH (eltype);
|
2010-11-05 22:31:30 +08:00
|
|
|
int n, i, j = 0;
|
|
|
|
LONGEST lowb = 0;
|
|
|
|
LONGEST highb = 0;
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
if (type->code () == TYPE_CODE_ARRAY
|
2010-11-05 22:31:30 +08:00
|
|
|
&& !get_array_bounds (type, &lowb, &highb))
|
|
|
|
error (_("Could not determine the vector bounds"));
|
|
|
|
|
|
|
|
/* Assume elsize aligned offset. */
|
|
|
|
gdb_assert (offset % elsize == 0);
|
|
|
|
offset /= elsize;
|
|
|
|
n = offset + highb - lowb + 1;
|
|
|
|
|
|
|
|
/* Since accesses to the fourth component of a triple vector is undefined we
|
|
|
|
just skip writes to the fourth element. Imagine something like this:
|
|
|
|
int3 i3 = (int3)(0, 1, 2);
|
|
|
|
i3.hi.hi = 5;
|
|
|
|
In this case n would be 4 (offset=12/4 + 1) while c->n would be 3. */
|
|
|
|
if (n > c->n)
|
|
|
|
n = c->n;
|
|
|
|
|
|
|
|
for (i = offset; i < n; i++)
|
|
|
|
{
|
|
|
|
struct value *from_elm_val = allocate_value (eltype);
|
|
|
|
struct value *to_elm_val = value_subscript (c->val, c->indices[i]);
|
|
|
|
|
|
|
|
memcpy (value_contents_writeable (from_elm_val),
|
|
|
|
value_contents (fromval) + j++ * elsize,
|
|
|
|
elsize);
|
|
|
|
value_assign (to_elm_val, from_elm_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
value_free_to_mark (mark);
|
|
|
|
}
|
|
|
|
|
2010-11-30 05:18:16 +08:00
|
|
|
/* Return nonzero if bits in V from OFFSET and LENGTH represent a
|
|
|
|
synthetic pointer. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
lval_func_check_synthetic_pointer (const struct value *v,
|
2016-04-13 03:02:57 +08:00
|
|
|
LONGEST offset, int length)
|
2010-11-30 05:18:16 +08:00
|
|
|
{
|
|
|
|
struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
|
|
|
|
/* Size of the target type in bits. */
|
|
|
|
int elsize =
|
|
|
|
TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
|
|
|
|
int startrest = offset % elsize;
|
|
|
|
int start = offset / elsize;
|
|
|
|
int endrest = (offset + length) % elsize;
|
|
|
|
int end = (offset + length) / elsize;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (endrest)
|
|
|
|
end++;
|
|
|
|
|
|
|
|
if (end > c->n)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (i = start; i < end; i++)
|
|
|
|
{
|
2011-03-01 02:40:31 +08:00
|
|
|
int comp_offset = (i == start) ? startrest : 0;
|
|
|
|
int comp_length = (i == end) ? endrest : elsize;
|
2010-11-30 05:18:16 +08:00
|
|
|
|
|
|
|
if (!value_bits_synthetic_pointer (c->val,
|
2011-03-01 02:40:31 +08:00
|
|
|
c->indices[i] * elsize + comp_offset,
|
|
|
|
comp_length))
|
2010-11-30 05:18:16 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-11-05 22:31:30 +08:00
|
|
|
static void *
|
|
|
|
lval_func_copy_closure (const struct value *v)
|
|
|
|
{
|
|
|
|
struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
|
|
|
|
|
|
|
|
++c->refc;
|
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lval_func_free_closure (struct value *v)
|
|
|
|
{
|
|
|
|
struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
|
|
|
|
|
|
|
|
--c->refc;
|
|
|
|
|
|
|
|
if (c->refc == 0)
|
|
|
|
{
|
Introduce a gdb_ref_ptr specialization for struct value
struct value is internally reference counted and so, while it also has
some ownership rules unique to it, it makes sense to use a gdb_ref_ptr
when managing it automatically.
This patch removes the existing unique_ptr specialization in favor of
a reference-counted pointer. It also introduces two other
clarifications:
1. Rename value_free to value_decref, which I think is more in line
with what the function actually does; and
2. Change release_value to return a gdb_ref_ptr. This change allows
us to remove the confusing release_value_or_incref function,
primarily by making it much simpler to reason about the result of
release_value.
gdb/ChangeLog
2018-04-06 Tom Tromey <tom@tromey.com>
* varobj.c (varobj_clear_saved_item)
(update_dynamic_varobj_children, install_new_value, ~varobj):
Update.
* value.h (value_incref): Move declaration earlier.
(value_decref): Rename from value_free.
(struct value_ref_policy): New.
(value_ref_ptr): New typedef.
(struct value_deleter): Remove.
(gdb_value_up): Remove typedef.
(release_value): Change return type.
(release_value_or_incref): Remove.
* value.c (set_value_parent): Update.
(value_incref): Change return type.
(value_decref): Rename from value_free.
(value_free_to_mark, free_all_values, free_value_chain): Update.
(release_value): Return value_ref_ptr.
(release_value_or_incref): Remove.
(record_latest_value, set_internalvar, clear_internalvar):
Update.
* stack.c (info_frame_command): Don't call value_free.
* python/py-value.c (valpy_dealloc, valpy_new)
(value_to_value_object): Update.
* printcmd.c (do_examine): Update.
* opencl-lang.c (lval_func_free_closure): Update.
* mi/mi-main.c (register_changed_p): Don't call value_free.
* mep-tdep.c (mep_frame_prev_register): Don't call value_free.
* m88k-tdep.c (m88k_frame_prev_register): Don't call value_free.
* m68hc11-tdep.c (m68hc11_frame_prev_register): Don't call
value_free.
* guile/scm-value.c (vlscm_free_value_smob)
(vlscm_scm_from_value): Update.
* frame.c (frame_register_unwind, frame_unwind_register_signed)
(frame_unwind_register_unsigned, get_frame_register_bytes)
(put_frame_register_bytes): Don't call value_free.
* findvar.c (address_from_register): Don't call value_free.
* dwarf2read.c (dwarf2_compute_name): Don't call value_free.
* dwarf2loc.c (entry_data_value_free_closure)
(value_of_dwarf_reg_entry, free_pieced_value_closure)
(dwarf2_evaluate_loc_desc_full): Update.
* breakpoint.c (update_watchpoint, breakpoint_init_inferior)
(~bpstats, bpstats, bpstat_clear_actions, watchpoint_check)
(~watchpoint, watch_command_1)
(invalidate_bp_value_on_memory_change): Update.
* alpha-tdep.c (alpha_register_to_value): Don't call value_free.
2018-04-04 07:45:21 +08:00
|
|
|
value_decref (c->val); /* Decrement the reference counter of the value. */
|
2010-11-05 22:31:30 +08:00
|
|
|
xfree (c->indices);
|
|
|
|
xfree (c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-14 23:00:20 +08:00
|
|
|
static const struct lval_funcs opencl_value_funcs =
|
2010-11-05 22:31:30 +08:00
|
|
|
{
|
|
|
|
lval_func_read,
|
|
|
|
lval_func_write,
|
gdb/
Display @entry parameter values even for references.
* ada-valprint.c (ada_val_print_1) <TYPE_CODE_REF>: Try also
coerce_ref_if_computed.
* c-valprint.c (c_val_print) <TYPE_CODE_REF>: Likewise.
* dwarf2expr.c (dwarf_block_to_dwarf_reg_deref): New function.
(execute_stack_op) <DW_OP_GNU_entry_value>: Add -1 deref_size to the
existing push_dwarf_reg_entry_value call. Add new detection calling
dwarf_block_to_dwarf_reg_deref. Update the error message.
(ctx_no_push_dwarf_reg_entry_value): New parameter deref_size.
* dwarf2expr.h
(struct dwarf_expr_context_funcs) <push_dwarf_reg_entry_value>: Add new
parameter deref_size, describe it in the comment.
(ctx_no_push_dwarf_reg_entry_value): Add new parameter deref_size.
(dwarf_block_to_dwarf_reg_deref): New declaration.
* dwarf2loc.c (dwarf_entry_parameter_to_value): Add new parameter
deref_size, describe it in the function comment. New variables
data_src and size, fetch the alternative block accoring to DEREF_SIZE.
(dwarf_expr_push_dwarf_reg_entry_value): Add new parameter deref_size,
describe it in the function comment. Fetch the alternative block
accoring to DEREF_SIZE.
(entry_data_value_coerce_ref, entry_data_value_copy_closure)
(entry_data_value_free_closure, entry_data_value_funcs): New.
(value_of_dwarf_reg_entry): New variables checked_type, target_type,
outer_val, target_val, val and addr. Try to fetch and create also
referenced value content.
(pieced_value_funcs): NULL value for coerce_ref.
(needs_dwarf_reg_entry_value): Add new parameter deref_size.
* f-valprint.c (f_val_print) <TYPE_CODE_REF>: Try also
coerce_ref_if_computed.
* opencl-lang.c (opencl_value_funcs): NULL value for coerce_ref.
* p-valprint.c (pascal_val_print) <TYPE_CODE_REF>: Likewise.
* stack.c (read_frame_arg): Compare also dereferenced values.
* value.c (value_computed_funcs): Make the parameter v const, use
value_lval_const for it.
(value_lval_const, coerce_ref_if_computed): New function.
(coerce_ref): New variable retval. Call also coerce_ref_if_computed.
* value.h (struct lval_funcs): New field coerce_ref.
(value_computed_funcs): Make the parameter v const.
(value_lval_const, coerce_ref_if_computed): New declarations.
gdb/testsuite/
Display @entry parameter values even for references.
* gdb.arch/amd64-entry-value.cc (reference, datap, datap_input): New
functions.
(main): New variables regvar, nodatavarp, stackvar1, stackvar2. Call
reference and datap_input.
* gdb.arch/amd64-entry-value.exp (reference, breakhere_reference): New
breakpoints.
(continue to breakpoint: entry_reference: reference)
(entry_reference: bt at entry)
(continue to breakpoint: entry_reference: breakhere_reference)
(entry_reference: bt, entry_reference: ptype regparam)
(entry_reference: p regparam, entry_reference: ptype regparam@entry)
(entry_reference: p regparam@entry, entry_reference: p ®param@entry)
(entry_reference: p regcopy, entry_reference: p nodataparam)
(entry_reference: p nodataparam@entry): New tests.
2011-10-10 03:43:41 +08:00
|
|
|
NULL, /* indirect */
|
|
|
|
NULL, /* coerce_ref */
|
2010-11-30 05:18:16 +08:00
|
|
|
lval_func_check_synthetic_pointer,
|
2010-11-05 22:31:30 +08:00
|
|
|
lval_func_copy_closure,
|
|
|
|
lval_func_free_closure
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Creates a sub-vector from VAL. The elements are selected by the indices of
|
|
|
|
an array with the length of N. Supported values for NOSIDE are
|
|
|
|
EVAL_NORMAL and EVAL_AVOID_SIDE_EFFECTS. */
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
|
|
|
|
int *indices, int n)
|
|
|
|
{
|
|
|
|
struct type *type = check_typedef (value_type (val));
|
|
|
|
struct type *elm_type = TYPE_TARGET_TYPE (type);
|
|
|
|
struct value *ret;
|
|
|
|
|
|
|
|
/* Check if a single component of a vector is requested which means
|
|
|
|
the resulting type is a (primitive) scalar type. */
|
|
|
|
if (n == 1)
|
|
|
|
{
|
|
|
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
|
|
|
ret = value_zero (elm_type, not_lval);
|
|
|
|
else
|
|
|
|
ret = value_subscript (val, indices[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Multiple components of the vector are requested which means the
|
|
|
|
resulting type is a vector as well. */
|
|
|
|
struct type *dst_type =
|
2020-05-15 01:46:38 +08:00
|
|
|
lookup_opencl_vector_type (gdbarch, elm_type->code (),
|
2010-11-05 22:31:30 +08:00
|
|
|
TYPE_LENGTH (elm_type),
|
|
|
|
TYPE_UNSIGNED (elm_type), n);
|
|
|
|
|
|
|
|
if (dst_type == NULL)
|
|
|
|
dst_type = init_vector_type (elm_type, n);
|
|
|
|
|
|
|
|
make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL);
|
|
|
|
|
|
|
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
|
|
|
ret = allocate_value (dst_type);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Check whether to create a lvalue or not. */
|
|
|
|
if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n))
|
|
|
|
{
|
|
|
|
struct lval_closure *c = allocate_lval_closure (indices, n, val);
|
|
|
|
ret = allocate_computed_value (dst_type, &opencl_value_funcs, c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ret = allocate_value (dst_type);
|
|
|
|
|
|
|
|
/* Copy src val contents into the destination value. */
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
memcpy (value_contents_writeable (ret)
|
|
|
|
+ (i * TYPE_LENGTH (elm_type)),
|
|
|
|
value_contents (val)
|
|
|
|
+ (indices[i] * TYPE_LENGTH (elm_type)),
|
|
|
|
TYPE_LENGTH (elm_type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OpenCL vector component access. */
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
opencl_component_ref (struct expression *exp, struct value *val, char *comps,
|
|
|
|
enum noside noside)
|
|
|
|
{
|
|
|
|
LONGEST lowb, highb;
|
|
|
|
int src_len;
|
|
|
|
struct value *v;
|
|
|
|
int indices[16], i;
|
|
|
|
int dst_len;
|
|
|
|
|
|
|
|
if (!get_array_bounds (check_typedef (value_type (val)), &lowb, &highb))
|
|
|
|
error (_("Could not determine the vector bounds"));
|
|
|
|
|
|
|
|
src_len = highb - lowb + 1;
|
|
|
|
|
|
|
|
/* Throw an error if the amount of array elements does not fit a
|
|
|
|
valid OpenCL vector size (2, 3, 4, 8, 16). */
|
|
|
|
if (src_len != 2 && src_len != 3 && src_len != 4 && src_len != 8
|
|
|
|
&& src_len != 16)
|
|
|
|
error (_("Invalid OpenCL vector size"));
|
|
|
|
|
|
|
|
if (strcmp (comps, "lo") == 0 )
|
|
|
|
{
|
|
|
|
dst_len = (src_len == 3) ? 2 : src_len / 2;
|
|
|
|
|
|
|
|
for (i = 0; i < dst_len; i++)
|
|
|
|
indices[i] = i;
|
|
|
|
}
|
|
|
|
else if (strcmp (comps, "hi") == 0)
|
|
|
|
{
|
|
|
|
dst_len = (src_len == 3) ? 2 : src_len / 2;
|
|
|
|
|
|
|
|
for (i = 0; i < dst_len; i++)
|
|
|
|
indices[i] = dst_len + i;
|
|
|
|
}
|
|
|
|
else if (strcmp (comps, "even") == 0)
|
|
|
|
{
|
|
|
|
dst_len = (src_len == 3) ? 2 : src_len / 2;
|
|
|
|
|
|
|
|
for (i = 0; i < dst_len; i++)
|
|
|
|
indices[i] = i*2;
|
|
|
|
}
|
|
|
|
else if (strcmp (comps, "odd") == 0)
|
|
|
|
{
|
|
|
|
dst_len = (src_len == 3) ? 2 : src_len / 2;
|
|
|
|
|
|
|
|
for (i = 0; i < dst_len; i++)
|
|
|
|
indices[i] = i*2+1;
|
|
|
|
}
|
|
|
|
else if (strncasecmp (comps, "s", 1) == 0)
|
|
|
|
{
|
|
|
|
#define HEXCHAR_TO_INT(C) ((C >= '0' && C <= '9') ? \
|
|
|
|
C-'0' : ((C >= 'A' && C <= 'F') ? \
|
|
|
|
C-'A'+10 : ((C >= 'a' && C <= 'f') ? \
|
|
|
|
C-'a'+10 : -1)))
|
|
|
|
|
|
|
|
dst_len = strlen (comps);
|
|
|
|
/* Skip the s/S-prefix. */
|
|
|
|
dst_len--;
|
|
|
|
|
|
|
|
for (i = 0; i < dst_len; i++)
|
|
|
|
{
|
|
|
|
indices[i] = HEXCHAR_TO_INT(comps[i+1]);
|
|
|
|
/* Check if the requested component is invalid or exceeds
|
|
|
|
the vector. */
|
|
|
|
if (indices[i] < 0 || indices[i] >= src_len)
|
|
|
|
error (_("Invalid OpenCL vector component accessor %s"), comps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dst_len = strlen (comps);
|
|
|
|
|
|
|
|
for (i = 0; i < dst_len; i++)
|
|
|
|
{
|
|
|
|
/* x, y, z, w */
|
|
|
|
switch (comps[i])
|
|
|
|
{
|
|
|
|
case 'x':
|
|
|
|
indices[i] = 0;
|
|
|
|
break;
|
|
|
|
case 'y':
|
|
|
|
indices[i] = 1;
|
|
|
|
break;
|
|
|
|
case 'z':
|
|
|
|
if (src_len < 3)
|
|
|
|
error (_("Invalid OpenCL vector component accessor %s"), comps);
|
|
|
|
indices[i] = 2;
|
|
|
|
break;
|
|
|
|
case 'w':
|
|
|
|
if (src_len < 4)
|
|
|
|
error (_("Invalid OpenCL vector component accessor %s"), comps);
|
|
|
|
indices[i] = 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error (_("Invalid OpenCL vector component accessor %s"), comps);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Throw an error if the amount of requested components does not
|
|
|
|
result in a valid length (1, 2, 3, 4, 8, 16). */
|
|
|
|
if (dst_len != 1 && dst_len != 2 && dst_len != 3 && dst_len != 4
|
|
|
|
&& dst_len != 8 && dst_len != 16)
|
|
|
|
error (_("Invalid OpenCL vector component accessor %s"), comps);
|
|
|
|
|
|
|
|
v = create_value (exp->gdbarch, val, noside, indices, dst_len);
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform the unary logical not (!) operation. */
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
opencl_logical_not (struct expression *exp, struct value *arg)
|
|
|
|
{
|
|
|
|
struct type *type = check_typedef (value_type (arg));
|
|
|
|
struct type *rettype;
|
|
|
|
struct value *ret;
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
if (type->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type))
|
2010-11-05 22:31:30 +08:00
|
|
|
{
|
|
|
|
struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
|
|
|
|
LONGEST lowb, highb;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!get_array_bounds (type, &lowb, &highb))
|
|
|
|
error (_("Could not determine the vector bounds"));
|
|
|
|
|
|
|
|
/* Determine the resulting type of the operation and allocate the
|
|
|
|
value. */
|
|
|
|
rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
|
|
|
|
TYPE_LENGTH (eltype), 0,
|
|
|
|
highb - lowb + 1);
|
|
|
|
ret = allocate_value (rettype);
|
|
|
|
|
|
|
|
for (i = 0; i < highb - lowb + 1; i++)
|
|
|
|
{
|
|
|
|
/* For vector types, the unary operator shall return a 0 if the
|
|
|
|
value of its operand compares unequal to 0, and -1 (i.e. all bits
|
|
|
|
set) if the value of its operand compares equal to 0. */
|
|
|
|
int tmp = value_logical_not (value_subscript (arg, i)) ? -1 : 0;
|
|
|
|
memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype),
|
|
|
|
tmp, TYPE_LENGTH (eltype));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rettype = language_bool_type (exp->language_defn, exp->gdbarch);
|
|
|
|
ret = value_from_longest (rettype, value_logical_not (arg));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform a relational operation on two scalar operands. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
scalar_relop (struct value *val1, struct value *val2, enum exp_opcode op)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
case BINOP_EQUAL:
|
|
|
|
ret = value_equal (val1, val2);
|
|
|
|
break;
|
|
|
|
case BINOP_NOTEQUAL:
|
|
|
|
ret = !value_equal (val1, val2);
|
|
|
|
break;
|
|
|
|
case BINOP_LESS:
|
|
|
|
ret = value_less (val1, val2);
|
|
|
|
break;
|
|
|
|
case BINOP_GTR:
|
|
|
|
ret = value_less (val2, val1);
|
|
|
|
break;
|
|
|
|
case BINOP_GEQ:
|
|
|
|
ret = value_less (val2, val1) || value_equal (val1, val2);
|
|
|
|
break;
|
|
|
|
case BINOP_LEQ:
|
|
|
|
ret = value_less (val1, val2) || value_equal (val1, val2);
|
|
|
|
break;
|
|
|
|
case BINOP_LOGICAL_AND:
|
|
|
|
ret = !value_logical_not (val1) && !value_logical_not (val2);
|
|
|
|
break;
|
|
|
|
case BINOP_LOGICAL_OR:
|
|
|
|
ret = !value_logical_not (val1) || !value_logical_not (val2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error (_("Attempt to perform an unsupported operation"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform a relational operation on two vector operands. */
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
vector_relop (struct expression *exp, struct value *val1, struct value *val2,
|
|
|
|
enum exp_opcode op)
|
|
|
|
{
|
|
|
|
struct value *ret;
|
|
|
|
struct type *type1, *type2, *eltype1, *eltype2, *rettype;
|
|
|
|
int t1_is_vec, t2_is_vec, i;
|
|
|
|
LONGEST lowb1, lowb2, highb1, highb2;
|
|
|
|
|
|
|
|
type1 = check_typedef (value_type (val1));
|
|
|
|
type2 = check_typedef (value_type (val2));
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
t1_is_vec = (type1->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type1));
|
|
|
|
t2_is_vec = (type2->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type2));
|
2010-11-05 22:31:30 +08:00
|
|
|
|
|
|
|
if (!t1_is_vec || !t2_is_vec)
|
|
|
|
error (_("Vector operations are not supported on scalar types"));
|
|
|
|
|
|
|
|
eltype1 = check_typedef (TYPE_TARGET_TYPE (type1));
|
|
|
|
eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
|
|
|
|
|
|
|
|
if (!get_array_bounds (type1,&lowb1, &highb1)
|
|
|
|
|| !get_array_bounds (type2, &lowb2, &highb2))
|
|
|
|
error (_("Could not determine the vector bounds"));
|
|
|
|
|
|
|
|
/* Check whether the vector types are compatible. */
|
2020-05-15 01:46:38 +08:00
|
|
|
if (eltype1->code () != eltype2->code ()
|
2010-11-05 22:31:30 +08:00
|
|
|
|| TYPE_LENGTH (eltype1) != TYPE_LENGTH (eltype2)
|
|
|
|
|| TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2)
|
|
|
|
|| lowb1 != lowb2 || highb1 != highb2)
|
|
|
|
error (_("Cannot perform operation on vectors with different types"));
|
|
|
|
|
|
|
|
/* Determine the resulting type of the operation and allocate the value. */
|
|
|
|
rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
|
|
|
|
TYPE_LENGTH (eltype1), 0,
|
|
|
|
highb1 - lowb1 + 1);
|
|
|
|
ret = allocate_value (rettype);
|
|
|
|
|
|
|
|
for (i = 0; i < highb1 - lowb1 + 1; i++)
|
|
|
|
{
|
|
|
|
/* For vector types, the relational, equality and logical operators shall
|
|
|
|
return 0 if the specified relation is false and -1 (i.e. all bits set)
|
|
|
|
if the specified relation is true. */
|
|
|
|
int tmp = scalar_relop (value_subscript (val1, i),
|
|
|
|
value_subscript (val2, i), op) ? -1 : 0;
|
|
|
|
memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype1),
|
|
|
|
tmp, TYPE_LENGTH (eltype1));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-26 01:16:43 +08:00
|
|
|
/* Perform a cast of ARG into TYPE. There's sadly a lot of duplication in
|
|
|
|
here from valops.c:value_cast, opencl is different only in the
|
|
|
|
behaviour of scalar to vector casting. As far as possibly we're going
|
|
|
|
to try and delegate back to the standard value_cast function. */
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
opencl_value_cast (struct type *type, struct value *arg)
|
|
|
|
{
|
|
|
|
if (type != value_type (arg))
|
|
|
|
{
|
|
|
|
/* Casting scalar to vector is a special case for OpenCL, scalar
|
|
|
|
is cast to element type of vector then replicated into each
|
|
|
|
element of the vector. First though, we need to work out if
|
|
|
|
this is a scalar to vector cast; code lifted from
|
|
|
|
valops.c:value_cast. */
|
|
|
|
enum type_code code1, code2;
|
|
|
|
struct type *to_type;
|
|
|
|
int scalar;
|
|
|
|
|
|
|
|
to_type = check_typedef (type);
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
code1 = to_type->code ();
|
|
|
|
code2 = check_typedef (value_type (arg))->code ();
|
2013-01-26 01:16:43 +08:00
|
|
|
|
|
|
|
if (code2 == TYPE_CODE_REF)
|
2020-05-15 01:46:38 +08:00
|
|
|
code2 = check_typedef (value_type (coerce_ref(arg)))->code ();
|
2013-01-26 01:16:43 +08:00
|
|
|
|
|
|
|
scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_BOOL
|
|
|
|
|| code2 == TYPE_CODE_CHAR || code2 == TYPE_CODE_FLT
|
|
|
|
|| code2 == TYPE_CODE_DECFLOAT || code2 == TYPE_CODE_ENUM
|
|
|
|
|| code2 == TYPE_CODE_RANGE);
|
|
|
|
|
|
|
|
if (code1 == TYPE_CODE_ARRAY && TYPE_VECTOR (to_type) && scalar)
|
|
|
|
{
|
|
|
|
struct type *eltype;
|
|
|
|
|
|
|
|
/* Cast to the element type of the vector here as
|
|
|
|
value_vector_widen will error if the scalar value is
|
|
|
|
truncated by the cast. To avoid the error, cast (and
|
|
|
|
possibly truncate) here. */
|
|
|
|
eltype = check_typedef (TYPE_TARGET_TYPE (to_type));
|
|
|
|
arg = value_cast (eltype, arg);
|
|
|
|
|
|
|
|
return value_vector_widen (arg, type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* Standard cast handler. */
|
|
|
|
arg = value_cast (type, arg);
|
|
|
|
}
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
|
2010-11-05 22:31:30 +08:00
|
|
|
/* Perform a relational operation on two operands. */
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
opencl_relop (struct expression *exp, struct value *arg1, struct value *arg2,
|
|
|
|
enum exp_opcode op)
|
|
|
|
{
|
|
|
|
struct value *val;
|
|
|
|
struct type *type1 = check_typedef (value_type (arg1));
|
|
|
|
struct type *type2 = check_typedef (value_type (arg2));
|
2020-05-15 01:46:38 +08:00
|
|
|
int t1_is_vec = (type1->code () == TYPE_CODE_ARRAY
|
2010-11-05 22:31:30 +08:00
|
|
|
&& TYPE_VECTOR (type1));
|
2020-05-15 01:46:38 +08:00
|
|
|
int t2_is_vec = (type2->code () == TYPE_CODE_ARRAY
|
2010-11-05 22:31:30 +08:00
|
|
|
&& TYPE_VECTOR (type2));
|
|
|
|
|
|
|
|
if (!t1_is_vec && !t2_is_vec)
|
|
|
|
{
|
|
|
|
int tmp = scalar_relop (arg1, arg2, op);
|
|
|
|
struct type *type =
|
|
|
|
language_bool_type (exp->language_defn, exp->gdbarch);
|
|
|
|
|
|
|
|
val = value_from_longest (type, tmp);
|
|
|
|
}
|
|
|
|
else if (t1_is_vec && t2_is_vec)
|
|
|
|
{
|
|
|
|
val = vector_relop (exp, arg1, arg2, op);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Widen the scalar operand to a vector. */
|
|
|
|
struct value **v = t1_is_vec ? &arg2 : &arg1;
|
|
|
|
struct type *t = t1_is_vec ? type2 : type1;
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
if (t->code () != TYPE_CODE_FLT && !is_integral_type (t))
|
2010-11-05 22:31:30 +08:00
|
|
|
error (_("Argument to operation not a number or boolean."));
|
|
|
|
|
2013-01-26 01:16:43 +08:00
|
|
|
*v = opencl_value_cast (t1_is_vec ? type1 : type2, *v);
|
2010-11-05 22:31:30 +08:00
|
|
|
val = vector_relop (exp, arg1, arg2, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Expression evaluator for the OpenCL. Most operations are delegated to
|
|
|
|
evaluate_subexp_standard; see that function for a description of the
|
|
|
|
arguments. */
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
|
|
|
|
int *pos, enum noside noside)
|
|
|
|
{
|
|
|
|
enum exp_opcode op = exp->elts[*pos].opcode;
|
|
|
|
struct value *arg1 = NULL;
|
|
|
|
struct value *arg2 = NULL;
|
|
|
|
struct type *type1, *type2;
|
|
|
|
|
|
|
|
switch (op)
|
|
|
|
{
|
2013-01-26 01:16:43 +08:00
|
|
|
/* Handle assignment and cast operators to support OpenCL-style
|
|
|
|
scalar-to-vector widening. */
|
|
|
|
case BINOP_ASSIGN:
|
|
|
|
(*pos)++;
|
|
|
|
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
type1 = value_type (arg1);
|
|
|
|
arg2 = evaluate_subexp (type1, exp, pos, noside);
|
|
|
|
|
|
|
|
if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
|
|
|
|
return arg1;
|
|
|
|
|
|
|
|
if (deprecated_value_modifiable (arg1)
|
|
|
|
&& VALUE_LVAL (arg1) != lval_internalvar)
|
|
|
|
arg2 = opencl_value_cast (type1, arg2);
|
|
|
|
|
|
|
|
return value_assign (arg1, arg2);
|
|
|
|
|
|
|
|
case UNOP_CAST:
|
|
|
|
type1 = exp->elts[*pos + 1].type;
|
|
|
|
(*pos) += 2;
|
|
|
|
arg1 = evaluate_subexp (type1, exp, pos, noside);
|
|
|
|
|
|
|
|
if (noside == EVAL_SKIP)
|
|
|
|
return value_from_longest (builtin_type (exp->gdbarch)->
|
|
|
|
builtin_int, 1);
|
|
|
|
|
|
|
|
return opencl_value_cast (type1, arg1);
|
|
|
|
|
|
|
|
case UNOP_CAST_TYPE:
|
|
|
|
(*pos)++;
|
|
|
|
arg1 = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
|
|
|
|
type1 = value_type (arg1);
|
|
|
|
arg1 = evaluate_subexp (type1, exp, pos, noside);
|
|
|
|
|
|
|
|
if (noside == EVAL_SKIP)
|
|
|
|
return value_from_longest (builtin_type (exp->gdbarch)->
|
|
|
|
builtin_int, 1);
|
|
|
|
|
|
|
|
return opencl_value_cast (type1, arg1);
|
|
|
|
|
2010-11-05 22:31:30 +08:00
|
|
|
/* Handle binary relational and equality operators that are either not
|
|
|
|
or differently defined for GNU vectors. */
|
|
|
|
case BINOP_EQUAL:
|
|
|
|
case BINOP_NOTEQUAL:
|
|
|
|
case BINOP_LESS:
|
|
|
|
case BINOP_GTR:
|
|
|
|
case BINOP_GEQ:
|
|
|
|
case BINOP_LEQ:
|
|
|
|
(*pos)++;
|
|
|
|
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
|
|
|
|
|
|
|
|
if (noside == EVAL_SKIP)
|
|
|
|
return value_from_longest (builtin_type (exp->gdbarch)->
|
|
|
|
builtin_int, 1);
|
|
|
|
|
|
|
|
return opencl_relop (exp, arg1, arg2, op);
|
|
|
|
|
|
|
|
/* Handle the logical unary operator not(!). */
|
|
|
|
case UNOP_LOGICAL_NOT:
|
|
|
|
(*pos)++;
|
|
|
|
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
|
|
|
|
if (noside == EVAL_SKIP)
|
|
|
|
return value_from_longest (builtin_type (exp->gdbarch)->
|
|
|
|
builtin_int, 1);
|
|
|
|
|
|
|
|
return opencl_logical_not (exp, arg1);
|
|
|
|
|
|
|
|
/* Handle the logical operator and(&&) and or(||). */
|
|
|
|
case BINOP_LOGICAL_AND:
|
|
|
|
case BINOP_LOGICAL_OR:
|
|
|
|
(*pos)++;
|
|
|
|
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
|
|
|
|
if (noside == EVAL_SKIP)
|
|
|
|
{
|
2011-03-01 06:49:57 +08:00
|
|
|
evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
2010-11-05 22:31:30 +08:00
|
|
|
|
|
|
|
return value_from_longest (builtin_type (exp->gdbarch)->
|
|
|
|
builtin_int, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* For scalar operations we need to avoid evaluating operands
|
2019-10-18 08:48:08 +08:00
|
|
|
unnecessarily. However, for vector operations we always need to
|
2010-11-05 22:31:30 +08:00
|
|
|
evaluate both operands. Unfortunately we only know which of the
|
|
|
|
two cases apply after we know the type of the second operand.
|
|
|
|
Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS. */
|
|
|
|
int oldpos = *pos;
|
|
|
|
|
2011-01-11 04:38:51 +08:00
|
|
|
arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
|
|
|
|
EVAL_AVOID_SIDE_EFFECTS);
|
2010-11-05 22:31:30 +08:00
|
|
|
*pos = oldpos;
|
|
|
|
type1 = check_typedef (value_type (arg1));
|
|
|
|
type2 = check_typedef (value_type (arg2));
|
|
|
|
|
2020-05-15 01:46:38 +08:00
|
|
|
if ((type1->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
|
|
|
|
|| (type2->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type2)))
|
2010-11-05 22:31:30 +08:00
|
|
|
{
|
|
|
|
arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
|
|
|
|
return opencl_relop (exp, arg1, arg2, op);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* For scalar built-in types, only evaluate the right
|
|
|
|
hand operand if the left hand operand compares
|
|
|
|
unequal(&&)/equal(||) to 0. */
|
|
|
|
int res;
|
|
|
|
int tmp = value_logical_not (arg1);
|
|
|
|
|
|
|
|
if (op == BINOP_LOGICAL_OR)
|
|
|
|
tmp = !tmp;
|
|
|
|
|
|
|
|
arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
|
|
|
|
tmp ? EVAL_SKIP : noside);
|
|
|
|
type1 = language_bool_type (exp->language_defn, exp->gdbarch);
|
|
|
|
|
|
|
|
if (op == BINOP_LOGICAL_AND)
|
|
|
|
res = !tmp && !value_logical_not (arg2);
|
|
|
|
else /* BINOP_LOGICAL_OR */
|
|
|
|
res = tmp || !value_logical_not (arg2);
|
|
|
|
|
|
|
|
return value_from_longest (type1, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the ternary selection operator. */
|
|
|
|
case TERNOP_COND:
|
|
|
|
(*pos)++;
|
|
|
|
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
type1 = check_typedef (value_type (arg1));
|
2020-05-15 01:46:38 +08:00
|
|
|
if (type1->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
|
2010-11-05 22:31:30 +08:00
|
|
|
{
|
|
|
|
struct value *arg3, *tmp, *ret;
|
|
|
|
struct type *eltype2, *type3, *eltype3;
|
|
|
|
int t2_is_vec, t3_is_vec, i;
|
|
|
|
LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3;
|
|
|
|
|
|
|
|
arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
arg3 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
type2 = check_typedef (value_type (arg2));
|
|
|
|
type3 = check_typedef (value_type (arg3));
|
|
|
|
t2_is_vec
|
2020-05-15 01:46:38 +08:00
|
|
|
= type2->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type2);
|
2010-11-05 22:31:30 +08:00
|
|
|
t3_is_vec
|
2020-05-15 01:46:38 +08:00
|
|
|
= type3->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type3);
|
2010-11-05 22:31:30 +08:00
|
|
|
|
|
|
|
/* Widen the scalar operand to a vector if necessary. */
|
|
|
|
if (t2_is_vec || !t3_is_vec)
|
|
|
|
{
|
2013-01-26 01:16:43 +08:00
|
|
|
arg3 = opencl_value_cast (type2, arg3);
|
2010-11-05 22:31:30 +08:00
|
|
|
type3 = value_type (arg3);
|
|
|
|
}
|
|
|
|
else if (!t2_is_vec || t3_is_vec)
|
|
|
|
{
|
2013-01-26 01:16:43 +08:00
|
|
|
arg2 = opencl_value_cast (type3, arg2);
|
2010-11-05 22:31:30 +08:00
|
|
|
type2 = value_type (arg2);
|
|
|
|
}
|
|
|
|
else if (!t2_is_vec || !t3_is_vec)
|
|
|
|
{
|
|
|
|
/* Throw an error if arg2 or arg3 aren't vectors. */
|
|
|
|
error (_("\
|
|
|
|
Cannot perform conditional operation on incompatible types"));
|
|
|
|
}
|
|
|
|
|
|
|
|
eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
|
|
|
|
eltype3 = check_typedef (TYPE_TARGET_TYPE (type3));
|
|
|
|
|
|
|
|
if (!get_array_bounds (type1, &lowb1, &highb1)
|
|
|
|
|| !get_array_bounds (type2, &lowb2, &highb2)
|
|
|
|
|| !get_array_bounds (type3, &lowb3, &highb3))
|
|
|
|
error (_("Could not determine the vector bounds"));
|
|
|
|
|
|
|
|
/* Throw an error if the types of arg2 or arg3 are incompatible. */
|
2020-05-15 01:46:38 +08:00
|
|
|
if (eltype2->code () != eltype3->code ()
|
2010-11-05 22:31:30 +08:00
|
|
|
|| TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3)
|
|
|
|
|| TYPE_UNSIGNED (eltype2) != TYPE_UNSIGNED (eltype3)
|
|
|
|
|| lowb2 != lowb3 || highb2 != highb3)
|
|
|
|
error (_("\
|
|
|
|
Cannot perform operation on vectors with different types"));
|
|
|
|
|
|
|
|
/* Throw an error if the sizes of arg1 and arg2/arg3 differ. */
|
|
|
|
if (lowb1 != lowb2 || lowb1 != lowb3
|
|
|
|
|| highb1 != highb2 || highb1 != highb3)
|
|
|
|
error (_("\
|
|
|
|
Cannot perform conditional operation on vectors with different sizes"));
|
|
|
|
|
|
|
|
ret = allocate_value (type2);
|
|
|
|
|
|
|
|
for (i = 0; i < highb1 - lowb1 + 1; i++)
|
|
|
|
{
|
|
|
|
tmp = value_logical_not (value_subscript (arg1, i)) ?
|
|
|
|
value_subscript (arg3, i) : value_subscript (arg2, i);
|
|
|
|
memcpy (value_contents_writeable (ret) +
|
|
|
|
i * TYPE_LENGTH (eltype2), value_contents_all (tmp),
|
|
|
|
TYPE_LENGTH (eltype2));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (value_logical_not (arg1))
|
|
|
|
{
|
|
|
|
/* Skip the second operand. */
|
|
|
|
evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
|
|
|
|
|
|
|
|
return evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Skip the third operand. */
|
|
|
|
arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
|
|
|
|
|
|
|
|
return arg2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle STRUCTOP_STRUCT to allow component access on OpenCL vectors. */
|
|
|
|
case STRUCTOP_STRUCT:
|
|
|
|
{
|
|
|
|
int pc = (*pos)++;
|
|
|
|
int tem = longest_to_int (exp->elts[pc + 1].longconst);
|
|
|
|
|
|
|
|
(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
|
|
|
|
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
|
|
|
|
type1 = check_typedef (value_type (arg1));
|
|
|
|
|
|
|
|
if (noside == EVAL_SKIP)
|
|
|
|
{
|
|
|
|
return value_from_longest (builtin_type (exp->gdbarch)->
|
|
|
|
builtin_int, 1);
|
|
|
|
}
|
2020-05-15 01:46:38 +08:00
|
|
|
else if (type1->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
|
2010-11-05 22:31:30 +08:00
|
|
|
{
|
|
|
|
return opencl_component_ref (exp, arg1, &exp->elts[pc + 2].string,
|
|
|
|
noside);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-14 00:51:52 +08:00
|
|
|
struct value *v = value_struct_elt (&arg1, NULL,
|
|
|
|
&exp->elts[pc + 2].string, NULL,
|
|
|
|
"structure");
|
|
|
|
|
|
|
|
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
2016-05-24 23:53:58 +08:00
|
|
|
v = value_zero (value_type (v), VALUE_LVAL (v));
|
2013-05-14 00:51:52 +08:00
|
|
|
return v;
|
2010-11-05 22:31:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return evaluate_subexp_c (expect_type, exp, pos, noside);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct exp_descriptor exp_descriptor_opencl =
|
|
|
|
{
|
|
|
|
print_subexp_standard,
|
|
|
|
operator_length_standard,
|
|
|
|
operator_check_standard,
|
|
|
|
op_name_standard,
|
|
|
|
dump_subexp_body_standard,
|
|
|
|
evaluate_subexp_opencl
|
|
|
|
};
|
|
|
|
|
gdb: Represent all languages as sub-classes of language_defn
This commit converts all languages to sub-classes of a language_defn
base class.
The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures. In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.
This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.
The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:
struct language_data
{
... old language_defn fields here ...
};
struct language_defn : public language_data
{
language_defn (const language_data d)
: language_data (d)
{ .... }
};
Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:
language_data ada_language_data =
{
... old ada_language_defn values here ...
};
struct ada_language : public language_defn
{
ada_language (ada_language_data)
{ .... }
};
What this means is that immediately after the conversion nothing much
changes. Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.
In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.
At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.
I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.
Most of the changes in the *-lang.c files are identical.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* gdb/ada-lang.c (ada_language_defn): Convert to...
(ada_language_data): ...this.
(class ada_language): New class.
(ada_language_defn): New static global.
* gdb/c-lang.c (c_language_defn): Convert to...
(c_language_data): ...this.
(class c_language): New class.
(c_language_defn): New static global.
(cplus_language_defn): Convert to...
(cplus_language_data): ...this.
(class cplus_language): New class.
(cplus_language_defn): New static global.
(asm_language_defn): Convert to...
(asm_language_data): ...this.
(class asm_language): New class.
(asm_language_defn): New static global.
(minimal_language_defn): Convert to...
(minimal_language_data): ...this.
(class minimal_language): New class.
(minimal_language_defn): New static global.
* gdb/d-lang.c (d_language_defn): Convert to...
(d_language_data): ...this.
(class d_language): New class.
(d_language_defn): New static global.
* gdb/f-lang.c (f_language_defn): Convert to...
(f_language_data): ...this.
(class f_language): New class.
(f_language_defn): New static global.
* gdb/go-lang.c (go_language_defn): Convert to...
(go_language_data): ...this.
(class go_language): New class.
(go_language_defn): New static global.
* gdb/language.c (unknown_language_defn): Remove declaration.
(current_language): Initialize to nullptr, real initialization is
moved to _initialize_language.
(languages): Delete global.
(language_defn::languages): Define.
(set_language_command): Use language_defn::languages.
(set_language): Likewise.
(range_error): Likewise.
(language_enum): Likewise.
(language_def): Likewise.
(add_set_language_command): Use language_def::languages for the
language list, and language_def to lookup language pointers.
(skip_language_trampoline): Use language_defn::languages.
(unknown_language_defn): Convert to...
(unknown_language_data): ...this.
(class unknown_language): New class.
(unknown_language_defn): New static global.
(auto_language_defn): Convert to...
(auto_language_data): ...this.
(class auto_language): New class.
(auto_language_defn): New static global.
(language_gdbarch_post_init): Use language_defn::languages.
(_initialize_language): Initialize current_language.
* gdb/language.h (struct language_defn): Rename to...
(struct language_data): ...this.
(struct language_defn): New.
(auto_language_defn): Delete.
(unknown_language_defn): Delete.
(minimal_language_defn): Delete.
(ada_language_defn): Delete.
(asm_language_defn): Delete.
(c_language_defn): Delete.
(cplus_language_defn): Delete.
(d_language_defn): Delete.
(f_language_defn): Delete.
(go_language_defn): Delete.
(m2_language_defn): Delete.
(objc_language_defn): Delete.
(opencl_language_defn): Delete.
(pascal_language_defn): Delete.
(rust_language_defn): Delete.
* gdb/m2-lang.c (m2_language_defn): Convert to...
(m2_language_data): ...this.
(class m2_language): New class.
(m2_language_defn): New static global.
* gdb/objc-lang.c (objc_language_defn): Convert to...
(objc_language_data): ...this.
(class objc_language): New class.
(objc_language_defn): New static global.
* gdb/opencl-lang.c (opencl_language_defn): Convert to...
(opencl_language_data): ...this.
(class opencl_language): New class.
(opencl_language_defn): New static global.
* gdb/p-lang.c (pascal_language_defn): Convert to...
(pascal_language_data): ...this.
(class pascal_language): New class.
(pascal_language_defn): New static global.
* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
language pointer, update comment format.
* gdb/rust-lang.c (rust_language_defn): Convert to...
(rust_language_data): ...this.
(class rust_language): New class.
(rust_language_defn): New static global.
2020-05-01 19:16:58 +08:00
|
|
|
/* Constant data representing the OpenCL language. */
|
|
|
|
extern const struct language_data opencl_language_data =
|
2010-11-05 22:31:30 +08:00
|
|
|
{
|
|
|
|
"opencl", /* Language name */
|
2013-10-26 16:00:11 +08:00
|
|
|
"OpenCL C",
|
2010-11-05 22:31:30 +08:00
|
|
|
language_opencl,
|
|
|
|
range_check_off,
|
|
|
|
case_sensitive_on,
|
|
|
|
array_row_major,
|
|
|
|
macro_expansion_c,
|
2016-05-27 00:33:28 +08:00
|
|
|
NULL,
|
2010-11-05 22:31:30 +08:00
|
|
|
&exp_descriptor_opencl,
|
|
|
|
c_parse,
|
|
|
|
null_post_parser,
|
|
|
|
c_printchar, /* Print a character constant */
|
|
|
|
c_printstr, /* Function to print string constant */
|
|
|
|
c_emit_char, /* Print a single char */
|
|
|
|
c_print_typedef, /* Print a typedef using appropriate syntax */
|
|
|
|
NULL, /* name_of_this */
|
problem looking up some symbols when they have a linkage name
This patch fixes a known failure in gdb.ada/maint_with_ada.exp
(maintenance check-psymtabs). Another way to witness the same
issue is by considering the following Ada declarations...
type Wrapper is record
A : Integer;
end record;
u00045 : constant Wrapper := (A => 16#060287af#);
pragma Export (C, u00045, "symada__cS");
... which declares a variable name "u00045" but with a linkage
name which is "symada__cS". This variable is a record with one
component, the Ada equivalent of a struct with one field in C.
Trying to print that variable's value currently yields:
(gdb) p /x <symada__cS>
'symada(char, signed)' has unknown type; cast it to its declared type
This indicates that GDB was only able to find the minimal symbol,
but not the full symbol. The expected output is:
(gdb) print /x <symada__cS>
$1 = (a => 0x60287af)
The error message gives a hint about what's happening: We processed
the symbol through gdb_demangle, which in the case of this particular
symbol name, ends up matching the C++ naming scheme. As a result,
the demangler transforms our symbol name into 'symada(char, signed)',
thus breaking Ada lookups.
This patch fixes the issue by first introducing a new language_defn
attribute called la_store_sym_names_in_linkage_form_p, which is a boolean
to be set to true for the few languages that do not want their symbols
to have their names stored in demangled form, and false otherwise.
We then use this language attribute to skip the call to gdb_demangle
for all languages whose la_store_sym_names_in_linkage_form_p is true.
In terms of the selection of languages for which the new attribute
is set to true, the selection errs on the side of preserving the
existing behavior, and only changes the behavior for the languages
where we are certain storing symbol names in demangling form is not
needed. It is conceivable that other languages might be in the same
situation, but I not knowing in detail the symbol name enconding
strategy, I decided to play it safe and let other language maintainers
potentially adjust their language if it makes sense to do so.
gdb/ChangeLog:
PR gdb/22670
* dwarf2read.c (dwarf2_physname): Do not return the demangled
symbol name if the CU's language stores symbol names in linkage
format.
* language.h (struct language_defn)
<la_store_sym_names_in_linkage_form_p>: New field. Adjust
all instances of this struct.
gdb/testsuite/ChangeLog:
* gdb.ada/maint_with_ada.exp: Remove PR gdb/22670 setup_kfail.
* gdb.ada/notcplusplus: New testcase.
* gdb.base/c-linkage-name.c: New file.
* gdb.base/c-linkage-name.exp: New testcase.
Tested on x86_64-linux.
This also passes AdaCore's internal GDB testsuite.
2018-03-27 21:57:16 +08:00
|
|
|
false, /* la_store_sym_names_in_linkage_form_p */
|
2010-11-05 22:31:30 +08:00
|
|
|
c_op_print_tab, /* expression operators for printing */
|
|
|
|
1, /* c-style arrays */
|
|
|
|
0, /* String lower bound */
|
2013-10-17 21:15:21 +08:00
|
|
|
&default_varobj_ops,
|
2019-04-10 06:06:41 +08:00
|
|
|
c_is_string_type_p,
|
2019-03-27 03:34:06 +08:00
|
|
|
"{...}" /* la_struct_too_deep_ellipsis */
|
2010-11-05 22:31:30 +08:00
|
|
|
};
|
|
|
|
|
gdb: Represent all languages as sub-classes of language_defn
This commit converts all languages to sub-classes of a language_defn
base class.
The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures. In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.
This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.
The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:
struct language_data
{
... old language_defn fields here ...
};
struct language_defn : public language_data
{
language_defn (const language_data d)
: language_data (d)
{ .... }
};
Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:
language_data ada_language_data =
{
... old ada_language_defn values here ...
};
struct ada_language : public language_defn
{
ada_language (ada_language_data)
{ .... }
};
What this means is that immediately after the conversion nothing much
changes. Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.
In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.
At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.
I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.
Most of the changes in the *-lang.c files are identical.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* gdb/ada-lang.c (ada_language_defn): Convert to...
(ada_language_data): ...this.
(class ada_language): New class.
(ada_language_defn): New static global.
* gdb/c-lang.c (c_language_defn): Convert to...
(c_language_data): ...this.
(class c_language): New class.
(c_language_defn): New static global.
(cplus_language_defn): Convert to...
(cplus_language_data): ...this.
(class cplus_language): New class.
(cplus_language_defn): New static global.
(asm_language_defn): Convert to...
(asm_language_data): ...this.
(class asm_language): New class.
(asm_language_defn): New static global.
(minimal_language_defn): Convert to...
(minimal_language_data): ...this.
(class minimal_language): New class.
(minimal_language_defn): New static global.
* gdb/d-lang.c (d_language_defn): Convert to...
(d_language_data): ...this.
(class d_language): New class.
(d_language_defn): New static global.
* gdb/f-lang.c (f_language_defn): Convert to...
(f_language_data): ...this.
(class f_language): New class.
(f_language_defn): New static global.
* gdb/go-lang.c (go_language_defn): Convert to...
(go_language_data): ...this.
(class go_language): New class.
(go_language_defn): New static global.
* gdb/language.c (unknown_language_defn): Remove declaration.
(current_language): Initialize to nullptr, real initialization is
moved to _initialize_language.
(languages): Delete global.
(language_defn::languages): Define.
(set_language_command): Use language_defn::languages.
(set_language): Likewise.
(range_error): Likewise.
(language_enum): Likewise.
(language_def): Likewise.
(add_set_language_command): Use language_def::languages for the
language list, and language_def to lookup language pointers.
(skip_language_trampoline): Use language_defn::languages.
(unknown_language_defn): Convert to...
(unknown_language_data): ...this.
(class unknown_language): New class.
(unknown_language_defn): New static global.
(auto_language_defn): Convert to...
(auto_language_data): ...this.
(class auto_language): New class.
(auto_language_defn): New static global.
(language_gdbarch_post_init): Use language_defn::languages.
(_initialize_language): Initialize current_language.
* gdb/language.h (struct language_defn): Rename to...
(struct language_data): ...this.
(struct language_defn): New.
(auto_language_defn): Delete.
(unknown_language_defn): Delete.
(minimal_language_defn): Delete.
(ada_language_defn): Delete.
(asm_language_defn): Delete.
(c_language_defn): Delete.
(cplus_language_defn): Delete.
(d_language_defn): Delete.
(f_language_defn): Delete.
(go_language_defn): Delete.
(m2_language_defn): Delete.
(objc_language_defn): Delete.
(opencl_language_defn): Delete.
(pascal_language_defn): Delete.
(rust_language_defn): Delete.
* gdb/m2-lang.c (m2_language_defn): Convert to...
(m2_language_data): ...this.
(class m2_language): New class.
(m2_language_defn): New static global.
* gdb/objc-lang.c (objc_language_defn): Convert to...
(objc_language_data): ...this.
(class objc_language): New class.
(objc_language_defn): New static global.
* gdb/opencl-lang.c (opencl_language_defn): Convert to...
(opencl_language_data): ...this.
(class opencl_language): New class.
(opencl_language_defn): New static global.
* gdb/p-lang.c (pascal_language_defn): Convert to...
(pascal_language_data): ...this.
(class pascal_language): New class.
(pascal_language_defn): New static global.
* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
language pointer, update comment format.
* gdb/rust-lang.c (rust_language_defn): Convert to...
(rust_language_data): ...this.
(class rust_language): New class.
(rust_language_defn): New static global.
2020-05-01 19:16:58 +08:00
|
|
|
/* Class representing the OpenCL language. */
|
|
|
|
|
|
|
|
class opencl_language : public language_defn
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
opencl_language ()
|
|
|
|
: language_defn (language_opencl, opencl_language_data)
|
|
|
|
{ /* Nothing. */ }
|
gdb: Convert language la_language_arch_info field to a method
This commit changes the language_data::la_language_arch_info function
pointer member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_arch_info): Delete function, move
implementation to...
(ada_language::language_arch_info): ...here, a new member
function.
(ada_language_data): Delete la_language_arch_info.
* c-lang.c (c_language_data): Likewise.
(c_language::language_arch_info): New member function.
(cplus_language_arch_info): Delete function, move
implementation to...
(cplus_language::language_arch_info): ...here, a new member
function.
(cplus_language_data): Delete la_language_arch_info.
(asm_language_data): Likewise.
(asm_language::language_arch_info): New member function.
(minimal_language_data): Delete la_language_arch_info.
(minimal_language::language_arch_info): New member function.
* d-lang.c (d_language_arch_info): Delete function, move
implementation to...
(d_language::language_arch_info): ...here, a new member
function.
(d_language_data): Delete la_language_arch_info.
* f-lang.c (f_language_arch_info): Delete function, move
implementation to...
(f_language::language_arch_info): ...here, a new member
function.
(f_language_data): Delete la_language_arch_info.
* go-lang.c (go_language_arch_info): Delete function, move
implementation to...
(go_language::language_arch_info): ...here, a new member
function.
(go_language_data): Delete la_language_arch_info.
* language.c (unknown_language_data): Likewise.
(unknown_language::language_arch_info): New member function.
(auto_language_data): Delete la_language_arch_info.
(auto_language::language_arch_info): New member function.
(language_gdbarch_post_init): Update call to
la_language_arch_info.
* language.h (language_data): Delete la_language_arch_info
function pointer.
(language_defn::language_arch_info): New function.
* m2-lang.c (m2_language_arch_info): Delete function, move
implementation to...
(m2_language::language_arch_info): ...here, a new member
function.
(m2_language_data): Delete la_language_arch_info.
* objc-lang.c (objc_language_arch_info): Delete function, move
implementation to...
(objc_language::language_arch_info): ...here, a new member
function.
(objc_language_data): Delete la_language_arch_info.
* opencl-lang.c (opencl_language_arch_info): Delete function, move
implementation to...
(opencl_language::language_arch_info): ...here, a new member
function.
(opencl_language_data): Delete la_language_arch_info.
* p-lang.c (pascal_language_arch_info): Delete function, move
implementation to...
(pascal_language::language_arch_info): ...here, a new member
function.
(pascal_language_data): Delete la_language_arch_info.
* rust-lang.c (rust_language_arch_info): Delete function, move
implementation to...
(rust_language::language_arch_info): ...here, a new member
function.
(rust_language_data): Delete la_language_arch_info.
2020-05-02 04:51:15 +08:00
|
|
|
|
|
|
|
/* See language.h. */
|
|
|
|
void language_arch_info (struct gdbarch *gdbarch,
|
|
|
|
struct language_arch_info *lai) const override
|
|
|
|
{
|
|
|
|
struct type **types = builtin_opencl_type (gdbarch);
|
|
|
|
|
|
|
|
/* Copy primitive types vector from gdbarch. */
|
|
|
|
lai->primitive_type_vector = types;
|
|
|
|
|
|
|
|
/* Type of elements of strings. */
|
|
|
|
lai->string_char_type = types [opencl_primitive_type_char];
|
|
|
|
|
|
|
|
/* Specifies the return type of logical and relational operations. */
|
|
|
|
lai->bool_type_symbol = "int";
|
|
|
|
lai->bool_type_default = types [opencl_primitive_type_int];
|
|
|
|
}
|
2020-05-15 01:41:39 +08:00
|
|
|
|
|
|
|
/* See language.h. */
|
|
|
|
|
|
|
|
void print_type (struct type *type, const char *varstring,
|
|
|
|
struct ui_file *stream, int show, int level,
|
|
|
|
const struct type_print_options *flags) const override
|
|
|
|
{
|
|
|
|
/* We nearly always defer to C type printing, except that vector types
|
|
|
|
are considered primitive in OpenCL, and should always be printed
|
|
|
|
using their TYPE_NAME. */
|
|
|
|
if (show > 0)
|
|
|
|
{
|
|
|
|
type = check_typedef (type);
|
|
|
|
if (type->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (type)
|
|
|
|
&& type->name () != NULL)
|
|
|
|
show = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
c_print_type (type, varstring, stream, show, level, flags);
|
|
|
|
}
|
gdb: Represent all languages as sub-classes of language_defn
This commit converts all languages to sub-classes of a language_defn
base class.
The motivation for this change is to make it easier to add new methods
onto languages without having to update all of the individual language
structures. In the future it might be possible to move more things,
like expression parsing, into the language class(es) for better
encapsulation, however I have no plans to tackle this in the short
term.
This commit sets up a strategy for transitioning from the current
language system, where each language is an instance of the
language_defn structure, to the class hierarchy system.
The plan is to rename the existing language_defn into language_data,
and make this a base class for the new language_defn class, something
like this:
struct language_data
{
... old language_defn fields here ...
};
struct language_defn : public language_data
{
language_defn (const language_data d)
: language_data (d)
{ .... }
};
Then each existing language, for example ada_language_defn can be
converted into an instance of language_data, and passed into the
constructor of a new language class, something like this:
language_data ada_language_data =
{
... old ada_language_defn values here ...
};
struct ada_language : public language_defn
{
ada_language (ada_language_data)
{ .... }
};
What this means is that immediately after the conversion nothing much
changes. Every language is now its own class, but all the old
language fields still exist and can be accessed in the same way.
In later commits I will convert function pointers from the old
language_defn structure into real class methods on language_defn, with
overrides on sub-classes where needed.
At this point I imagine that those fields of the old language_defn
structure that contained only data will probably remain as data fields
within the new language_data base structure, it is only the methods
that I plan to change initially.
I tweaked how we manage the list of languages a bit, each language is
now registered as it is created, and this resulted in a small number
of changes in language.c.
Most of the changes in the *-lang.c files are identical.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* gdb/ada-lang.c (ada_language_defn): Convert to...
(ada_language_data): ...this.
(class ada_language): New class.
(ada_language_defn): New static global.
* gdb/c-lang.c (c_language_defn): Convert to...
(c_language_data): ...this.
(class c_language): New class.
(c_language_defn): New static global.
(cplus_language_defn): Convert to...
(cplus_language_data): ...this.
(class cplus_language): New class.
(cplus_language_defn): New static global.
(asm_language_defn): Convert to...
(asm_language_data): ...this.
(class asm_language): New class.
(asm_language_defn): New static global.
(minimal_language_defn): Convert to...
(minimal_language_data): ...this.
(class minimal_language): New class.
(minimal_language_defn): New static global.
* gdb/d-lang.c (d_language_defn): Convert to...
(d_language_data): ...this.
(class d_language): New class.
(d_language_defn): New static global.
* gdb/f-lang.c (f_language_defn): Convert to...
(f_language_data): ...this.
(class f_language): New class.
(f_language_defn): New static global.
* gdb/go-lang.c (go_language_defn): Convert to...
(go_language_data): ...this.
(class go_language): New class.
(go_language_defn): New static global.
* gdb/language.c (unknown_language_defn): Remove declaration.
(current_language): Initialize to nullptr, real initialization is
moved to _initialize_language.
(languages): Delete global.
(language_defn::languages): Define.
(set_language_command): Use language_defn::languages.
(set_language): Likewise.
(range_error): Likewise.
(language_enum): Likewise.
(language_def): Likewise.
(add_set_language_command): Use language_def::languages for the
language list, and language_def to lookup language pointers.
(skip_language_trampoline): Use language_defn::languages.
(unknown_language_defn): Convert to...
(unknown_language_data): ...this.
(class unknown_language): New class.
(unknown_language_defn): New static global.
(auto_language_defn): Convert to...
(auto_language_data): ...this.
(class auto_language): New class.
(auto_language_defn): New static global.
(language_gdbarch_post_init): Use language_defn::languages.
(_initialize_language): Initialize current_language.
* gdb/language.h (struct language_defn): Rename to...
(struct language_data): ...this.
(struct language_defn): New.
(auto_language_defn): Delete.
(unknown_language_defn): Delete.
(minimal_language_defn): Delete.
(ada_language_defn): Delete.
(asm_language_defn): Delete.
(c_language_defn): Delete.
(cplus_language_defn): Delete.
(d_language_defn): Delete.
(f_language_defn): Delete.
(go_language_defn): Delete.
(m2_language_defn): Delete.
(objc_language_defn): Delete.
(opencl_language_defn): Delete.
(pascal_language_defn): Delete.
(rust_language_defn): Delete.
* gdb/m2-lang.c (m2_language_defn): Convert to...
(m2_language_data): ...this.
(class m2_language): New class.
(m2_language_defn): New static global.
* gdb/objc-lang.c (objc_language_defn): Convert to...
(objc_language_data): ...this.
(class objc_language): New class.
(objc_language_defn): New static global.
* gdb/opencl-lang.c (opencl_language_defn): Convert to...
(opencl_language_data): ...this.
(class opencl_language): New class.
(opencl_language_defn): New static global.
* gdb/p-lang.c (pascal_language_defn): Convert to...
(pascal_language_data): ...this.
(class pascal_language): New class.
(pascal_language_defn): New static global.
* gdb/rust-exp.y (rust_lex_tests): Use language_def to find
language pointer, update comment format.
* gdb/rust-lang.c (rust_language_defn): Convert to...
(rust_language_data): ...this.
(class rust_language): New class.
(rust_language_defn): New static global.
2020-05-01 19:16:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Single instance of the OpenCL language class. */
|
|
|
|
|
|
|
|
static opencl_language opencl_language_defn;
|
|
|
|
|
2010-11-05 22:31:30 +08:00
|
|
|
static void *
|
|
|
|
build_opencl_types (struct gdbarch *gdbarch)
|
|
|
|
{
|
2011-02-21 23:53:10 +08:00
|
|
|
struct type **types
|
|
|
|
= GDBARCH_OBSTACK_CALLOC (gdbarch, nr_opencl_primitive_types + 1,
|
|
|
|
struct type *);
|
2010-11-05 22:31:30 +08:00
|
|
|
|
|
|
|
/* Helper macro to create strings. */
|
2011-02-02 21:47:06 +08:00
|
|
|
#define OCL_STRING(S) #S
|
2010-11-05 22:31:30 +08:00
|
|
|
/* This macro allocates and assigns the type struct pointers
|
|
|
|
for the vector types. */
|
|
|
|
#define BUILD_OCL_VTYPES(TYPE)\
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_##TYPE##2] \
|
|
|
|
= init_vector_type (types[opencl_primitive_type_##TYPE], 2); \
|
2020-05-17 00:15:54 +08:00
|
|
|
types[opencl_primitive_type_##TYPE##2]->set_name (OCL_STRING(TYPE ## 2)); \
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_##TYPE##3] \
|
|
|
|
= init_vector_type (types[opencl_primitive_type_##TYPE], 3); \
|
2020-05-17 00:15:54 +08:00
|
|
|
types[opencl_primitive_type_##TYPE##3]->set_name (OCL_STRING(TYPE ## 3)); \
|
2011-02-21 23:53:10 +08:00
|
|
|
TYPE_LENGTH (types[opencl_primitive_type_##TYPE##3]) \
|
|
|
|
= 4 * TYPE_LENGTH (types[opencl_primitive_type_##TYPE]); \
|
|
|
|
types[opencl_primitive_type_##TYPE##4] \
|
|
|
|
= init_vector_type (types[opencl_primitive_type_##TYPE], 4); \
|
2020-05-17 00:15:54 +08:00
|
|
|
types[opencl_primitive_type_##TYPE##4]->set_name (OCL_STRING(TYPE ## 4)); \
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_##TYPE##8] \
|
|
|
|
= init_vector_type (types[opencl_primitive_type_##TYPE], 8); \
|
2020-05-17 00:15:54 +08:00
|
|
|
types[opencl_primitive_type_##TYPE##8]->set_name (OCL_STRING(TYPE ## 8)); \
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_##TYPE##16] \
|
|
|
|
= init_vector_type (types[opencl_primitive_type_##TYPE], 16); \
|
2020-05-17 00:15:54 +08:00
|
|
|
types[opencl_primitive_type_##TYPE##16]->set_name (OCL_STRING(TYPE ## 16))
|
2011-02-21 23:53:10 +08:00
|
|
|
|
|
|
|
types[opencl_primitive_type_char]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 8, 0, "char");
|
|
|
|
BUILD_OCL_VTYPES (char);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_uchar]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 8, 1, "uchar");
|
|
|
|
BUILD_OCL_VTYPES (uchar);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_short]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 16, 0, "short");
|
|
|
|
BUILD_OCL_VTYPES (short);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_ushort]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 16, 1, "ushort");
|
|
|
|
BUILD_OCL_VTYPES (ushort);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_int]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 32, 0, "int");
|
|
|
|
BUILD_OCL_VTYPES (int);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_uint]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 32, 1, "uint");
|
|
|
|
BUILD_OCL_VTYPES (uint);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_long]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 64, 0, "long");
|
|
|
|
BUILD_OCL_VTYPES (long);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_ulong]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 64, 1, "ulong");
|
|
|
|
BUILD_OCL_VTYPES (ulong);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_half]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_float_type (gdbarch, 16, "half", floatformats_ieee_half);
|
|
|
|
BUILD_OCL_VTYPES (half);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_float]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_float_type (gdbarch, 32, "float", floatformats_ieee_single);
|
|
|
|
BUILD_OCL_VTYPES (float);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_double]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_float_type (gdbarch, 64, "double", floatformats_ieee_double);
|
|
|
|
BUILD_OCL_VTYPES (double);
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_bool]
|
2011-02-16 04:10:13 +08:00
|
|
|
= arch_boolean_type (gdbarch, 8, 1, "bool");
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_unsigned_char]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 8, 1, "unsigned char");
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_unsigned_short]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 16, 1, "unsigned short");
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_unsigned_int]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 32, 1, "unsigned int");
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_unsigned_long]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, 64, 1, "unsigned long");
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_size_t]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t");
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_ptrdiff_t]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t");
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_intptr_t]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t");
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_uintptr_t]
|
2010-11-05 22:31:30 +08:00
|
|
|
= arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t");
|
2011-02-21 23:53:10 +08:00
|
|
|
types[opencl_primitive_type_void]
|
2017-09-28 01:02:00 +08:00
|
|
|
= arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
|
2010-11-05 22:31:30 +08:00
|
|
|
|
2011-02-21 23:53:10 +08:00
|
|
|
return types;
|
2010-11-05 22:31:30 +08:00
|
|
|
}
|
|
|
|
|
2020-01-14 03:01:38 +08:00
|
|
|
void _initialize_opencl_language ();
|
2010-11-05 22:31:30 +08:00
|
|
|
void
|
2020-01-14 03:01:38 +08:00
|
|
|
_initialize_opencl_language ()
|
2010-11-05 22:31:30 +08:00
|
|
|
{
|
|
|
|
opencl_type_data = gdbarch_data_register_post_init (build_opencl_types);
|
|
|
|
}
|