aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2022-11-11 22:02:39 +0700
committerMike Frysinger <vapier@gentoo.org>2022-11-11 22:08:14 +0700
commit36895e5335bcfaab939c7e8d2f271face79bc45c (patch)
treefe1bfca1202e19335f81ec241c7097d181ac1d4d /sim
parentac42aa228f3f1ebda16ddb53b993d6341dbbf100 (diff)
downloadgdb-36895e5335bcfaab939c7e8d2f271face79bc45c.zip
gdb-36895e5335bcfaab939c7e8d2f271face79bc45c.tar.gz
gdb-36895e5335bcfaab939c7e8d2f271face79bc45c.tar.bz2
sim: igen: cleanup archaic pointer-to-long printf casts
Use proper %p to printf a pointer instead of casting it to long and using 0x%lx. It's cleaner, more correct, and doesn't break on LLP64.
Diffstat (limited to 'sim')
-rw-r--r--sim/igen/gen.c20
-rw-r--r--sim/igen/ld-decode.c16
-rw-r--r--sim/igen/ld-insn.c62
-rw-r--r--sim/igen/table.c4
4 files changed, 49 insertions, 53 deletions
diff --git a/sim/igen/gen.c b/sim/igen/gen.c
index 9f48e5c..f0f7482 100644
--- a/sim/igen/gen.c
+++ b/sim/igen/gen.c
@@ -1511,7 +1511,7 @@ dump_opcode_field (lf *file,
char *prefix,
opcode_field *field, char *suffix, int levels)
{
- lf_printf (file, "%s(opcode_field *) 0x%lx", prefix, (long) field);
+ lf_printf (file, "%s(opcode_field *) %p", prefix, field);
if (levels && field != NULL)
{
lf_indent (file, +1);
@@ -1531,7 +1531,7 @@ static void
dump_opcode_bits (lf *file,
char *prefix, opcode_bits *bits, char *suffix, int levels)
{
- lf_printf (file, "%s(opcode_bits *) 0x%lx", prefix, (long) bits);
+ lf_printf (file, "%s(opcode_bits *) %p", prefix, bits);
if (levels && bits != NULL)
{
@@ -1550,13 +1550,13 @@ dump_opcode_bits (lf *file,
static void
dump_insn_list (lf *file, char *prefix, insn_list *entry, char *suffix)
{
- lf_printf (file, "%s(insn_list *) 0x%lx", prefix, (long) entry);
+ lf_printf (file, "%s(insn_list *) %p", prefix, entry);
if (entry != NULL)
{
lf_indent (file, +1);
dump_insn_entry (file, "\n(insn ", entry->insn, ")");
- lf_printf (file, "\n(next 0x%lx)", (long) entry->next);
+ lf_printf (file, "\n(next %p)", entry->next);
lf_indent (file, -1);
}
lf_printf (file, "%s", suffix);
@@ -1583,7 +1583,7 @@ dump_gen_entry (lf *file,
char *prefix, gen_entry *table, char *suffix, int levels)
{
- lf_printf (file, "%s(gen_entry *) 0x%lx", prefix, (long) table);
+ lf_printf (file, "%s(gen_entry *) %p", prefix, table);
if (levels && table !=NULL)
{
@@ -1614,9 +1614,9 @@ dump_gen_list (lf *file,
{
while (entry != NULL)
{
- lf_printf (file, "%s(gen_list *) 0x%lx", prefix, (long) entry);
+ lf_printf (file, "%s(gen_list *) %p", prefix, entry);
dump_gen_entry (file, "\n(", entry->table, ")", levels);
- lf_printf (file, "\n(next (gen_list *) 0x%lx)", (long) entry->next);
+ lf_printf (file, "\n(next (gen_list *) %p)", entry->next);
lf_printf (file, "%s", suffix);
}
}
@@ -1626,9 +1626,9 @@ static void
dump_gen_table (lf *file,
char *prefix, gen_table *gen, char *suffix, int levels)
{
- lf_printf (file, "%s(gen_table *) 0x%lx", prefix, (long) gen);
- lf_printf (file, "\n(isa (insn_table *) 0x%lx)", (long) gen->isa);
- lf_printf (file, "\n(rules (decode_table *) 0x%lx)", (long) gen->rules);
+ lf_printf (file, "%s(gen_table *) %p", prefix, gen);
+ lf_printf (file, "\n(isa (insn_table *) %p)", gen->isa);
+ lf_printf (file, "\n(rules (decode_table *) %p)", gen->rules);
dump_gen_list (file, "\n(", gen->tables, ")", levels);
lf_printf (file, "%s", suffix);
}
diff --git a/sim/igen/ld-decode.c b/sim/igen/ld-decode.c
index 51bb3e0..badfa95 100644
--- a/sim/igen/ld-decode.c
+++ b/sim/igen/ld-decode.c
@@ -309,15 +309,15 @@ static void
dump_decode_cond (lf *file, const char *prefix, const decode_cond *cond,
const char *suffix)
{
- lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond);
+ lf_printf (file, "%s(decode_cond *) %p", prefix, cond);
if (cond != NULL)
{
lf_indent (file, +1);
lf_printf (file, "\n(word_nr %d)", cond->word_nr);
- lf_printf (file, "\n(mask 0x%lx)", (long) cond->mask);
- lf_printf (file, "\n(value 0x%lx)", (long) cond->value);
- lf_printf (file, "\n(is_equal 0x%lx)", (long) cond->is_equal);
- lf_printf (file, "\n(next (decode_cond *) 0%lx)", (long) cond->next);
+ lf_printf (file, "\n(mask %p)", cond->mask);
+ lf_printf (file, "\n(value %p)", cond->value);
+ lf_printf (file, "\n(is_equal %d)", cond->is_equal);
+ lf_printf (file, "\n(next (decode_cond *) %p)", cond->next);
lf_indent (file, -1);
}
lf_printf (file, "%s", suffix);
@@ -328,7 +328,7 @@ static void
dump_decode_conds (lf *file, const char *prefix, const decode_cond *cond,
const char *suffix)
{
- lf_printf (file, "%s(decode_cond *) 0x%lx", prefix, (long) cond);
+ lf_printf (file, "%s(decode_cond *) %p", prefix, cond);
while (cond != NULL)
{
dump_decode_cond (file, "\n(", cond, ")");
@@ -342,7 +342,7 @@ void
dump_decode_rule (lf *file, const char *prefix, const decode_table *rule,
const char *suffix)
{
- lf_printf (file, "%s(decode_table *) 0x%lx", prefix, (long) rule);
+ lf_printf (file, "%s(decode_table *) %p", prefix, rule);
if (rule != NULL)
{
lf_indent (file, +1);
@@ -363,7 +363,7 @@ dump_decode_rule (lf *file, const char *prefix, const decode_table *rule,
dump_filter (file, "\n(format_names \"", rule->format_names, "\")");
dump_filter (file, "\n(model_names \"", rule->model_names, "\")");
dump_decode_conds (file, "\n(conditions ", rule->conditions, ")");
- lf_printf (file, "\n(next 0x%lx)", (long) rule->next);
+ lf_printf (file, "\n(next %p)", rule->next);
lf_indent (file, -1);
}
lf_printf (file, "%s", suffix);
diff --git a/sim/igen/ld-insn.c b/sim/igen/ld-insn.c
index a823b3f..473c6ff 100644
--- a/sim/igen/ld-insn.c
+++ b/sim/igen/ld-insn.c
@@ -1388,7 +1388,7 @@ dump_function_entry (lf *file,
const function_entry *entry,
const char *suffix)
{
- lf_printf (file, "%s(function_entry *) 0x%lx", prefix, (long) entry);
+ lf_printf (file, "%s(function_entry *) %p", prefix, entry);
if (entry != NULL)
{
dump_line_ref (file, "\n(line ", entry->line, ")");
@@ -1398,7 +1398,7 @@ dump_function_entry (lf *file,
lf_printf (file, "\n(param \"%s\")", entry->param);
dump_table_entry (file, "\n(code ", entry->code, ")");
lf_printf (file, "\n(is_internal %d)", entry->is_internal);
- lf_printf (file, "\n(next 0x%lx)", (long) entry->next);
+ lf_printf (file, "\n(next %p)", entry->next);
}
lf_printf (file, "%s", suffix);
}
@@ -1442,7 +1442,7 @@ dump_cache_entry (lf *file,
const cache_entry *entry,
const char *suffix)
{
- lf_printf (file, "%s(cache_entry *) 0x%lx", prefix, (long) entry);
+ lf_printf (file, "%s(cache_entry *) %p", prefix, entry);
if (entry != NULL)
{
dump_line_ref (file, "\n(line ", entry->line, ")");
@@ -1453,7 +1453,7 @@ dump_cache_entry (lf *file,
dump_filter (file, "\n(original_fields ", entry->original_fields, ")");
lf_printf (file, "\n(type \"%s\")", entry->type);
lf_printf (file, "\n(expression \"%s\")", entry->expression);
- lf_printf (file, "\n(next 0x%lx)", (long) entry->next);
+ lf_printf (file, "\n(next %p)", entry->next);
}
lf_printf (file, "%s", suffix);
}
@@ -1481,7 +1481,7 @@ dump_model_data (lf *file,
const model_data *entry,
const char *suffix)
{
- lf_printf (file, "%s(model_data *) 0x%lx", prefix, (long) entry);
+ lf_printf (file, "%s(model_data *) %p", prefix, entry);
if (entry != NULL)
{
lf_indent (file, +1);
@@ -1489,7 +1489,7 @@ dump_model_data (lf *file,
dump_filter (file, "\n(flags ", entry->flags, ")");
dump_table_entry (file, "\n(entry ", entry->entry, ")");
dump_table_entry (file, "\n(code ", entry->code, ")");
- lf_printf (file, "\n(next 0x%lx)", (long) entry->next);
+ lf_printf (file, "\n(next %p)", entry->next);
lf_indent (file, -1);
}
lf_printf (file, "%s", prefix);
@@ -1518,7 +1518,7 @@ dump_model_entry (lf *file,
const model_entry *entry,
const char *suffix)
{
- lf_printf (file, "%s(model_entry *) 0x%lx", prefix, (long) entry);
+ lf_printf (file, "%s(model_entry *) %p", prefix, entry);
if (entry != NULL)
{
lf_indent (file, +1);
@@ -1527,7 +1527,7 @@ dump_model_entry (lf *file,
lf_printf (file, "\n(name \"%s\")", entry->name);
lf_printf (file, "\n(full_name \"%s\")", entry->full_name);
lf_printf (file, "\n(unit_data \"%s\")", entry->unit_data);
- lf_printf (file, "\n(next 0x%lx)", (long) entry->next);
+ lf_printf (file, "\n(next %p)", entry->next);
lf_indent (file, -1);
}
lf_printf (file, "%s", prefix);
@@ -1557,7 +1557,7 @@ dump_model_table (lf *file,
const model_table *entry,
const char *suffix)
{
- lf_printf (file, "%s(model_table *) 0x%lx", prefix, (long) entry);
+ lf_printf (file, "%s(model_table *) %p", prefix, entry);
if (entry != NULL)
{
lf_indent (file, +1);
@@ -1603,7 +1603,7 @@ dump_insn_field (lf *file,
const char *suffix)
{
char *sep = " ";
- lf_printf (file, "%s(insn_field_entry *) 0x%lx", prefix, (long) field);
+ lf_printf (file, "%s(insn_field_entry *) %p", prefix, field);
if (field != NULL)
{
lf_indent (file, +1);
@@ -1630,8 +1630,8 @@ dump_insn_field (lf *file,
lf_printf (file, "%s(val \"%s\")", sep, field->val_string);
break;
}
- lf_printf (file, "%s(next 0x%lx)", sep, (long) field->next);
- lf_printf (file, "%s(prev 0x%lx)", sep, (long) field->prev);
+ lf_printf (file, "%s(next %p)", sep, field->next);
+ lf_printf (file, "%s(prev %p)", sep, field->prev);
lf_indent (file, -1);
}
lf_printf (file, "%s", suffix);
@@ -1643,24 +1643,24 @@ dump_insn_word_entry (lf *file,
const insn_word_entry *word,
const char *suffix)
{
- lf_printf (file, "%s(insn_word_entry *) 0x%lx", prefix, (long) word);
+ lf_printf (file, "%s(insn_word_entry *) %p", prefix, word);
if (word != NULL)
{
int i;
insn_field_entry *field;
lf_indent (file, +1);
- lf_printf (file, "\n(first 0x%lx)", (long) word->first);
- lf_printf (file, "\n(last 0x%lx)", (long) word->last);
+ lf_printf (file, "\n(first %p)", word->first);
+ lf_printf (file, "\n(last %p)", word->last);
lf_printf (file, "\n(bit");
for (i = 0; i < options.insn_bit_size; i++)
- lf_printf (file, "\n ((value %d) (mask %d) (field 0x%lx))",
+ lf_printf (file, "\n ((value %d) (mask %d) (field %p))",
word->bit[i]->value, word->bit[i]->mask,
- (long) word->bit[i]->field);
+ word->bit[i]->field);
lf_printf (file, ")");
for (field = word->first; field != NULL; field = field->next)
dump_insn_field (file, "\n(", field, ")");
dump_filter (file, "\n(field_names ", word->field_names, ")");
- lf_printf (file, "\n(next 0x%lx)", (long) word->next);
+ lf_printf (file, "\n(next %p)", word->next);
lf_indent (file, -1);
}
lf_printf (file, "%s", suffix);
@@ -1687,7 +1687,7 @@ dump_insn_model_entry (lf *file,
const insn_model_entry *model,
const char *suffix)
{
- lf_printf (file, "%s(insn_model_entry *) 0x%lx", prefix, (long) model);
+ lf_printf (file, "%s(insn_model_entry *) %p", prefix, model);
if (model != NULL)
{
lf_indent (file, +1);
@@ -1695,9 +1695,8 @@ dump_insn_model_entry (lf *file,
dump_filter (file, "\n(names ", model->names, ")");
lf_printf (file, "\n(full_name \"%s\")", model->full_name);
lf_printf (file, "\n(unit_data \"%s\")", model->unit_data);
- lf_printf (file, "\n(insn (insn_entry *) 0x%lx)", (long) model->insn);
- lf_printf (file, "\n(next (insn_model_entry *) 0x%lx)",
- (long) model->next);
+ lf_printf (file, "\n(insn (insn_entry *) %p)", model->insn);
+ lf_printf (file, "\n(next (insn_model_entry *) %p)", model->next);
lf_indent (file, -1);
}
lf_printf (file, "%s", suffix);
@@ -1725,18 +1724,15 @@ dump_insn_mnemonic_entry (lf *file,
const insn_mnemonic_entry *mnemonic,
const char *suffix)
{
- lf_printf (file, "%s(insn_mnemonic_entry *) 0x%lx", prefix,
- (long) mnemonic);
+ lf_printf (file, "%s(insn_mnemonic_entry *) %p", prefix, mnemonic);
if (mnemonic != NULL)
{
lf_indent (file, +1);
dump_line_ref (file, "\n(line ", mnemonic->line, ")");
lf_printf (file, "\n(format \"%s\")", mnemonic->format);
lf_printf (file, "\n(condition \"%s\")", mnemonic->condition);
- lf_printf (file, "\n(insn (insn_entry *) 0x%lx)",
- (long) mnemonic->insn);
- lf_printf (file, "\n(next (insn_mnemonic_entry *) 0x%lx)",
- (long) mnemonic->next);
+ lf_printf (file, "\n(insn (insn_entry *) %p)", mnemonic->insn);
+ lf_printf (file, "\n(next (insn_mnemonic_entry *) %p)", mnemonic->next);
lf_indent (file, -1);
}
lf_printf (file, "%s", suffix);
@@ -1763,7 +1759,7 @@ dump_insn_entry (lf *file,
const insn_entry *entry,
const char *suffix)
{
- lf_printf (file, "%s(insn_entry *) 0x%lx", prefix, (long) entry);
+ lf_printf (file, "%s(insn_entry *) %p", prefix, entry);
if (entry != NULL)
{
int i;
@@ -1774,7 +1770,7 @@ dump_insn_entry (lf *file,
dump_insn_word_entries (file, "\n(words ", entry->words, ")");
lf_printf (file, "\n(word");
for (i = 0; i < entry->nr_models; i++)
- lf_printf (file, " 0x%lx", (long) entry->word[i]);
+ lf_printf (file, " %p", entry->word[i]);
lf_printf (file, ")");
dump_filter (file, "\n(field_names ", entry->field_names, ")");
lf_printf (file, "\n(format_name \"%s\")", entry->format_name);
@@ -1784,13 +1780,13 @@ dump_insn_entry (lf *file,
dump_insn_model_entries (file, "\n(models ", entry->models, ")");
lf_printf (file, "\n(model");
for (i = 0; i < entry->nr_models; i++)
- lf_printf (file, " 0x%lx", (long) entry->model[i]);
+ lf_printf (file, " %p", entry->model[i]);
lf_printf (file, ")");
dump_filter (file, "\n(processors ", entry->processors, ")");
dump_insn_mnemonic_entries (file, "\n(mnemonics ", entry->mnemonics,
")");
dump_table_entry (file, "\n(code ", entry->code, ")");
- lf_printf (file, "\n(next 0x%lx)", (long) entry->next);
+ lf_printf (file, "\n(next %p)", entry->next);
lf_indent (file, -1);
}
lf_printf (file, "%s", suffix);
@@ -1820,7 +1816,7 @@ dump_insn_table (lf *file,
const insn_table *isa,
const char *suffix)
{
- lf_printf (file, "%s(insn_table *) 0x%lx", prefix, (long) isa);
+ lf_printf (file, "%s(insn_table *) %p", prefix, isa);
if (isa != NULL)
{
lf_indent (file, +1);
diff --git a/sim/igen/table.c b/sim/igen/table.c
index acf6e1c..0bf1a30 100644
--- a/sim/igen/table.c
+++ b/sim/igen/table.c
@@ -536,7 +536,7 @@ dump_line_ref (lf *file,
const line_ref *line,
const char *suffix)
{
- lf_printf (file, "%s(line_ref*) 0x%lx", prefix, (long) line);
+ lf_printf (file, "%s(line_ref*) %p", prefix, line);
if (line != NULL)
{
lf_indent (file, +1);
@@ -567,7 +567,7 @@ dump_table_entry (lf *file,
const table_entry *entry,
const char *suffix)
{
- lf_printf (file, "%s(table_entry*) 0x%lx", prefix, (long) entry);
+ lf_printf (file, "%s(table_entry*) %p", prefix, entry);
if (entry != NULL)
{
int field;