@@ -65,7 +65,7 @@ void consolidate_lists(std::vector<T>& list, std::vector<T>& list2)
6565 for (auto it = list.begin () + 1 ; it != list.end (); ++it) {
6666 if (prev->start + prev->length != it->start ) {
6767 if (prev->start + prev->length > it->start ) {
68- std::cout << " *** Overlapping entries:" << std::endl ;
68+ std::cout << " *** Overlapping entries:\n " ;
6969 std::cout << std::hex;
7070 std::cout << " 0x" << prev->start << " ..0x" << prev->start + prev->length << std::endl;
7171 std::cout << " 0x" << it->start << " ..0x" << it->start + it->length << std::endl;
@@ -455,7 +455,16 @@ class Group : public Array {
455455 for (size_t n = 0 ; n < m_history.size (); n++) {
456456 ref = m_history.get_ref (n);
457457 Node node (m_alloc, ref);
458- ret.emplace_back (node.data (), node.size ());
458+ if (!node.has_refs ()) {
459+ ret.emplace_back (node.data (), node.size ());
460+ continue ;
461+ }
462+
463+ Array array (m_alloc, ref);
464+ for (size_t j = 0 ; j < array.size (); ++j) {
465+ Node node (m_alloc, array.get_ref (j));
466+ ret.emplace_back (node.data (), node.size ());
467+ }
459468 }
460469 }
461470 return ret;
@@ -473,7 +482,7 @@ class Group : public Array {
473482 if (m_evacuation_info.valid ()) {
474483 ostr << " Evacuation limit: " << size_t (m_evacuation_info.get_val (0 ));
475484 if (m_evacuation_info.get_val (1 )) {
476- ostr << " Scan done" << std::endl ;
485+ ostr << " Scan done\n " ;
477486 }
478487 else {
479488 ostr << " Progress: [" ;
@@ -482,7 +491,7 @@ class Group : public Array {
482491 ostr << ' ,' ;
483492 ostr << m_evacuation_info.get_val (i);
484493 }
485- ostr << " ]" << std::endl ;
494+ ostr << " ]\n " ;
486495 }
487496 }
488497 }
@@ -588,14 +597,14 @@ std::ostream& operator<<(std::ostream& ostr, const Group& g)
588597 }
589598 }
590599 else {
591- ostr << " *** Invalid group ***" << std::endl ;
600+ ostr << " *** Invalid group ***\n " ;
592601 }
593602 return ostr;
594603}
595604
596605void Table::print_columns (const Group& group) const
597606{
598- std::cout << " <" << m_table_type << " >" << std::endl ;
607+ std::cout << " <" << m_table_type << " >\n " ;
599608 for (unsigned i = 0 ; i < m_column_names.size (); i++) {
600609 auto type = realm::ColumnType (m_column_types.get_val (i) & 0xFFFF );
601610 auto attr = realm::ColumnAttr (m_column_attributes.get_val (i));
@@ -646,7 +655,7 @@ void Table::print_columns(const Group& group) const
646655void Group::print_schema () const
647656{
648657 if (valid ()) {
649- std::cout << " Tables: " << std::endl ;
658+ std::cout << " Tables: \n " ;
650659
651660 for (unsigned i = 0 ; i < get_nb_tables (); i++) {
652661 Table* table = get_table (i);
@@ -808,7 +817,7 @@ void RealmFile::node_scan()
808817 }
809818 uint64_t bad_ref = 0 ;
810819 if (free_list.empty ()) {
811- std::cout << " *** No free list - results may be unreliable ***" << std::endl ;
820+ std::cout << " *** No free list - results may be unreliable ***\n " ;
812821 }
813822 std::cout << std::hex;
814823 while (ref < end) {
@@ -847,7 +856,7 @@ void RealmFile::node_scan()
847856 << " Start: 0x" << bad_ref << " ..0x" << end << std::endl;
848857 }
849858 std::cout << std::dec;
850- std::cout << " Allocated space:" << std::endl ;
859+ std::cout << " Allocated space:\n " ;
851860 for (auto s : sizes) {
852861 std::cout << " Size: " << s.first << " count: " << s.second << std::endl;
853862 }
@@ -870,7 +879,7 @@ void RealmFile::memory_leaks()
870879 consolidate_lists (nodes, free_blocks);
871880 auto it = nodes.begin ();
872881 if (nodes.size () > 1 ) {
873- std::cout << " Memory leaked:" << std::endl ;
882+ std::cout << " Memory leaked:\n " ;
874883 auto prev = it;
875884 ++it;
876885 while (it != nodes.end ()) {
@@ -882,7 +891,7 @@ void RealmFile::memory_leaks()
882891 }
883892 else {
884893 REALM_ASSERT (it->length == m_group->get_file_size ());
885- std::cout << " No memory leaks" << std::endl ;
894+ std::cout << " No memory leaks\n " ;
886895 }
887896 }
888897}
@@ -891,7 +900,7 @@ void RealmFile::free_list_info() const
891900{
892901 std::map<uint64_t , unsigned > free_sizes;
893902 std::map<uint64_t , unsigned > pinned_sizes;
894- std::cout << " Free space:" << std::endl ;
903+ std::cout << " Free space:\n " ;
895904 auto free_list = m_group->get_free_list ();
896905 uint64_t pinned_free_list_size = 0 ;
897906 uint64_t total_free_list_size = 0 ;
@@ -911,11 +920,11 @@ void RealmFile::free_list_info() const
911920
912921 ++it;
913922 }
914- std::cout << " Free space sizes:" << std::endl ;
923+ std::cout << " Free space sizes:\n " ;
915924 for (auto s : free_sizes) {
916925 std::cout << " Size: " << s.first << " count: " << s.second << std::endl;
917926 }
918- std::cout << " Pinned sizes:" << std::endl ;
927+ std::cout << " Pinned sizes:\n " ;
919928 for (auto s : pinned_sizes) {
920929 std::cout << " Size: " << s.first << " count: " << s.second << std::endl;
921930 }
@@ -984,7 +993,7 @@ class HistoryLogger {
984993
985994 bool dictionary_clear (size_t )
986995 {
987- std::cout << " Dictionary clear " << std::endl ;
996+ std::cout << " Dictionary clear \n " ;
988997 return true ;
989998 }
990999
@@ -1052,8 +1061,13 @@ void RealmFile::changes() const
10521061
10531062 for (auto c : changesets) {
10541063 realm::util::SimpleInputStream stream (c);
1055- parser.parse (stream, logger);
1056- std::cout << " --------------------------------------------" << std::endl;
1064+ try {
1065+ parser.parse (stream, logger);
1066+ }
1067+ catch (const std::exception& ex) {
1068+ std::cout << " Bad history: " << ex.what () << " \n " ;
1069+ }
1070+ std::cout << " --------------------------------------------\n " ;
10571071 }
10581072}
10591073
@@ -1161,15 +1175,14 @@ int main(int argc, const char* argv[])
11611175 }
11621176 }
11631177 else {
1164- std::cout << " Usage: realm-trawler [-afmsw ] [--keyfile file-with-binary-crypt-key] [--hexkey "
1178+ std::cout << " Usage: realm-trawler [-cfmsw ] [--keyfile file-with-binary-crypt-key] [--hexkey "
11651179 " crypt-key-in-hex] [--top "
1166- " top_ref] <realmfile>"
1167- << std::endl;
1168- std::cout << " c : dump changelog" << std::endl;
1169- std::cout << " f : free list analysis" << std::endl;
1170- std::cout << " m : memory leak check" << std::endl;
1171- std::cout << " s : schema dump" << std::endl;
1172- std::cout << " w : node walk" << std::endl;
1180+ " top_ref] <realmfile>\n " ;
1181+ std::cout << " c : dump changelog\n " ;
1182+ std::cout << " f : free list analysis\n " ;
1183+ std::cout << " m : memory leak check\n " ;
1184+ std::cout << " s : schema dump\n " ;
1185+ std::cout << " w : node walk\n " ;
11731186 }
11741187
11751188 return 0 ;
0 commit comments