diff --git a/qemu/aarch64.h b/qemu/aarch64.h index e2627126..9e872148 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_aarch64 #define not_v8_cp_reginfo not_v8_cp_reginfo_aarch64 #define object_child_foreach object_child_foreach_aarch64 +#define object_child_foreach_recursive object_child_foreach_recursive_aarch64 #define object_class_foreach object_class_foreach_aarch64 #define object_class_foreach_tramp object_class_foreach_tramp_aarch64 #define object_class_get_list object_class_get_list_aarch64 @@ -2582,10 +2583,6 @@ #define save_globals save_globals_aarch64 #define scr_write scr_write_aarch64 #define sctlr_write sctlr_write_aarch64 -#define semihosting_get_target semihosting_get_target_aarch64 -#define semihosting_get_arg semihosting_get_arg_aarch64 -#define semihosting_get_argc semihosting_get_argc_aarch64 -#define semihosting_get_cmdline semihosting_get_cmdline_aarch64 #define set_bit set_bit_aarch64 #define set_bits set_bits_aarch64 #define set_default_nan_mode set_default_nan_mode_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index c9f0e672..bacff95b 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_aarch64eb #define not_v8_cp_reginfo not_v8_cp_reginfo_aarch64eb #define object_child_foreach object_child_foreach_aarch64eb +#define object_child_foreach_recursive object_child_foreach_recursive_aarch64eb #define object_class_foreach object_class_foreach_aarch64eb #define object_class_foreach_tramp object_class_foreach_tramp_aarch64eb #define object_class_get_list object_class_get_list_aarch64eb @@ -2582,10 +2583,6 @@ #define save_globals save_globals_aarch64eb #define scr_write scr_write_aarch64eb #define sctlr_write sctlr_write_aarch64eb -#define semihosting_get_target semihosting_get_target_aarch64eb -#define semihosting_get_arg semihosting_get_arg_aarch64eb -#define semihosting_get_argc semihosting_get_argc_aarch64eb -#define semihosting_get_cmdline semihosting_get_cmdline_aarch64eb #define set_bit set_bit_aarch64eb #define set_bits set_bits_aarch64eb #define set_default_nan_mode set_default_nan_mode_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index 5f3a85c5..95b718cc 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_arm #define not_v8_cp_reginfo not_v8_cp_reginfo_arm #define object_child_foreach object_child_foreach_arm +#define object_child_foreach_recursive object_child_foreach_recursive_arm #define object_class_foreach object_class_foreach_arm #define object_class_foreach_tramp object_class_foreach_tramp_arm #define object_class_get_list object_class_get_list_arm @@ -2582,10 +2583,6 @@ #define save_globals save_globals_arm #define scr_write scr_write_arm #define sctlr_write sctlr_write_arm -#define semihosting_get_target semihosting_get_target_arm -#define semihosting_get_arg semihosting_get_arg_arm -#define semihosting_get_argc semihosting_get_argc_arm -#define semihosting_get_cmdline semihosting_get_cmdline_arm #define set_bit set_bit_arm #define set_bits set_bits_arm #define set_default_nan_mode set_default_nan_mode_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index 2678a069..ed34550e 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_armeb #define not_v8_cp_reginfo not_v8_cp_reginfo_armeb #define object_child_foreach object_child_foreach_armeb +#define object_child_foreach_recursive object_child_foreach_recursive_armeb #define object_class_foreach object_class_foreach_armeb #define object_class_foreach_tramp object_class_foreach_tramp_armeb #define object_class_get_list object_class_get_list_armeb @@ -2582,10 +2583,6 @@ #define save_globals save_globals_armeb #define scr_write scr_write_armeb #define sctlr_write sctlr_write_armeb -#define semihosting_get_target semihosting_get_target_armeb -#define semihosting_get_arg semihosting_get_arg_armeb -#define semihosting_get_argc semihosting_get_argc_armeb -#define semihosting_get_cmdline semihosting_get_cmdline_armeb #define set_bit set_bit_armeb #define set_bits set_bits_armeb #define set_default_nan_mode set_default_nan_mode_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index 2e63f65c..ccf1d42d 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -2162,6 +2162,7 @@ symbols = ( 'not_v7_cp_reginfo', 'not_v8_cp_reginfo', 'object_child_foreach', + 'object_child_foreach_recursive', 'object_class_foreach', 'object_class_foreach_tramp', 'object_class_get_list', diff --git a/qemu/include/qom/object.h b/qemu/include/qom/object.h index 4451c7cf..3edefbc6 100644 --- a/qemu/include/qom/object.h +++ b/qemu/include/qom/object.h @@ -1251,6 +1251,22 @@ void object_property_set_description(Object *obj, const char *name, int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), void *opaque); +/** + * object_child_foreach_recursive: + * @obj: the object whose children will be navigated + * @fn: the iterator function to be called + * @opaque: an opaque value that will be passed to the iterator + * + * Call @fn passing each child of @obj and @opaque to it, until @fn returns + * non-zero. Calls recursively, all child nodes of @obj will also be passed + * all the way down to the leaf nodes of the tree. Depth first ordering. + * + * Returns: The last value returned by @fn, or 0 if there is no child. + */ +int object_child_foreach_recursive(Object *obj, + int (*fn)(Object *child, void *opaque), + void *opaque); + /** * container_get: * @root: root of the #path, e.g., object_get_root() diff --git a/qemu/m68k.h b/qemu/m68k.h index a10ac6b3..e8f5e4c4 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_m68k #define not_v8_cp_reginfo not_v8_cp_reginfo_m68k #define object_child_foreach object_child_foreach_m68k +#define object_child_foreach_recursive object_child_foreach_recursive_m68k #define object_class_foreach object_class_foreach_m68k #define object_class_foreach_tramp object_class_foreach_tramp_m68k #define object_class_get_list object_class_get_list_m68k @@ -2582,10 +2583,6 @@ #define save_globals save_globals_m68k #define scr_write scr_write_m68k #define sctlr_write sctlr_write_m68k -#define semihosting_get_target semihosting_get_target_m68k -#define semihosting_get_arg semihosting_get_arg_m68k -#define semihosting_get_argc semihosting_get_argc_m68k -#define semihosting_get_cmdline semihosting_get_cmdline_m68k #define set_bit set_bit_m68k #define set_bits set_bits_m68k #define set_default_nan_mode set_default_nan_mode_m68k diff --git a/qemu/mips.h b/qemu/mips.h index d862264e..c95b5505 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_mips #define not_v8_cp_reginfo not_v8_cp_reginfo_mips #define object_child_foreach object_child_foreach_mips +#define object_child_foreach_recursive object_child_foreach_recursive_mips #define object_class_foreach object_class_foreach_mips #define object_class_foreach_tramp object_class_foreach_tramp_mips #define object_class_get_list object_class_get_list_mips @@ -2582,10 +2583,6 @@ #define save_globals save_globals_mips #define scr_write scr_write_mips #define sctlr_write sctlr_write_mips -#define semihosting_get_target semihosting_get_target_mips -#define semihosting_get_arg semihosting_get_arg_mips -#define semihosting_get_argc semihosting_get_argc_mips -#define semihosting_get_cmdline semihosting_get_cmdline_mips #define set_bit set_bit_mips #define set_bits set_bits_mips #define set_default_nan_mode set_default_nan_mode_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index 0b8e3afa..9ad17aa9 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_mips64 #define not_v8_cp_reginfo not_v8_cp_reginfo_mips64 #define object_child_foreach object_child_foreach_mips64 +#define object_child_foreach_recursive object_child_foreach_recursive_mips64 #define object_class_foreach object_class_foreach_mips64 #define object_class_foreach_tramp object_class_foreach_tramp_mips64 #define object_class_get_list object_class_get_list_mips64 @@ -2582,10 +2583,6 @@ #define save_globals save_globals_mips64 #define scr_write scr_write_mips64 #define sctlr_write sctlr_write_mips64 -#define semihosting_get_target semihosting_get_target_mips64 -#define semihosting_get_arg semihosting_get_arg_mips64 -#define semihosting_get_argc semihosting_get_argc_mips64 -#define semihosting_get_cmdline semihosting_get_cmdline_mips64 #define set_bit set_bit_mips64 #define set_bits set_bits_mips64 #define set_default_nan_mode set_default_nan_mode_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index 028f1e6d..51cdde26 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_mips64el #define not_v8_cp_reginfo not_v8_cp_reginfo_mips64el #define object_child_foreach object_child_foreach_mips64el +#define object_child_foreach_recursive object_child_foreach_recursive_mips64el #define object_class_foreach object_class_foreach_mips64el #define object_class_foreach_tramp object_class_foreach_tramp_mips64el #define object_class_get_list object_class_get_list_mips64el @@ -2582,10 +2583,6 @@ #define save_globals save_globals_mips64el #define scr_write scr_write_mips64el #define sctlr_write sctlr_write_mips64el -#define semihosting_get_target semihosting_get_target_mips64el -#define semihosting_get_arg semihosting_get_arg_mips64el -#define semihosting_get_argc semihosting_get_argc_mips64el -#define semihosting_get_cmdline semihosting_get_cmdline_mips64el #define set_bit set_bit_mips64el #define set_bits set_bits_mips64el #define set_default_nan_mode set_default_nan_mode_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index e7bfcaca..fd6706fe 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_mipsel #define not_v8_cp_reginfo not_v8_cp_reginfo_mipsel #define object_child_foreach object_child_foreach_mipsel +#define object_child_foreach_recursive object_child_foreach_recursive_mipsel #define object_class_foreach object_class_foreach_mipsel #define object_class_foreach_tramp object_class_foreach_tramp_mipsel #define object_class_get_list object_class_get_list_mipsel @@ -2582,10 +2583,6 @@ #define save_globals save_globals_mipsel #define scr_write scr_write_mipsel #define sctlr_write sctlr_write_mipsel -#define semihosting_get_target semihosting_get_target_mipsel -#define semihosting_get_arg semihosting_get_arg_mipsel -#define semihosting_get_argc semihosting_get_argc_mipsel -#define semihosting_get_cmdline semihosting_get_cmdline_mipsel #define set_bit set_bit_mipsel #define set_bits set_bits_mipsel #define set_default_nan_mode set_default_nan_mode_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index 3bdbe1c5..c5df8654 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_powerpc #define not_v8_cp_reginfo not_v8_cp_reginfo_powerpc #define object_child_foreach object_child_foreach_powerpc +#define object_child_foreach_recursive object_child_foreach_recursive_powerpc #define object_class_foreach object_class_foreach_powerpc #define object_class_foreach_tramp object_class_foreach_tramp_powerpc #define object_class_get_list object_class_get_list_powerpc @@ -2582,10 +2583,6 @@ #define save_globals save_globals_powerpc #define scr_write scr_write_powerpc #define sctlr_write sctlr_write_powerpc -#define semihosting_get_target semihosting_get_target_powerpc -#define semihosting_get_arg semihosting_get_arg_powerpc -#define semihosting_get_argc semihosting_get_argc_powerpc -#define semihosting_get_cmdline semihosting_get_cmdline_powerpc #define set_bit set_bit_powerpc #define set_bits set_bits_powerpc #define set_default_nan_mode set_default_nan_mode_powerpc diff --git a/qemu/qom/object.c b/qemu/qom/object.c index c2ce5213..f4ef17ff 100644 --- a/qemu/qom/object.c +++ b/qemu/qom/object.c @@ -657,23 +657,42 @@ void object_class_foreach(struct uc_struct *uc, void (*fn)(ObjectClass *klass, v uc->enumerating_types = false; } -int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), - void *opaque) +static int do_object_child_foreach(Object *obj, + int (*fn)(Object *child, void *opaque), + void *opaque, bool recurse) { ObjectProperty *prop, *next; int ret = 0; QTAILQ_FOREACH_SAFE(prop, &obj->properties, node, next) { if (object_property_is_child(prop)) { - ret = fn(prop->opaque, opaque); + Object *child = prop->opaque; + + ret = fn(child, opaque); if (ret != 0) { break; } + if (recurse) { + do_object_child_foreach(child, fn, opaque, true); + } } } return ret; } +int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), + void *opaque) +{ + return do_object_child_foreach(obj, fn, opaque, false); +} + +int object_child_foreach_recursive(Object *obj, + int (*fn)(Object *child, void *opaque), + void *opaque) +{ + return do_object_child_foreach(obj, fn, opaque, true); +} + static void object_class_get_list_tramp(ObjectClass *klass, void *opaque) { GSList **list = opaque; diff --git a/qemu/sparc.h b/qemu/sparc.h index 5fc27a8e..214ba5fa 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_sparc #define not_v8_cp_reginfo not_v8_cp_reginfo_sparc #define object_child_foreach object_child_foreach_sparc +#define object_child_foreach_recursive object_child_foreach_recursive_sparc #define object_class_foreach object_class_foreach_sparc #define object_class_foreach_tramp object_class_foreach_tramp_sparc #define object_class_get_list object_class_get_list_sparc @@ -2582,10 +2583,6 @@ #define save_globals save_globals_sparc #define scr_write scr_write_sparc #define sctlr_write sctlr_write_sparc -#define semihosting_get_target semihosting_get_target_sparc -#define semihosting_get_arg semihosting_get_arg_sparc -#define semihosting_get_argc semihosting_get_argc_sparc -#define semihosting_get_cmdline semihosting_get_cmdline_sparc #define set_bit set_bit_sparc #define set_bits set_bits_sparc #define set_default_nan_mode set_default_nan_mode_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index fba04f6c..66268322 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_sparc64 #define not_v8_cp_reginfo not_v8_cp_reginfo_sparc64 #define object_child_foreach object_child_foreach_sparc64 +#define object_child_foreach_recursive object_child_foreach_recursive_sparc64 #define object_class_foreach object_class_foreach_sparc64 #define object_class_foreach_tramp object_class_foreach_tramp_sparc64 #define object_class_get_list object_class_get_list_sparc64 @@ -2582,10 +2583,6 @@ #define save_globals save_globals_sparc64 #define scr_write scr_write_sparc64 #define sctlr_write sctlr_write_sparc64 -#define semihosting_get_target semihosting_get_target_sparc64 -#define semihosting_get_arg semihosting_get_arg_sparc64 -#define semihosting_get_argc semihosting_get_argc_sparc64 -#define semihosting_get_cmdline semihosting_get_cmdline_sparc64 #define set_bit set_bit_sparc64 #define set_bits set_bits_sparc64 #define set_default_nan_mode set_default_nan_mode_sparc64 diff --git a/qemu/x86_64.h b/qemu/x86_64.h index aaf228f2..886ac062 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -2156,6 +2156,7 @@ #define not_v7_cp_reginfo not_v7_cp_reginfo_x86_64 #define not_v8_cp_reginfo not_v8_cp_reginfo_x86_64 #define object_child_foreach object_child_foreach_x86_64 +#define object_child_foreach_recursive object_child_foreach_recursive_x86_64 #define object_class_foreach object_class_foreach_x86_64 #define object_class_foreach_tramp object_class_foreach_tramp_x86_64 #define object_class_get_list object_class_get_list_x86_64 @@ -2582,10 +2583,6 @@ #define save_globals save_globals_x86_64 #define scr_write scr_write_x86_64 #define sctlr_write sctlr_write_x86_64 -#define semihosting_get_target semihosting_get_target_x86_64 -#define semihosting_get_arg semihosting_get_arg_x86_64 -#define semihosting_get_argc semihosting_get_argc_x86_64 -#define semihosting_get_cmdline semihosting_get_cmdline_x86_64 #define set_bit set_bit_x86_64 #define set_bits set_bits_x86_64 #define set_default_nan_mode set_default_nan_mode_x86_64