/************************************************************* Writes the Hunk and Offset of the given Address into buf *************************************************************/ static int enforcer_decode_hunk_and_offset (TCHAR *buf, uae_u32 pc) { uae_u32 sysbase = get_long (4); uae_u32 semaphore_list = sysbase + 532; uae_u32 library_list = sysbase + 378; /* First step is searching for the SegTracker semaphore */ uae_u32 node = amiga_list_first (semaphore_list); while (node) { uae_u32 string = get_long (node + 10); /* ln_Name */ uae_u8 *native_string = amiga2native (string, 100); if (native_string) { if (!strcmp ((char*)native_string, "SegTracker")) break; } node = amiga_node_next (node); } if (node) { /* We have found the segtracker semaphore. Soon after the * public documented semaphore structure Segtracker holds * an own list of all segements. We will use this list to * find out the hunk and offset (simliar to segtracker). * * Source of segtracker can be found at: * http://www.sinz.org/Michael.Sinz/Enforcer/SegTracker.c.html */ uae_u32 seg_list = node + 46 + 4; /* sizeof(struct SignalSemaphore) + seg find */ node = amiga_list_first (seg_list); while (node) { uae_u32 seg_entry = node + 12; uae_u32 address, size; int hunk = 0; /* Go through all entries until an address is 0 * or the segment has been found */ while ((address = get_long (seg_entry))) { size = get_long (seg_entry + 4); if (pc > address && pc < address + size) { uae_u32 name, offset; TCHAR *native_name; offset = pc - address - 4; name = get_long (node + 8); /* ln_Name */ if (name) { native_name = au ((char*)amiga2native(name,100)); if (!native_name) native_name = my_strdup (_T("Unknown")); } else { native_name = my_strdup (_T("Unknown")); } _stprintf (buf, _T("----> %08x - \"%s\" Hunk %04x Offset %08x\n"), pc, native_name, hunk, offset); xfree (native_name); return 1; } seg_entry += 8; hunk++; } node = amiga_node_next (node); } } node = amiga_list_first (library_list); while (node) { uae_u32 string = get_long (node + 10); /* ln_Name */ uae_u8 *native_string = amiga2native (string, 100); if (native_string) { if (!strcmp ((char*)native_string, "debug.library")) break; } node = amiga_node_next (node); } /* AROS debug.library */ if (node) { uae_u32 seg_list = node + 34; /* sizeof(struct Library) */ node = amiga_list_first (seg_list); while (node) { uae_u32 start = get_long (node + 12); uae_u32 end = get_long (node + 16); if (pc > start && pc < end) { TCHAR *native_name; uae_u32 hunk = get_long (node + 28); uae_u32 offset = pc - (get_long (node + 8) << 2); uaecptr mod = get_long (node + 20); native_name = au ((char*)amiga2native (mod + 24, 100)); _stprintf (buf, _T("----> %08x - \"%s\" Hunk %04x Offset %08x\n"), pc, native_name, hunk, offset); xfree (native_name); return 1; } node = amiga_node_next (node); } } return 0; }
/************************************************************* Writes the Hunk and Offset of the given Address into buf *************************************************************/ static int enforcer_decode_hunk_and_offset (char *buf, uae_u32 pc) { uae_u32 sysbase = get_long(4); uae_u32 semaphore_list = sysbase + 532; /* First step is searching for the SegTracker semaphore */ uae_u32 node = amiga_list_first (semaphore_list); while (node) { uae_u32 string = get_long (node + 10); /* ln_Name */ uae_u8 *native_string = amiga2native (string, 100); if (native_string) { if (!strcmp ((char *) native_string, "SegTracker")) break; } node = amiga_node_next (node); } if (node) { /* We have found the segtracker semaphore. Soon after the * public documented semaphore structure Segtracker holds * an own list of all segements. We will use this list to * find out the hunk and offset (simliar to segtracker). * * Source of segtracker can be found at: * http://www.sinz.org/Michael.Sinz/Enforcer/SegTracker.c.html */ uae_u32 seg_list = node + 46 + 4; /* sizeof(struct SignalSemaphore) + seg find */ node = amiga_list_first (seg_list); while (node) { uae_u32 seg_entry = node + 12; uae_u32 address, size; int hunk = 0; /* Go through all entries until an address is 0 * or the segment has been found */ while ((address = get_long (seg_entry))) { size = get_long (seg_entry + 4); if (pc >= address && pc < address + size) { uae_u32 name, offset; const char *native_name; offset = pc - address - 4; name = get_long (node + 8); /* ln_Name */ if (name) { native_name = (char *) amiga2native (name, 100); if (!native_name) native_name = "Unknown"; } else native_name = "Unknown"; sprintf (buf, "----> %08lx - \"%s\" Hunk %04lx Offset %08lx\n", pc, native_name, hunk, offset); return 1; } seg_entry += 8; hunk++; } node = amiga_node_next (node); } } return 0; }