aboutsummaryrefslogtreecommitdiff
path: root/gdb/expop.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:14 -0700
commitde401988aeac56a8478f61cde1b35e961742317b (patch)
tree5025ecd1df35aae4520e8d6da3bf8e840762792d /gdb/expop.h
parente2803273a078950d0895de245cdc5375f362a8c5 (diff)
downloadgdb-de401988aeac56a8478f61cde1b35e961742317b.zip
gdb-de401988aeac56a8478f61cde1b35e961742317b.tar.gz
gdb-de401988aeac56a8478f61cde1b35e961742317b.tar.bz2
Implement dumping
This patch implements the dumping methods for tuple_holding_operation. A number of overloads are used. Note that no default case is given. This approach makes it simple to detect when a new overload is needed -- compilation will fail. (There is an example of this in a later patch in the series.) gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expprint.c (expr::dump_for_expression): New functions. * expop.h (dump_for_expression): New overloads. (tuple_holding_operation::dump, tuple_holding_operation::do_dump): Update.
Diffstat (limited to 'gdb/expop.h')
-rw-r--r--gdb/expop.h55
1 files changed, 54 insertions, 1 deletions
diff --git a/gdb/expop.h b/gdb/expop.h
index 861e3c2..97848fd 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -133,6 +133,57 @@ check_objfile (const std::pair<S, T> &item, struct objfile *objfile)
|| check_objfile (item.second, objfile));
}
+static inline void
+dump_for_expression (struct ui_file *stream, int depth,
+ const operation_up &op)
+{
+ op->dump (stream, depth);
+}
+
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ enum exp_opcode op);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ const std::string &str);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ struct type *type);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ CORE_ADDR addr);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ internalvar *ivar);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ symbol *sym);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ minimal_symbol *msym);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ const block *bl);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ type_instance_flags flags);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ enum c_string_type_values flags);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ enum range_flag flags);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ objfile *objf);
+
+template<typename T>
+void
+dump_for_expression (struct ui_file *stream, int depth,
+ const std::vector<T> &vals)
+{
+ fprintf_filtered (stream, _("%*sVector:\n"), depth, "");
+ for (auto &item : vals)
+ dump_for_expression (stream, depth + 1, item);
+}
+
+template<typename X, typename Y>
+void
+dump_for_expression (struct ui_file *stream, int depth,
+ const std::pair<X, Y> &vals)
+{
+ dump_for_expression (stream, depth, vals.first);
+ dump_for_expression (stream, depth, vals.second);
+}
+
/* Base class for most concrete operations. This class holds data,
specified via template parameters, and supplies generic
implementations of the 'dump' and 'uses_objfile' methods. */
@@ -155,7 +206,8 @@ public:
void dump (struct ui_file *stream, int depth) const override
{
- do_dump<0, Arg...> (stream, depth, m_storage);
+ dump_for_expression (stream, depth, opcode ());
+ do_dump<0, Arg...> (stream, depth + 1, m_storage);
}
protected:
@@ -178,6 +230,7 @@ private:
do_dump (struct ui_file *stream, int depth, const std::tuple<T...> &value)
const
{
+ dump_for_expression (stream, depth, std::get<I> (value));
do_dump<I + 1, T...> (stream, depth, value);
}