oops .. forgot to offset from objects bounds
[AROS.git] / rom / dos / internalloadseg_support.c
blob51c99f5bd79f9409d23e4d954b62416b071ad4db
1 #include <aros/config.h>
2 #include <libraries/debug.h>
3 #include <proto/debug.h>
4 #include <proto/dos.h>
5 #include <proto/exec.h>
7 #include "dos_intern.h"
8 #include "internalloadseg.h"
10 static char *getname(BPTR file, char **bufferp, struct DosLibrary *DOSBase)
12 /* Some applications pass a non-filehandle to
13 * Dos/InternalLoadSeg, so don't try to register
14 * the hunks if this is not a real FileHandle
16 * A real-life example of this is C:AddDataTypes
17 * from AmigaOS 3.9
19 if (ISFILEHANDLE(file) && DOSBase) {
20 char *buffer = AllocMem(512, MEMF_ANY);
21 if (buffer) {
22 *bufferp = buffer;
23 if (NameFromFH(file, buffer, 512)) {
24 char *nameptr = buffer;
25 /* gdb support needs full paths */
26 #if !AROS_MODULES_DEBUG
27 /* First, go through the name, till end of the string */
28 while(*nameptr++);
29 /* Now, go back until either ":" or "/" is found */
30 while(nameptr > buffer && nameptr[-1] != ':' && nameptr[-1] != '/')
31 nameptr--;
32 #endif
33 return nameptr;
37 return "unknown";
40 void register_elf(BPTR file, BPTR hunks, struct elfheader *eh, struct sheader *sh, struct DosLibrary *DOSBase)
42 if (DOSBase && DebugBase)
44 char *buffer = NULL;
45 char *nameptr = getname(file, &buffer, DOSBase);
46 struct ELF_DebugInfo dbg = {eh, sh};
47 RegisterModule(nameptr, hunks, DEBUG_ELF, &dbg);
48 FreeMem(buffer, 512);
52 #undef DebugBase
53 /* DOSBase is NULL if called by m68k RDB filesystem loader.
54 * No DosBase = Open debug.library manually, this enables
55 * us to have RDB segments in debug.library list.
57 void register_hunk(BPTR file, BPTR hunks, APTR header, struct DosLibrary *DOSBase)
59 struct Library *DebugBase;
60 if (DOSBase)
61 DebugBase = IDosBase(DOSBase)->debugBase;
62 else
63 DebugBase = OpenLibrary("debug.library", 0);
64 if (DebugBase)
66 char *buffer = NULL;
67 char *nameptr = getname(file, &buffer, DOSBase);
68 struct HUNK_DebugInfo dbg = { header };
69 RegisterModule(nameptr, hunks, DEBUG_HUNK, &dbg);
70 FreeMem(buffer, 512);
72 if (!DOSBase)
73 CloseLibrary(DebugBase);