+ map_keys = g_ptr_array_new();
+ if (!map_keys) {
+ BT_CLI_LOGE_APPEND_CAUSE("Failed to allocated on GPtrArray.");
+ goto end;
+ }
+
+ /*
+ * We want to print the map entries in a stable order. Collect
+ * all the map's keys in a GPtrArray, sort it, then print the
+ * entries in that order.
+ */
+ foreach_status = bt_value_map_foreach_entry_const(value,
+ collect_map_keys, map_keys);
+ if (foreach_status != BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_OK) {
+ BT_CLI_LOGE_APPEND_CAUSE("Failed to iterator on map value.");
+ goto end;
+ }
+
+ g_ptr_array_sort(map_keys, g_ptr_array_sort_strings);
+
+ for (i = 0; i < map_keys->len; i++) {
+ const char *map_key = g_ptr_array_index(map_keys, i);
+ const bt_value *map_value;
+
+ map_value = bt_value_map_borrow_entry_value_const(value, map_key);
+ BT_ASSERT(map_value);
+
+ print_map_value(map_key, map_value, fp, indent);
+ }
+