summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2020-05-19 15:52:03 +0800
committerMoritz Angermann <moritz.angermann@gmail.com>2020-06-04 04:55:51 -0400
commit6a4098a4bb89b3d30cca26d82b82724913062536 (patch)
treef1a74f803a6cc2e3f13723adb6af26c35adc2c38 /rts
parentad44b50484f27beceab8213a061aa60c7a03f7ca (diff)
downloadhaskell-6a4098a4bb89b3d30cca26d82b82724913062536.tar.gz
[linker] Adds void printLoadedObjects(void);wip/angerman/print-loaded-objects
This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype
Diffstat (limited to 'rts')
-rw-r--r--rts/Linker.c30
-rw-r--r--rts/LinkerInternals.h2
2 files changed, 30 insertions, 2 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 21abcc6e86..cb1373fd37 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -873,8 +873,9 @@ SymbolAddr* lookupSymbol_ (SymbolName* lbl)
* Symbol name only used for diagnostics output.
*/
SymbolAddr* loadSymbol(SymbolName *lbl, RtsSymbolInfo *pinfo) {
- IF_DEBUG(linker, debugBelch("lookupSymbol: value of %s is %p\n", lbl,
- pinfo->value));
+ IF_DEBUG(linker, debugBelch("lookupSymbol: value of %s is %p, owned by %s\n", lbl,
+ pinfo->value,
+ pinfo->owner ? OC_INFORMATIVE_FILENAME(pinfo->owner) : "No owner, probably built-in."));
ObjectCode* oc = pinfo->owner;
/* Symbol can be found during linking, but hasn't been relocated. Do so now.
@@ -898,6 +899,27 @@ SymbolAddr* loadSymbol(SymbolName *lbl, RtsSymbolInfo *pinfo) {
return pinfo->value;
}
+void
+printLoadedObjects() {
+ ObjectCode* oc;
+ for (oc = objects; oc; oc = oc->next) {
+ if (oc->sections != NULL) {
+ int i;
+ printf("%s\n", OC_INFORMATIVE_FILENAME(oc));
+ for (i=0; i < oc->n_sections; i++) {
+ if(oc->sections[i].mapped_start != NULL || oc->sections[i].start != NULL) {
+ printf("\tsec %2d[alloc: %d; kind: %d]: %p - %p; mmaped: %p - %p\n",
+ i, oc->sections[i].alloc, oc->sections[i].kind,
+ oc->sections[i].start,
+ (void*)((uintptr_t)(oc->sections[i].start) + oc->sections[i].size),
+ oc->sections[i].mapped_start,
+ (void*)((uintptr_t)(oc->sections[i].mapped_start) + oc->sections[i].mapped_size));
+ }
+ }
+ }
+ }
+}
+
SymbolAddr* lookupSymbol( SymbolName* lbl )
{
ACQUIRE_LOCK(&linker_mutex);
@@ -905,6 +927,7 @@ SymbolAddr* lookupSymbol( SymbolName* lbl )
if (!r) {
errorBelch("^^ Could not load '%s', dependency unresolved. "
"See top entry above.\n", lbl);
+ IF_DEBUG(linker, printLoadedObjects());
fflush(stderr);
}
RELEASE_LOCK(&linker_mutex);
@@ -1720,6 +1743,9 @@ static HsInt resolveObjs_ (void)
r = ocTryLoad(oc);
if (!r)
{
+ errorBelch("Could not load Object Code %s.\n", OC_INFORMATIVE_FILENAME(oc));
+ IF_DEBUG(linker, printLoadedObjects());
+ fflush(stderr);
return r;
}
}
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h
index 6ecf742fd4..8a2aaee354 100644
--- a/rts/LinkerInternals.h
+++ b/rts/LinkerInternals.h
@@ -16,6 +16,8 @@
#include <sys/mman.h>
#endif
+void printLoadedObjects(void);
+
#include "BeginPrivate.h"
typedef void SymbolAddr;