MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / loaddebugmemhunkfile

Function loaddebugmemhunkfile

src/debugmem.cpp:1650–1862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1648}
1649
1650static uaecptr loaddebugmemhunkfile(uae_u8 *p, uae_u32 len, uae_u32 *parentidp)
1651{
1652 uae_u8 *lastptr = NULL;
1653 struct debugmemallocs *hunks[1000];
1654 uae_u32 lens[1000], memtypes[1000];
1655 uae_u32 parentid = 0;
1656
1657 p += 4;
1658 if (gl(p) != 0) {
1659 console_out_f(_T("Long word after HUNK_HEADER is not zero!\n"));
1660 return 0;
1661 }
1662 p += 4;
1663 int hunktotal = gl(p);
1664 int first = gl(p + 4);
1665 int last = gl(p + 8);
1666 if (hunktotal > 1000 || (last - first + 1) > 1000) {
1667 console_out_f(_T("Too many hunks.\n"));
1668 return 0;
1669 }
1670 if (first > last) {
1671 console_out_f(_T("First hunk larger than last hunk (%d > %d).\n"), first, last);
1672 return 0;
1673 }
1674 p += 12;
1675 uae_u32 relative_start = 0;
1676 for (int i = first; i <= last; i++) {
1677 uae_u32 len = gl(p);
1678 p += 4;
1679 memtypes[i] = 0;
1680 if ((len & 0xc0000000) == 0xc0000000) {
1681 memtypes[i] = gl(p);
1682 p += 4;
1683 } else if (len & 0x40000000) {
1684 memtypes[i] = 0x40000000;
1685 } else {
1686 memtypes[i] = len & 0xc0000000;
1687 }
1688 len &= ~(0x80000000 | 0x40000000);
1689 lens[i] = len * 4;
1690 struct debugmemallocs *dma = debugmem_allocate(lens[i] + 8, DEBUGMEM_READ | DEBUGMEM_WRITE | DEBUGMEM_FETCH | DEBUGMEM_INITIALIZED, parentid);
1691 hunks[i] = dma;
1692 dma->type = DEBUGALLOC_HUNK;
1693 dma->relative_start = relative_start;
1694 relative_start += lens[i];
1695 if (!hunks[i]) {
1696 console_out_f(_T("Hunk #%d memory allocation failed, size %d\n"), i, len + 8);
1697 return 0;
1698 }
1699 if (!parentid) {
1700 parentid = hunks[i]->id;
1701 }
1702 linemapsize += lens[i];
1703 }
1704 int hunkcnt = first - 1;
1705 for (;;) {
1706 uae_u32 hunktype = gl(p) & ~0xc0000000;
1707

Callers 1

debugmem_relocFunction · 0.85

Calls 8

debugmem_allocateFunction · 0.85
put_byte_hostFunction · 0.85
put_long_hostFunction · 0.85
get_long_hostFunction · 0.85
auFunction · 0.85
glFunction · 0.70
gwFunction · 0.70
console_out_fFunction · 0.50

Tested by

no test coverage detected