Skip to content
Tags

Emergency Debugging

August 28, 2015

I have some kind of evil problem with the web server where it is going into a loop or hanging somewhere. It’s probably a memory overwrite. I beat my head against it with diagnostic prints but no joy. I decided to do an emergency dump of registers and memory on startup and put a routine to print the dump into the first part of the web server.
The dump routine I put into LCC1802epiloDH which has the startup routines that prep the registers and give control to main(). Before initializing the regs I dump regs 1-14(0 and 15 are already corrupted), then copy memory from 0-100 and the top 128 bytes of the stack page into a reserved area(I moved the runtime stack down to start at 7EFF and the emergency dump area is 7F00:7FFF).
The code is in sastore.inc included into lcc1802epilodh and sadump.c included into the main routine. The output looks correct, now I just need a failure.

15:25:55.529> low memory
15:25:55.607> 0000: C027 7400 0000 0000 0000 2222 2287 7397
15:25:55.732> 0008: 5222 2222 228C A79C B782 FC06 AE92 7C00
15:25:55.732> 0010: BEF8 005E 1EF8 035E F86E ACF8 27BC 82FC
15:25:55.732> 0018: 06AD 927C 00BD D412 C5F8 69AC F827 BCF8
15:25:55.928> 0020: 80AD F822 BDD4 12C5 07AC F800 BCF8 80AD
15:25:55.928> 0028: F822 BDD4 0EC5 8FAB 9FBB 8BAC 9BBC D420
15:25:55.928> 0030: DCF8 63AC 0014 7ECF 0D0E 2901 2912 0D92
15:25:55.928> 
15:25:55.928> registers 1-14
15:25:55.928> 0001: 0014
15:25:55.928> 0002: 7ECF
15:25:55.928> 0003: 0D0E
15:25:55.928> 0004: 2901
15:25:55.928> 0005: 2912
15:25:55.928> 0006: 0D92
15:25:55.928> 0007: 0014
15:25:55.928> 0008: 7EC9
15:25:56.264> 0009: FEF3
15:25:56.264> 000A: 0000
15:25:56.264> 000B: 0014
15:25:56.264> 000C: 0014
15:25:56.264> 000D: 002E
15:25:56.264> 000E: 7EF8
15:25:56.264> 
15:25:56.264> stack area
15:25:56.264> 7E80: 0C7E 8900 010A A000 3100 0022 8000 3167
15:25:56.264> 7E90: D311 5300 0400 6400 6414 3100 017E 9F31
15:25:56.264> 7EA0: 0038 0027 0A67 D37E C300 0103 7600 801E
15:25:56.264> 7EB0: 9000 1000 001D 5E0C 1A24 3067 D312 C000
15:25:56.264> 7EC0: 0000 0819 8500 2E67 D37E DD00 010C 2600
15:25:56.264> 7ED0: 070C 5700 1400 800D 537F 0027 6200 0014
15:25:56.807> 7EE0: 2804 0014 2801 0017 C0A8 00B6 0D8F 6922
15:25:56.807> 7EF0: 9828 0400 1028 0100 14C0 A800 B601 3C69
sastore.inc
;Standalone reg save included at front of lcc1802init
	seq
	ldad r15,0x7f00+127	;begin register save
	sex r15			;set up for reg saves
	pushm r14
	pushm r13
	pushm r12
	pushm r11
	pushm r10
	pushm r9
	pushm r8
	pushm r7
	pushm r6
	pushm r5
	pushm r4
	pushm r3
	pushm r2
	pushm r1
;now copy 1st 100 bytes of  main memory
	ldad r15,0x7f00
	ldad r14,0x0000
	ldad r13,100
$$stm:
	lda r14
	str r15
	inc r15
	dec r13
	glo r13
	bnz $$stm
;now copy top 128 bytes of  stack area
	ldad r15,0x7f80
	ldad r14,0x7e80
	ldad r13,128
	
$$stk:
	lda r14
	str r15
	inc r15
	dec r13
	glo r13
	bnz $$stk
;end of standalone save
	req
	
sadump.c
//sadump print the contents of memory block 7f00-ff
//where init has saved registers and diagnostics
	unsigned int * sadptr=(unsigned int *)0x7f00;//pointer to sadump block
	unsigned int saloop;
	printf("\nlow memory\n");
	for (saloop=0; saloop<50;saloop+=8){
		printf("%x: %x %x %x %x %x %x %x %x\n",
				saloop, sadptr[saloop],sadptr[saloop+1],sadptr[saloop+2],sadptr[saloop+3],sadptr[saloop+4],sadptr[saloop+5],sadptr[saloop+6],sadptr[saloop+7]);
	}
	printf("\nregisters 1-14\n");
	for (saloop=1; saloop<15;saloop+=1){
		printf("%x: %x\n",
				saloop, sadptr[saloop+49]);
	}
	printf("\nstack area\n");
	for (saloop=64; saloop<128;saloop+=8){
		printf("%x: %x %x %x %x %x %x %x %x\n",
				saloop*2+0x7e00, sadptr[saloop],sadptr[saloop+1],sadptr[saloop+2],sadptr[saloop+3],sadptr[saloop+4],sadptr[saloop+5],sadptr[saloop+6],sadptr[saloop+7]);
	}
Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: