From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Siddhesh Poyarekar <siddhesh@redhat.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: [commit] Support 64-bit constants/enums on 32-bit host [Re: [PATCH] Allow 64-bit enum values]
Date: Tue, 17 Apr 2012 13:11:00 -0000 [thread overview]
Message-ID: <20120417130833.GB15356@host2.jankratochvil.net> (raw)
In-Reply-To: <20120321100630.GA14496@spoyarek.pnq.redhat.com>
Hi Siddhesh,
On Wed, 21 Mar 2012 11:06:32 +0100, Siddhesh Poyarekar wrote:
> In the following patch, I introduce a separate
> field_location union member 'enumval' which can accept LONGEST and
> hence expand enum values to 64-bit signed values.
your testcase does not test really 64-bit values.
> +enum e { I, J = 0xffffffffU } e = J;
When I used 64-bit entries like
+enum e { I, J = 0xffffffffU, K = 0xf000000000000000ULL } e = J, f = K;
it worked on amd64 but it did not work with GDB compiled on 32-bit host.
This patch is unrelated. Testcase for 64-bit values going to post in the
thread
[PATCH] Allow 64-bit enum values
It increases memory footprint but only on 32-bit hosts compiled without
--enable-64-bit-bfd.
sizeof (struct symbol): 44 -> 48
sizeof (struct minimal_symbol): 40 -> 44
BTW why we have minimal_symbol and expand it later when it has "the same"
size? Just expanding the types would have the same effect.
In all other configuration it has no memory footprint change.
- /* The fact that this is a long not a LONGEST mainly limits the
- range of a LOC_CONST. Since LOC_CONST_BYTES exists, I'm not
- sure that is a big deal. */
- long ivalue;
+ LONGEST ivalue;
Going to check it in, probably today, if there are any concerns about those
4 added bytes.
No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu and with
-gstabs+.
Thanks,
Jan
gdb/
2012-04-17 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix 64-bit constants on 32-bit hosts.
* dwarf2read.c (read_unsigned_leb128): Change declaration return type
from unsigned long to ULONGEST.
(read_signed_leb128): Change declaration return type from long to
LONGEST.
(dwarf2_const_value_attr): Change declaration parameter value from long
to LONGEST.
(dwarf2_compute_name): Change variable value from long to LONGEST.
(read_unsigned_leb128): Change return type, variable result and some
casts from unsigned long to ULONGEST.
(read_signed_leb128): Change return type, variable result and some
casts from long to LONGEST.
(dwarf2_const_value_data, dwarf2_const_value_attr): Change parameter
value from long to LONGEST.
(dwarf2_const_value): Change variable value from long to LONGEST.
* symmisc.c (print_symbol): Change SYMBOL_VALUE format strings to use
plongest and hex_string.
* symtab.h (struct general_symbol_info): Change ivalue from long to
LONGEST, remove the comment.
* tracepoint.c (validate_actionline, collect_symbol, scope_info):
Change SYMBOL_VALUE format strings to use plongest and hex_string.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 0e211ae..d237efb 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -957,9 +957,9 @@ static char *read_indirect_string (bfd *, gdb_byte *,
const struct comp_unit_head *,
unsigned int *);
-static unsigned long read_unsigned_leb128 (bfd *, gdb_byte *, unsigned int *);
+static ULONGEST read_unsigned_leb128 (bfd *, gdb_byte *, unsigned int *);
-static long read_signed_leb128 (bfd *, gdb_byte *, unsigned int *);
+static LONGEST read_signed_leb128 (bfd *, gdb_byte *, unsigned int *);
static gdb_byte *skip_leb128 (bfd *, gdb_byte *);
@@ -1008,7 +1008,7 @@ static void dwarf2_const_value_attr (struct attribute *attr,
struct type *type,
const char *name,
struct obstack *obstack,
- struct dwarf2_cu *cu, long *value,
+ struct dwarf2_cu *cu, LONGEST *value,
gdb_byte **bytes,
struct dwarf2_locexpr_baton **baton);
@@ -5146,7 +5146,7 @@ dwarf2_compute_name (char *name, struct die_info *die, struct dwarf2_cu *cu,
for (child = die->child; child != NULL; child = child->sibling)
{
struct type *type;
- long value;
+ LONGEST value;
gdb_byte *bytes;
struct dwarf2_locexpr_baton *baton;
struct value *v;
@@ -10660,10 +10660,10 @@ read_indirect_string (bfd *abfd, gdb_byte *buf,
return read_indirect_string_at_offset (abfd, str_offset);
}
-static unsigned long
+static ULONGEST
read_unsigned_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
{
- unsigned long result;
+ ULONGEST result;
unsigned int num_read;
int i, shift;
unsigned char byte;
@@ -10677,7 +10677,7 @@ read_unsigned_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
byte = bfd_get_8 (abfd, buf);
buf++;
num_read++;
- result |= ((unsigned long)(byte & 127) << shift);
+ result |= ((ULONGEST) (byte & 127) << shift);
if ((byte & 128) == 0)
{
break;
@@ -10688,10 +10688,10 @@ read_unsigned_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
return result;
}
-static long
+static LONGEST
read_signed_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
{
- long result;
+ LONGEST result;
int i, shift, num_read;
unsigned char byte;
@@ -10704,7 +10704,7 @@ read_signed_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
byte = bfd_get_8 (abfd, buf);
buf++;
num_read++;
- result |= ((long)(byte & 127) << shift);
+ result |= ((LONGEST) (byte & 127) << shift);
shift += 7;
if ((byte & 128) == 0)
{
@@ -10712,7 +10712,7 @@ read_signed_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr)
}
}
if ((shift < 8 * sizeof (result)) && (byte & 0x40))
- result |= -(((long)1) << shift);
+ result |= -(((LONGEST) 1) << shift);
*bytes_read_ptr = num_read;
return result;
}
@@ -12037,7 +12037,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
static gdb_byte *
dwarf2_const_value_data (struct attribute *attr, struct type *type,
const char *name, struct obstack *obstack,
- struct dwarf2_cu *cu, long *value, int bits)
+ struct dwarf2_cu *cu, LONGEST *value, int bits)
{
struct objfile *objfile = cu->objfile;
enum bfd_endian byte_order = bfd_big_endian (objfile->obfd) ?
@@ -12071,7 +12071,7 @@ static void
dwarf2_const_value_attr (struct attribute *attr, struct type *type,
const char *name, struct obstack *obstack,
struct dwarf2_cu *cu,
- long *value, gdb_byte **bytes,
+ LONGEST *value, gdb_byte **bytes,
struct dwarf2_locexpr_baton **baton)
{
struct objfile *objfile = cu->objfile;
@@ -12178,7 +12178,7 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
{
struct objfile *objfile = cu->objfile;
struct comp_unit_head *cu_header = &cu->header;
- long value;
+ LONGEST value;
gdb_byte *bytes;
struct dwarf2_locexpr_baton *baton;
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index daa0b43..b0ab29b 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -509,9 +509,9 @@ print_symbol (void *args)
switch (SYMBOL_CLASS (symbol))
{
case LOC_CONST:
- fprintf_filtered (outfile, "const %ld (0x%lx)",
- SYMBOL_VALUE (symbol),
- SYMBOL_VALUE (symbol));
+ fprintf_filtered (outfile, "const %s (%s)",
+ plongest (SYMBOL_VALUE (symbol)),
+ hex_string (SYMBOL_VALUE (symbol)));
break;
case LOC_CONST_BYTES:
@@ -539,28 +539,31 @@ print_symbol (void *args)
case LOC_REGISTER:
if (SYMBOL_IS_ARGUMENT (symbol))
- fprintf_filtered (outfile, "parameter register %ld",
- SYMBOL_VALUE (symbol));
+ fprintf_filtered (outfile, "parameter register %s",
+ plongest (SYMBOL_VALUE (symbol)));
else
- fprintf_filtered (outfile, "register %ld", SYMBOL_VALUE (symbol));
+ fprintf_filtered (outfile, "register %s",
+ plongest (SYMBOL_VALUE (symbol)));
break;
case LOC_ARG:
- fprintf_filtered (outfile, "arg at offset 0x%lx",
- SYMBOL_VALUE (symbol));
+ fprintf_filtered (outfile, "arg at offset %s",
+ hex_string (SYMBOL_VALUE (symbol)));
break;
case LOC_REF_ARG:
- fprintf_filtered (outfile, "reference arg at 0x%lx", SYMBOL_VALUE (symbol));
+ fprintf_filtered (outfile, "reference arg at %s",
+ hex_string (SYMBOL_VALUE (symbol)));
break;
case LOC_REGPARM_ADDR:
- fprintf_filtered (outfile, "address parameter register %ld", SYMBOL_VALUE (symbol));
+ fprintf_filtered (outfile, "address parameter register %s",
+ plongest (SYMBOL_VALUE (symbol)));
break;
case LOC_LOCAL:
- fprintf_filtered (outfile, "local at offset 0x%lx",
- SYMBOL_VALUE (symbol));
+ fprintf_filtered (outfile, "local at offset %s",
+ hex_string (SYMBOL_VALUE (symbol)));
break;
case LOC_TYPEDEF:
diff --git a/gdb/symtab.h b/gdb/symtab.h
index d9e5f4a..6933c0c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -109,10 +109,7 @@ struct general_symbol_info
union
{
- /* The fact that this is a long not a LONGEST mainly limits the
- range of a LOC_CONST. Since LOC_CONST_BYTES exists, I'm not
- sure that is a big deal. */
- long ivalue;
+ LONGEST ivalue;
struct block *block;
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 057b441..86b6cfa 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -740,10 +740,10 @@ validate_actionline (char **line, struct breakpoint *b)
{
if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_CONST)
{
- error (_("constant `%s' (value %ld) "
+ error (_("constant `%s' (value %s) "
"will not be collected."),
SYMBOL_PRINT_NAME (exp->elts[2].symbol),
- SYMBOL_VALUE (exp->elts[2].symbol));
+ plongest (SYMBOL_VALUE (exp->elts[2].symbol)));
}
else if (SYMBOL_CLASS (exp->elts[2].symbol)
== LOC_OPTIMIZED_OUT)
@@ -980,8 +980,8 @@ collect_symbol (struct collection_list *collect,
SYMBOL_CLASS (sym));
break;
case LOC_CONST:
- printf_filtered ("constant %s (value %ld) will not be collected.\n",
- SYMBOL_PRINT_NAME (sym), SYMBOL_VALUE (sym));
+ printf_filtered ("constant %s (value %s) will not be collected.\n",
+ SYMBOL_PRINT_NAME (sym), plongest (SYMBOL_VALUE (sym)));
break;
case LOC_STATIC:
offset = SYMBOL_VALUE_ADDRESS (sym);
@@ -2623,8 +2623,9 @@ scope_info (char *args, int from_tty)
count--; /* Don't count this one. */
continue;
case LOC_CONST:
- printf_filtered ("a constant with value %ld (0x%lx)",
- SYMBOL_VALUE (sym), SYMBOL_VALUE (sym));
+ printf_filtered ("a constant with value %s (%s)",
+ plongest (SYMBOL_VALUE (sym)),
+ hex_string (SYMBOL_VALUE (sym)));
break;
case LOC_CONST_BYTES:
printf_filtered ("constant bytes: ");
@@ -2657,16 +2658,16 @@ scope_info (char *args, int from_tty)
gdbarch_register_name (gdbarch, regno));
break;
case LOC_ARG:
- printf_filtered ("an argument at stack/frame offset %ld",
- SYMBOL_VALUE (sym));
+ printf_filtered ("an argument at stack/frame offset %s",
+ plongest (SYMBOL_VALUE (sym)));
break;
case LOC_LOCAL:
- printf_filtered ("a local variable at frame offset %ld",
- SYMBOL_VALUE (sym));
+ printf_filtered ("a local variable at frame offset %s",
+ plongest (SYMBOL_VALUE (sym)));
break;
case LOC_REF_ARG:
- printf_filtered ("a reference argument at offset %ld",
- SYMBOL_VALUE (sym));
+ printf_filtered ("a reference argument at offset %s",
+ plongest (SYMBOL_VALUE (sym)));
break;
case LOC_REGPARM_ADDR:
/* Note comment at LOC_REGISTER. */
next prev parent reply other threads:[~2012-04-17 13:09 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 14:53 [PATCH] Expand bitpos to LONGEST to allow access to large offsets within a struct Siddhesh Poyarekar
2012-02-21 20:46 ` Tom Tromey
2012-02-22 7:44 ` Siddhesh Poyarekar
2012-02-29 13:55 ` Siddhesh Poyarekar
2012-02-29 13:59 ` Siddhesh Poyarekar
2012-03-01 22:45 ` Jan Kratochvil
2012-03-05 6:34 ` Siddhesh Poyarekar
2012-03-05 8:05 ` Jan Kratochvil
2012-03-21 10:06 ` [PATCH] Allow 64-bit enum values Siddhesh Poyarekar
2012-03-27 17:00 ` Jan Kratochvil
2012-03-28 4:19 ` Siddhesh Poyarekar
2012-03-30 16:15 ` Jan Kratochvil
2012-04-17 14:01 ` Jan Kratochvil
2012-04-18 2:53 ` Siddhesh Poyarekar
2012-04-18 6:58 ` [commit] " Jan Kratochvil
2012-04-18 7:06 ` [ChangeLog commit] " Jan Kratochvil
2012-04-19 16:58 ` [commit] " Ulrich Weigand
2012-04-20 4:23 ` Siddhesh Poyarekar
2012-04-20 7:50 ` [obv] Fix python-2.4 compilation compat. [Re: [commit] [PATCH] Allow 64-bit enum values] Jan Kratochvil
2012-04-20 19:00 ` Tom Tromey
2012-03-28 16:55 ` [PATCH] Allow 64-bit enum values Tom Tromey
2012-03-29 10:56 ` Siddhesh Poyarekar
2012-04-17 13:11 ` Jan Kratochvil [this message]
2012-04-17 13:16 ` [patch!] Support 64-bit constants/enums on 32-bit host [Re: [PATCH] Allow 64-bit enum values] Jan Kratochvil
2012-04-17 14:33 ` [patch] " Jan Kratochvil
2012-04-17 15:59 ` Tom Tromey
2012-04-17 15:42 ` Jan Kratochvil
2012-04-17 15:52 ` Tom Tromey
2012-04-17 14:33 ` [commit] " Tom Tromey
2012-04-17 14:55 ` Jan Kratochvil
2012-04-17 15:18 ` Tom Tromey
2012-04-17 15:32 ` Jan Kratochvil
2012-04-17 19:32 ` Jan Kratochvil
2012-04-17 20:51 ` Tom Tromey
2012-04-18 7:01 ` [real commit] " Jan Kratochvil
2012-02-21 21:39 ` [PATCH] Expand bitpos to LONGEST to allow access to large offsets within a struct Jan Kratochvil
2012-05-04 13:10 ` [PATCH v2] Expand bitpos and type.length to LONGEST and ULONGEST Siddhesh Poyarekar
2012-05-15 9:46 ` ping: " Siddhesh Poyarekar
2012-05-15 9:49 ` Jan Kratochvil
2012-05-15 10:02 ` Siddhesh Poyarekar
2012-05-15 20:07 ` Jan Kratochvil
2012-05-16 3:50 ` Siddhesh Poyarekar
2012-05-16 7:19 ` Jan Kratochvil
2012-05-16 7:41 ` Siddhesh Poyarekar
2012-05-20 15:43 ` Doug Evans
2012-05-20 20:24 ` Jan Kratochvil
2012-05-20 20:28 ` Doug Evans
2012-05-23 13:52 ` Siddhesh Poyarekar
2012-05-23 17:46 ` Jan Kratochvil
2012-05-24 1:36 ` Siddhesh Poyarekar
2012-05-24 15:01 ` Jan Kratochvil
2012-05-31 18:15 ` [PATCH v3] " Siddhesh Poyarekar
2012-06-05 22:27 ` Jan Kratochvil
2012-06-06 18:23 ` Siddhesh Poyarekar
2012-06-06 21:34 ` Jan Kratochvil
2012-06-08 14:16 ` Jan Kratochvil
2012-06-08 15:27 ` Jan Kratochvil
2012-06-11 12:53 ` Siddhesh Poyarekar
2012-06-11 13:00 ` Jan Kratochvil
2012-06-11 18:33 ` Siddhesh Poyarekar
2012-06-12 9:56 ` Jan Kratochvil
2012-06-12 14:35 ` Jan Kratochvil
2012-06-18 10:31 ` [2/2][PATCH " Siddhesh Poyarekar
2012-06-18 10:31 ` [1/2][PATCH " Siddhesh Poyarekar
2012-06-20 15:47 ` Jan Kratochvil
2012-06-20 16:32 ` Siddhesh Poyarekar
2012-06-20 17:25 ` Jan Kratochvil
2012-06-23 1:59 ` Siddhesh Poyarekar
2012-05-31 6:39 ` [PATCH v2] " Siddhesh Poyarekar
2012-05-31 9:24 ` Siddhesh Poyarekar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120417130833.GB15356@host2.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=siddhesh@redhat.com \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox