summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@well-typed.com>2022-03-16 21:54:24 -0400
committerBen Gamari <ben@well-typed.com>2022-03-17 00:05:02 -0400
commit56a4fad535bae7b10550c5dcc11aea1cfc28806d (patch)
treeae598934d4c85fe9d546c320a6c44cbf6ccb4f77
parentac41b3415bfe8dac52d659bfa9488706fcf92eeb (diff)
downloadhaskell-56a4fad535bae7b10550c5dcc11aea1cfc28806d.tar.gz
rts/linker: More descriptive debug output
-rw-r--r--rts/Linker.c27
-rw-r--r--rts/LinkerInternals.h6
2 files changed, 21 insertions, 12 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 4241235e67..383f68abc8 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1116,7 +1116,7 @@ freePreloadObjectFile (ObjectCode *oc)
*/
void freeObjectCode (ObjectCode *oc)
{
- IF_DEBUG(linker, debugBelch("freeObjectCode: %" PATH_FMT, oc->fileName));
+ IF_DEBUG(linker, ocDebugBelch(oc, "start\n"));
if (oc->type == DYNAMIC_OBJECT) {
#if defined(OBJFORMAT_ELF)
@@ -1479,7 +1479,7 @@ HsInt loadOc (ObjectCode* oc)
{
int r;
- IF_DEBUG(linker, debugBelch("loadOc: start (%" PATH_FMT ")\n", oc->fileName));
+ IF_DEBUG(linker, ocDebugBelch(oc, "start\n"));
/* verify the in-memory image */
# if defined(OBJFORMAT_ELF)
@@ -1492,7 +1492,7 @@ HsInt loadOc (ObjectCode* oc)
barf("loadObj: no verify method");
# endif
if (!r) {
- IF_DEBUG(linker, debugBelch("loadOc: ocVerifyImage_* failed\n"));
+ IF_DEBUG(linker, ocDebugBelch(oc, "ocVerifyImage_* failed\n"));
return r;
}
@@ -1518,14 +1518,14 @@ HsInt loadOc (ObjectCode* oc)
r = ocAllocateExtras_MachO ( oc );
if (!r) {
IF_DEBUG(linker,
- debugBelch("loadOc: ocAllocateExtras_MachO failed\n"));
+ ocDebugBelch(oc, "ocAllocateExtras_MachO failed\n"));
return r;
}
# elif defined(OBJFORMAT_ELF)
r = ocAllocateExtras_ELF ( oc );
if (!r) {
IF_DEBUG(linker,
- debugBelch("loadOc: ocAllocateExtras_ELF failed\n"));
+ ocDebugBelch(oc, "ocAllocateExtras_ELF failed\n"));
return r;
}
# endif
@@ -1542,7 +1542,7 @@ HsInt loadOc (ObjectCode* oc)
barf("loadObj: no getNames method");
# endif
if (!r) {
- IF_DEBUG(linker, debugBelch("loadOc: ocGetNames_* failed\n"));
+ IF_DEBUG(linker, ocDebugBelch(oc, "ocGetNames_* failed\n"));
return r;
}
@@ -1557,7 +1557,7 @@ HsInt loadOc (ObjectCode* oc)
oc->status = OBJECT_LOADED;
}
}
- IF_DEBUG(linker, debugBelch("loadOc: done (%" PATH_FMT ").\n", oc->fileName));
+ IF_DEBUG(linker, ocDebugBelch(oc, "done\n"));
return 1;
}
@@ -1598,6 +1598,7 @@ int ocTryLoad (ObjectCode* oc) {
}
}
+ IF_DEBUG(linker, ocDebugBelch(oc, "resolving\n"));
# if defined(OBJFORMAT_ELF)
r = ocResolve_ELF ( oc );
# elif defined(OBJFORMAT_PEi386)
@@ -1609,6 +1610,7 @@ int ocTryLoad (ObjectCode* oc) {
# endif
if (!r) { return r; }
+ IF_DEBUG(linker, ocDebugBelch(oc, "protecting mappings\n"));
#if defined(NEED_SYMBOL_EXTRAS)
ocProtectExtras(oc);
#endif
@@ -1622,7 +1624,7 @@ int ocTryLoad (ObjectCode* oc) {
// run init/init_array/ctors/mod_init_func
- IF_DEBUG(linker, debugBelch("ocTryLoad: ocRunInit start\n"));
+ IF_DEBUG(linker, ocDebugBelch(oc, "running initializers\n"));
// See Note [Tracking foreign exports] in ForeignExports.c
foreignExportsLoadingObject(oc);
@@ -1639,6 +1641,7 @@ int ocTryLoad (ObjectCode* oc) {
if (!r) { return r; }
+ IF_DEBUG(linker, ocDebugBelch(oc, "resolved\n"));
oc->status = OBJECT_RESOLVED;
return 1;
@@ -1909,19 +1912,19 @@ initSegment (Segment *s, void *start, size_t size, SegmentProt prot, int n_secti
void freeSegments (ObjectCode *oc)
{
if (oc->segments != NULL) {
- IF_DEBUG(linker, debugBelch("freeSegments: freeing %d segments\n", oc->n_segments));
+ IF_DEBUG(linker, ocDebugBelch(oc, "freeing %d segments\n", oc->n_segments));
for (int i = 0; i < oc->n_segments; i++) {
Segment *s = &oc->segments[i];
- IF_DEBUG(linker, debugBelch("freeSegments: freeing segment %d at %p size %zu\n",
- i, s->start, s->size));
+ IF_DEBUG(linker, ocDebugBelch(oc, "freeing segment %d at %p size %zu\n",
+ i, s->start, s->size));
stgFree(s->sections_idx);
s->sections_idx = NULL;
if (0 == s->size) {
- IF_DEBUG(linker, debugBelch("freeSegment: skipping segment of 0 size\n"));
+ IF_DEBUG(linker, ocDebugBelch(oc, "skipping segment of 0 size\n"));
continue;
} else {
#if RTS_LINKER_USE_MMAP
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h
index 8177a0fd03..1994a0c070 100644
--- a/rts/LinkerInternals.h
+++ b/rts/LinkerInternals.h
@@ -356,6 +356,12 @@ struct _ObjectCode {
(OC)->fileName \
)
+#define ocDebugBelch(oc, s, ...) \
+ debugBelch("%s(%" PATH_FMT ": " s, \
+ __func__, \
+ OC_INFORMATIVE_FILENAME(oc), \
+ ##__VA_ARGS__)
+
#if defined(THREADED_RTS)
extern Mutex linker_mutex;