use USER_CPPFLAGS
[AROS.git] / arch / m68k-all / debug / segtracker.c
blobc703689e562b406ff4324a9832dcf056c59added
1 /*
2 Copyright © 1995-2018, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: m68k SegTracker emulation.
6 */
8 #include <aros/config.h>
9 #include <aros/debug.h>
10 #include <libraries/debug.h>
11 #include <proto/exec.h>
12 #include <proto/debug.h>
14 #include "debug_intern.h"
16 struct SegSem
18 struct SignalSemaphore seg_Semaphore;
19 APTR seg_Find;
20 /* Dummy list for programs that directly
21 * read SegTracker segment list.
23 struct MinList seg_List;
25 #define SEG_SEM "SegTracker"
27 static AROS_UFH3(UBYTE*, SegTrack,
28 AROS_UFHA(ULONG, Address, A0),
29 AROS_UFHA(ULONG*, SegNum, A1),
30 AROS_UFHA(ULONG*, Offset, A2))
32 AROS_USERFUNC_INIT
34 /* Bad code again but SegTrack() may be called in Supervisor context.. */
35 struct DebugBase *DebugBase = (struct DebugBase*)FindName(&SysBase->LibList, "debug.library");
36 if (DebugBase) {
37 ULONG segNum2;
38 BPTR segPtr, firstSeg;
39 char *modName;
40 if (DecodeLocation((APTR)Address, DL_SegmentNumber, &segNum2, DL_SegmentPointer, &segPtr,
41 DL_FirstSegment, &firstSeg, DL_ModuleName, &modName, TAG_DONE)) {
42 if (SegNum == Offset) {
43 *SegNum = firstSeg;
44 } else {
45 *SegNum = segNum2;
46 *Offset = Address - (ULONG)BADDR(segPtr);
48 return modName;
52 return NULL;
54 AROS_USERFUNC_EXIT
57 static int SegTracker_Init(struct DebugBase *DebugBase)
59 struct SegSem *ss;
61 ss = AllocMem(sizeof(struct SegSem), MEMF_CLEAR | MEMF_PUBLIC);
62 if (ss) {
63 ss->seg_Semaphore.ss_Link.ln_Name = SEG_SEM;
64 ss->seg_Semaphore.ss_Link.ln_Pri = -127;
65 ss->seg_Find = SegTrack;
66 NEWLIST((struct List*)&ss->seg_List);
67 AddSemaphore(&ss->seg_Semaphore);
69 return 1;
72 ADD2INITLIB(SegTracker_Init, -100)