• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision915ef8b18e28e6418216a582067b9fbdd6395e6a (tree)
l'heure2015-11-19 23:32:53
AuteurPedro Alves <palves@redh...>
CommiterPedro Alves

Message de Log

[C++] remote.c: Avoid enum arithmetic

Fixes:

src/gdb/remote.c: In function ‘void remote_unpush_target()’:
src/gdb/remote.c:4610:45: error: invalid conversion from ‘int’ to ‘strata’ [-fpermissive]
pop_all_targets_above (process_stratum - 1);


In file included from src/gdb/inferior.h:38:0,

from src/gdb/remote.c:25:

src/gdb/target.h:2299:13: error: initializing argument 1 of ‘void pop_all_targets_above(strata)’ [-fpermissive]
extern void pop_all_targets_above (enum strata above_stratum);


I used to carry a patch in the C++ branch that just did:

- pop_all_targets_above (process_stratum - 1);
+ pop_all_targets_above ((enum strata) (process_stratum - 1));

But then thought that maybe adding a routine that does exactly what we
need results in clearer code. This is the result.

gdb/ChangeLog:
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.

Change Summary

Modification

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
1+2015-11-19 Pedro Alves <palves@redhat.com>
2+
3+ * remote.c (remote_unpush_target): Use
4+ pop_all_targets_at_and_above instead of pop_all_targets_above.
5+ * target.c (unpush_target_and_assert): New function, factored out
6+ from ...
7+ (pop_all_targets_above): ... here.
8+ (pop_all_targets_at_and_above): New function.
9+ * target.h (pop_all_targets_at_and_above): Declare.
10+
111 2015-11-18 Simon Marchi <simon.marchi@ericsson.com>
212
313 * valops.c (value_string): Constify 'ptr' parameter.
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4607,7 +4607,7 @@ remote_query_supported (void)
46074607 static void
46084608 remote_unpush_target (void)
46094609 {
4610- pop_all_targets_above (process_stratum - 1);
4610+ pop_all_targets_at_and_above (process_stratum);
46114611 }
46124612
46134613 static void
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -746,21 +746,35 @@ unpush_target (struct target_ops *t)
746746 return 1;
747747 }
748748
749+/* Unpush TARGET and assert that it worked. */
750+
751+static void
752+unpush_target_and_assert (struct target_ops *target)
753+{
754+ if (!unpush_target (target))
755+ {
756+ fprintf_unfiltered (gdb_stderr,
757+ "pop_all_targets couldn't find target %s\n",
758+ target->to_shortname);
759+ internal_error (__FILE__, __LINE__,
760+ _("failed internal consistency check"));
761+ }
762+}
763+
749764 void
750765 pop_all_targets_above (enum strata above_stratum)
751766 {
752767 while ((int) (current_target.to_stratum) > (int) above_stratum)
753- {
754- if (!unpush_target (target_stack))
755- {
756- fprintf_unfiltered (gdb_stderr,
757- "pop_all_targets couldn't find target %s\n",
758- target_stack->to_shortname);
759- internal_error (__FILE__, __LINE__,
760- _("failed internal consistency check"));
761- break;
762- }
763- }
768+ unpush_target_and_assert (target_stack);
769+}
770+
771+/* See target.h. */
772+
773+void
774+pop_all_targets_at_and_above (enum strata stratum)
775+{
776+ while ((int) (current_target.to_stratum) >= (int) stratum)
777+ unpush_target_and_assert (target_stack);
764778 }
765779
766780 void
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -2294,6 +2294,10 @@ extern void target_preopen (int);
22942294 /* Does whatever cleanup is required to get rid of all pushed targets. */
22952295 extern void pop_all_targets (void);
22962296
2297+/* Like pop_all_targets, but pops only targets whose stratum is at or
2298+ above STRATUM. */
2299+extern void pop_all_targets_at_and_above (enum strata stratum);
2300+
22972301 /* Like pop_all_targets, but pops only targets whose stratum is
22982302 strictly above ABOVE_STRATUM. */
22992303 extern void pop_all_targets_above (enum strata above_stratum);