Skip to content

Commit 0652710

Browse files
author
meister
committed
Cleanup output of snapshot save
1 parent 3cac852 commit 0652710

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

src/gctools/snapshotSaveLoad.cc

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,21 +1145,21 @@ struct ISLFileHeader {
11451145

11461146
void describe(const std::string& mesg) {
11471147
printf("%s\n", mesg.c_str() );
1148-
printf(" %30s -> %lu\n", "size_t _Magic", _Magic );
1149-
printf(" %30s -> %lu(0x%lx)\n", "uintptr_t _LibrariesOffset", _LibrariesOffset, _LibrariesOffset );
1150-
printf(" %30s -> %lu\n", "uintptr_t _NumberOfLibraries", _NumberOfLibraries );
1151-
printf(" %30s -> 0x%lx\n", "uintptr_t _SaveTimeMemoryAddress", _SaveTimeMemoryAddress );
1152-
printf(" %30s -> %lu(0x%lx)\n", "uintptr_t _MemoryStart", _MemoryStart, _MemoryStart );
1153-
printf(" %30s -> %lu\n", "uintptr_t _NumberOfObjects", _NumberOfObjects );
1154-
printf(" %30s -> %lu(0x%lx)\n", "uintptr_t _MemorySize", _MemorySize, _MemorySize );
1155-
printf(" %30s -> %lu\n", "size_t _LispRootOffset", _LispRootOffset );
1156-
printf(" %30s -> %lu\n", "size_t _LispRootCount", _LispRootCount );
1157-
printf(" %30s -> %lu\n", "size_t _SymbolRootsOffset", _SymbolRootsOffset );
1158-
printf(" %30s -> %lu\n", "size_t _SymbolRootsCount", _SymbolRootsCount );
1159-
printf(" %30s -> %lu(0x%lx)\n", "uintptr_t _ObjectFileStart", _ObjectFileStart, _ObjectFileStart );
1160-
printf(" %30s -> %lu(0x%lx)\n", "uintptr_t _ObjectFileSize", _ObjectFileSize, _ObjectFileSize );
1161-
printf(" %30s -> %lu(0x%lx)\n", "NextUnshiftedClbindStamp", _NextUnshiftedClbindStamp, _NextUnshiftedClbindStamp );
1162-
printf(" %30s -> %lu(0x%lx)\n", "NextUnshiftedStamp", _NextUnshiftedStamp, _NextUnshiftedStamp );
1148+
printf(" %32s -> %lu\n", "size_t _Magic", _Magic );
1149+
printf(" %32s -> %lu(0x%lx)\n", "uintptr_t _LibrariesOffset", _LibrariesOffset, _LibrariesOffset );
1150+
printf(" %32s -> %lu\n", "uintptr_t _NumberOfLibraries", _NumberOfLibraries );
1151+
printf(" %32s -> 0x%lx\n", "uintptr_t _SaveTimeMemoryAddress", _SaveTimeMemoryAddress );
1152+
printf(" %32s -> %lu(0x%lx)\n", "uintptr_t _MemoryStart", _MemoryStart, _MemoryStart );
1153+
printf(" %32s -> %lu\n", "uintptr_t _NumberOfObjects", _NumberOfObjects );
1154+
printf(" %32s -> %lu(0x%lx)\n", "uintptr_t _MemorySize", _MemorySize, _MemorySize );
1155+
printf(" %32s -> %lu\n", "size_t _LispRootOffset", _LispRootOffset );
1156+
printf(" %32s -> %lu\n", "size_t _LispRootCount", _LispRootCount );
1157+
printf(" %32s -> %lu\n", "size_t _SymbolRootsOffset", _SymbolRootsOffset );
1158+
printf(" %32s -> %lu\n", "size_t _SymbolRootsCount", _SymbolRootsCount );
1159+
printf(" %32s -> %lu(0x%lx)\n", "uintptr_t _ObjectFileStart", _ObjectFileStart, _ObjectFileStart );
1160+
printf(" %32s -> %lu(0x%lx)\n", "uintptr_t _ObjectFileSize", _ObjectFileSize, _ObjectFileSize );
1161+
printf(" %32s -> %lu(0x%lx)\n", "NextUnshiftedClbindStamp", _NextUnshiftedClbindStamp, _NextUnshiftedClbindStamp );
1162+
printf(" %32s -> %lu(0x%lx)\n", "NextUnshiftedStamp", _NextUnshiftedStamp, _NextUnshiftedStamp );
11631163
}
11641164
};
11651165

@@ -1217,7 +1217,7 @@ struct copy_buffer_t {
12171217

12181218
size_t write_to_filedes(int filedes) {
12191219
size_t wrote = write( filedes, this->_BufferStart, this->_Size );
1220-
printf("%s:%d:%s Wrote %lu bytes from %p to filedes %d\n", __FILE__, __LINE__, __FUNCTION__, wrote, this->_BufferStart, filedes );
1220+
// printf("%s:%d:%s Wrote %lu bytes from %p to filedes %d\n", __FILE__, __LINE__, __FUNCTION__, wrote, this->_BufferStart, filedes );
12211221
return wrote;
12221222
}
12231223
};
@@ -1584,7 +1584,7 @@ struct copy_progress {
15841584
intptr_t delta = cur - this->_begin;
15851585
if (delta > this->_next_progress_tic) {
15861586
this->_next_progress_tic += this->_inc;
1587-
core::lisp_write(fmt::format("\rCopy memory to snapshot buffer {:6.2f} done ", (100.0*(float)delta/(float)this->_size)));
1587+
core::lisp_write(fmt::format("\rCopy memory to snapshot buffer {:6.2f} done ", (100.0*(float)delta/(float)this->_size)));
15881588
}
15891589
}
15901590
};
@@ -1602,7 +1602,7 @@ struct copy_objects_t : public walker_callback_t {
16021602
walker_callback_t(info),
16031603
_progress((uintptr_t)objects->_BufferStart,(uintptr_t)objects->_Size)
16041604
{};
1605-
1605+
16061606
void callback(gctools::BaseHeader_s* header) {
16071607
std::string str;
16081608
// On boehm sometimes I get unknown objects that I'm trying to avoid with the next test.
@@ -1625,7 +1625,7 @@ struct copy_objects_t : public walker_callback_t {
16251625
if (generalSize==0) ISL_ERROR(fmt::format("A zero size general at {} was encountered", (void*)clientStart ));
16261626
llvmo::ObjectFile_O* code = (llvmo::ObjectFile_O*)clientStart;
16271627
ISLGeneralHeader_s islheader( General, code->frontSize()+code->literalsSize(), (gctools::Header_s*)header, false );
1628-
char* islh = this->_objects->write_buffer( (char*)&islheader , sizeof(ISLGeneralHeader_s));
1628+
char* islh = this->_objects->write_buffer( (char*)&islheader , sizeof(ISLGeneralHeader_s));
16291629
char* new_client = this->_objects->write_buffer((char*)clientStart, code->frontSize() );
16301630
llvmo::ObjectFile_O* newObjectFile = (llvmo::ObjectFile_O*)new_client;
16311631
DBG_OF(
@@ -1934,7 +1934,7 @@ struct SaveSymbolCallback : public core::SymbolCallback {
19341934
size_t hitBadPointers = 0;
19351935
for (ssize_t ii = this->_Library._GroupedPointers.size()-1; ii>=0; --ii ) {
19361936
if (ii%1000==0 && ii>0) {
1937-
printf("%6lu remaining pointers to dladdr\n", ii );
1937+
core::lisp_write(fmt::format("\r{} remaining pointers to dladdr ", ii ));
19381938
}
19391939
uintptr_t address = this->_Library._GroupedPointers[ii]._address;
19401940
std::string saveName("");
@@ -1949,6 +1949,7 @@ struct SaveSymbolCallback : public core::SymbolCallback {
19491949
this->_Library._SymbolBuffer.push_back('\0');
19501950
}
19511951
}
1952+
core::lisp_write(fmt::format("\rAll pointers passed through dladdr \n"));
19521953
if (hitBadPointers) {
19531954
printf("There were %lu bad pointers - we need to figure out how to get this to zero\n", hitBadPointers );
19541955
abort();
@@ -2114,8 +2115,8 @@ void prepareRelocationTableForSave(Fixup* fixup, SymbolLookup& symbolLookup) {
21142115
for ( size_t idx=0; idx<fixup->_libraries.size(); idx++ ) {
21152116
int groupPointerIdx = -1;
21162117
ISLLibrary& curLib = fixup->_libraries[idx];
2117-
printf("%s:%d:%s Dealing with library#%lu: %s @%p\n", __FILE__, __LINE__, __FUNCTION__, idx, curLib._Name.c_str(), &curLib );
2118-
printf("%s:%d:%s Number of pointers before extracting unique pointers: %lu\n", __FILE__, __LINE__, __FUNCTION__, curLib._InternalPointers.size() );
2118+
// printf("%s:%d:%s Dealing with library#%lu: %s @%p\n", __FILE__, __LINE__, __FUNCTION__, idx, curLib._Name.c_str(), &curLib );
2119+
// printf("%s:%d:%s Number of pointers before extracting unique pointers: %lu\n", __FILE__, __LINE__, __FUNCTION__, curLib._InternalPointers.size() );
21192120
for ( size_t ii=0; ii<curLib._InternalPointers.size(); ii++ ) {
21202121
if (groupPointerIdx < 0 || curLib._InternalPointers[ii]._address != curLib._InternalPointers[ii-1]._address ) {
21212122
curLib._GroupedPointers.emplace_back( curLib._InternalPointers[ii]._pointerType, curLib._InternalPointers[ii]._address );
@@ -2129,17 +2130,17 @@ void prepareRelocationTableForSave(Fixup* fixup, SymbolLookup& symbolLookup) {
21292130
*curLib._InternalPointers[ii]._ptrptr = encodeRelocation_( firstByte, idx, groupPointerIdx );
21302131
// printf("%s:%d:%s to %p\n", __FILE__, __LINE__, __FUNCTION__, (void*)*curLib._InternalPointers[ii]._ptrptr );
21312132
}
2132-
printf("%s:%d:%s Number of unique pointers: %lu\n", __FILE__, __LINE__, __FUNCTION__, curLib._GroupedPointers.size() );
2133+
core::lisp_write(fmt::format("{} unique pointers need to be passed to dladdr\n", curLib._GroupedPointers.size() ));
21332134
SaveSymbolCallback thing(curLib);
21342135
curLib._SymbolInfo.resize(curLib._GroupedPointers.size(),SymbolInfo());
21352136
thing.generateSymbolTable(fixup,symbolLookup);
2136-
printf("%s:%d:%s Library #%lu contains %lu grouped pointers\n", __FILE__, __LINE__, __FUNCTION__, idx, curLib._GroupedPointers.size() );
2137+
core::lisp_write(fmt::format("Library #{} {} contains {} unique pointers\n", idx, curLib._Name, curLib._GroupedPointers.size() ));
21372138
for ( size_t ii=0; ii<curLib._SymbolInfo.size(); ii++ ) {
21382139
if (curLib._SymbolInfo[ii]._SymbolLength<0) {
2139-
printf("%s:%d:%s The _SymbolInfo[%lu] does not have an length\n", __FILE__, __LINE__, __FUNCTION__, ii );
2140+
printf("%s:%d:%s The _SymbolInfo[%lu] does not have a length\n", __FILE__, __LINE__, __FUNCTION__, ii );
21402141
}
21412142
}
2142-
printf("%s:%d:%s Done with library: %s @%p\n", __FILE__, __LINE__, __FUNCTION__, curLib._Name.c_str(), &curLib );
2143+
core::lisp_write(fmt::format("Done with library #{} at {}\n", curLib._Name, (void*)&curLib ));
21432144
}
21442145
DBG_SLS("Step done\n" );
21452146
}
@@ -2516,7 +2517,7 @@ void* snapshot_save_impl(void* data) {
25162517
fixup_vtables_t fixup_vtables( &fixup, (uintptr_t)start, (uintptr_t)end, &islInfo );
25172518
walk_snapshot_save_load_objects((ISLHeader_s*)snapshot._Memory->_BufferStart,fixup_vtables);
25182519
}
2519-
2520+
core::lisp_write(fmt::format("Copy memory done\n"));
25202521

25212522
//
25222523
// Now generate libraries
@@ -2604,7 +2605,7 @@ void* snapshot_save_impl(void* data) {
26042605
}
26052606
filename = tfbuffer;
26062607
}
2607-
printf("Writing snapshot to %s filedes = %d\n", filename.c_str(), filedes );
2608+
printf("Writing snapshot to temporary file %s filedes = %d\n", filename.c_str(), filedes );
26082609
snapshot._HeaderBuffer->write_to_filedes(filedes);
26092610
snapshot._Libraries->write_to_filedes(filedes);
26102611
snapshot._Memory->write_to_filedes(filedes);
@@ -2679,7 +2680,7 @@ void* snapshot_save_impl(void* data) {
26792680
printf("%s:%d:%s global_badge_count = %lu\n", __FILE__, __LINE__, __FUNCTION__, global_badge_count );
26802681
#endif
26812682
#ifdef USE_BOEHM
2682-
printf("%s:%d:%s Not using GC_start_world_external();\n", __FILE__, __LINE__, __FUNCTION__ );
2683+
// printf("%s:%d:%s Not using GC_start_world_external();\n", __FILE__, __LINE__, __FUNCTION__ );
26832684
#endif
26842685
exit(0);
26852686
}
@@ -2752,7 +2753,7 @@ void snapshot_save(core::SaveLispAndDie& data) {
27522753
// For saving we may want to save snapshots and not die - so use noStomp forwarding.
27532754
//
27542755
global_forwardingKind = noStomp;
2755-
printf("%s:%d:%s Updated with noStomp forwarding for snapshot_save\n", __FILE__, __LINE__, __FUNCTION__ );
2756+
core::lisp_write(fmt::format("Updated with noStomp forwarding for snapshot_save\n"));
27562757
//
27572758
// Call Common Lisp code to release things at snapshot-save time
27582759
//
@@ -2761,7 +2762,7 @@ void snapshot_save(core::SaveLispAndDie& data) {
27612762
core::eval::funcall( comp::_sym_invoke_save_hooks );
27622763
}
27632764

2764-
printf("%s:%d:%s Finished invoking cmp:invoke-save-hooks\n", __FILE__, __LINE__, __FUNCTION__ );
2765+
core::lisp_write(fmt::format("Finished invoking cmp:invoke-save-hooks\n"));
27652766

27662767
#if defined(USE_BOEHM)
27672768
GC_call_with_alloc_lock( snapshot_save_impl, &data );

0 commit comments

Comments
 (0)