/* Low level packing and unpacking of values for GDB, the GNU Debugger.
- Copyright (C) 1986-2019 Free Software Foundation, Inc.
+ Copyright (C) 1986-2020 Free Software Foundation, Inc.
This file is part of GDB.
LONGEST bitsize = 0;
/* Only used for bitfields; position of start of field. For
- gdbarch_bits_big_endian=0 targets, it is the position of the LSB. For
- gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */
+ little-endian targets, it is the position of the LSB. For
+ big-endian targets, it is the position of the MSB. */
LONGEST bitpos = 0;
/* The number of references to this value. When a value is created,
/* Do nothing. */
}
-/* Clean up if an internal function's command is destroyed. */
-static void
-function_destroyer (struct cmd_list_element *self, void *ignore)
-{
- xfree ((char *) self->name);
-}
-
/* Helper function that does the work for add_internal_function. */
static struct cmd_list_element *
do_add_internal_function (const char *name, const char *doc,
internal_function_fn handler, void *cookie)
{
- struct cmd_list_element *cmd;
struct internal_function *ifn;
struct internalvar *var = lookup_internalvar (name);
ifn = create_internal_function (name, handler, cookie);
set_internalvar_function (var, ifn);
- cmd = add_cmd (xstrdup (name), no_class, function_command, (char *) doc,
- &functionlist);
- cmd->destroyer = function_destroyer;
-
- return cmd;
+ return add_cmd (name, no_class, function_command, doc, &functionlist);
}
/* See value.h. */
/* See value.h. */
void
-add_internal_function (const char *name, gdb::unique_xmalloc_ptr<char> &&doc,
+add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
+ gdb::unique_xmalloc_ptr<char> &&doc,
internal_function_fn handler, void *cookie)
{
struct cmd_list_element *cmd
- = do_add_internal_function (name, doc.get (), handler, cookie);
+ = do_add_internal_function (name.get (), doc.get (), handler, cookie);
doc.release ();
cmd->doc_allocated = 1;
+ name.release ();
+ cmd->name_allocated = 1;
}
/* Update VALUE before discarding OBJFILE. COPIED_TYPES is used to
/* Extract bits. See comment above. */
- if (gdbarch_bits_big_endian (get_type_arch (field_type)))
+ if (byte_order == BFD_ENDIAN_BIG)
lsbcount = (bytes_read * 8 - bitpos % 8 - bitsize);
else
lsbcount = (bitpos % 8);
oword = extract_unsigned_integer (addr, bytesize, byte_order);
/* Shifting for bit field depends on endianness of the target machine. */
- if (gdbarch_bits_big_endian (get_type_arch (type)))
+ if (byte_order == BFD_ENDIAN_BIG)
bitpos = bytesize * 8 - bitpos - bitsize;
oword &= ~(mask << bitpos);
return value_from_longest (builtin_type (gdbarch)->builtin_int, ret);
}
-/* Implementation of the convenience function $_cimag. Extracts the
+/* Implementation of the convenience function $_creal. Extracts the
real part from a complex number. */
static struct value *