mirror of
https://github.com/LIV2/lide.device.git
synced 2025-12-06 00:32:45 +00:00
Add debug for Alloc/FreeMem
This commit is contained in:
parent
061bc22c04
commit
7468dc0129
28
debug.c
28
debug.c
@ -1,5 +1,6 @@
|
||||
#include <exec/io.h>
|
||||
#include <exec/errors.h>
|
||||
#include <inline/exec.h>
|
||||
#include <devices/trackdisk.h>
|
||||
#include <devices/scsidisk.h>
|
||||
|
||||
@ -7,6 +8,33 @@
|
||||
#include "debug.h"
|
||||
#include "newstyle.h"
|
||||
|
||||
#if DEBUG & DBG_MEM
|
||||
static int memused = 0;
|
||||
|
||||
#define OrigAllocMem(___byteSize, ___requirements) \
|
||||
LP2(0xc6, APTR, AllocMem , ULONG, ___byteSize, d0, ULONG, ___requirements, d1,\
|
||||
, EXEC_BASE_NAME)
|
||||
|
||||
#define OrigFreeMem(___memoryBlock, ___byteSize) \
|
||||
LP2NR(0xd2, FreeMem , APTR, ___memoryBlock, a1, ULONG, ___byteSize, d0,\
|
||||
, EXEC_BASE_NAME)
|
||||
|
||||
void * DebugAllocMem(char *file, int line, ULONG byteSize, ULONG requirements)
|
||||
{
|
||||
struct ExecBase *SysBase = *(struct ExecBase **)4UL;
|
||||
KPrintF("AllocMem: %s:%ld %ld %ld\n", file,line, memused, byteSize);
|
||||
memused += byteSize;
|
||||
return OrigAllocMem(byteSize,requirements);
|
||||
}
|
||||
|
||||
void DebugFreeMem(char *file, int line, void *memBlock, ULONG byteSize) {
|
||||
struct ExecBase *SysBase = *(struct ExecBase **)4UL;
|
||||
KPrintF("FreeMem: %s:%ld %ld %ld\n", file, line, memused, byteSize);
|
||||
memused -= byteSize;
|
||||
OrigFreeMem(memBlock,byteSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DEBUG & DBG_CMD
|
||||
|
||||
void traceCommand(struct IOStdReq *req) {
|
||||
|
||||
11
debug.h
11
debug.h
@ -6,11 +6,22 @@
|
||||
#define DBG_WARN 2
|
||||
#define DBG_TRACE 4
|
||||
#define DBG_CMD 8
|
||||
#define DBG_MEM 16
|
||||
|
||||
#if DEBUG
|
||||
#include <clib/debug_protos.h>
|
||||
#endif
|
||||
|
||||
#if DEBUG & DBG_MEM
|
||||
void * DebugAllocMem(char *file, int line, ULONG byteSize, ULONG attributes);
|
||||
#undef AllocMem
|
||||
#define AllocMem(x,y) DebugAllocMem(__FILE__,__LINE__,x,y)
|
||||
|
||||
void DebugFreeMem(char *file, int line, void *memBlock, ULONG byteSize);
|
||||
#undef FreeMem
|
||||
#define FreeMem(x,y) DebugFreeMem(__FILE__,__LINE__,x,y)
|
||||
#endif
|
||||
|
||||
#if DEBUG & DBG_INFO
|
||||
#define Info KPrintF
|
||||
#else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user