+2015-11-19 Pedro Alves <palves@redhat.com>
+
+ * remote.c (remote_unpush_target): Use
+ pop_all_targets_at_and_above instead of pop_all_targets_above.
+ * target.c (unpush_target_and_assert): New function, factored out
+ from ...
+ (pop_all_targets_above): ... here.
+ (pop_all_targets_at_and_above): New function.
+ * target.h (pop_all_targets_at_and_above): Declare.
+
2015-11-18 Simon Marchi <simon.marchi@ericsson.com>
* valops.c (value_string): Constify 'ptr' parameter.
return 1;
}
+/* Unpush TARGET and assert that it worked. */
+
+static void
+unpush_target_and_assert (struct target_ops *target)
+{
+ if (!unpush_target (target))
+ {
+ fprintf_unfiltered (gdb_stderr,
+ "pop_all_targets couldn't find target %s\n",
+ target->to_shortname);
+ internal_error (__FILE__, __LINE__,
+ _("failed internal consistency check"));
+ }
+}
+
void
pop_all_targets_above (enum strata above_stratum)
{
while ((int) (current_target.to_stratum) > (int) above_stratum)
- {
- if (!unpush_target (target_stack))
- {
- fprintf_unfiltered (gdb_stderr,
- "pop_all_targets couldn't find target %s\n",
- target_stack->to_shortname);
- internal_error (__FILE__, __LINE__,
- _("failed internal consistency check"));
- break;
- }
- }
+ unpush_target_and_assert (target_stack);
+}
+
+/* See target.h. */
+
+void
+pop_all_targets_at_and_above (enum strata stratum)
+{
+ while ((int) (current_target.to_stratum) >= (int) stratum)
+ unpush_target_and_assert (target_stack);
}
void
/* Does whatever cleanup is required to get rid of all pushed targets. */
extern void pop_all_targets (void);
+/* Like pop_all_targets, but pops only targets whose stratum is at or
+ above STRATUM. */
+extern void pop_all_targets_at_and_above (enum strata stratum);
+
/* Like pop_all_targets, but pops only targets whose stratum is
strictly above ABOVE_STRATUM. */
extern void pop_all_targets_above (enum strata above_stratum);