[comp.sys.mac.programmer] Core Dump

kent@lloyd.camex.uucp (Kent Borg) (08/15/88)

Is there a way from Macsbug to do a "core dump" to disk?  Recently when 
pasteing some text into uw, my Macintosh Plus crashed.  Using Macsbug I 
managed to find (3 copies of) my text and copy 3 pages by hand.  I would
gladly been willing to type in quite a few lines of opcodes if it ment I
could have used a text editor to find my text, and not have had to write 
it out be hand.  I have yet to type it back in.

Also, in searching through my megabyte I found several ASCII references to 
Mishawana and Mishawana Bold (I think I have the name right).  Sounds like 
a font name.  I've never installed it, I have never seen it an any font
menu, I've never heard of it.  What is it?

Kent Borg
kent@lloyd.uucp
or 
hscfvax!lloyd!kent

gandreas@umn-d-ub.D.UMN.EDU (Glenn Andreas) (08/16/88)

In article <136@lloyd.camex.uucp> kent@lloyd.camex.uucp (Kent Borg) writes:
>Is there a way from Macsbug to do a "core dump" to disk?  Recently when 
>pasteing some text into uw, my Macintosh Plus crashed.  Using Macsbug I 
>managed to find (3 copies of) my text and copy 3 pages by hand.  I would
>gladly been willing to type in quite a few lines of opcodes if it ment I
>could have used a text editor to find my text, and not have had to write 
>it out be hand.  I have yet to type it back in.

Well, there sort of is a way.  Kindof.  But it's not very easy.  And off
hand I don't remember the exact details, but here is the general procedure.

	First, figure out where the information you want is in the memory
	and how big it is.

	Now lower the low memory variable 'BufPtr' by the size of the data.
	Also set A7 (SP) (and maybe A6 for the hell of it) to that new
	BufPtr value.  This reserves memory above the (new) stack for you to
	move your data.

	Now load A0 with the address of your data, A1 with the value of
	BufPtr, and D0 with the size of the data. (You can double check this
	by looking up BlockMove in IM).

	Find a free place in memory (i.e. a free block as shown by MacsBug,
	so you don't frag the heap too bad) and code in the traps for
	BlockMove followed by ExitToShell.  Set the PC to this and "g".
	This will copy your data above the stack and exit back to the finder.

	Now you need a program that will copy things from any location in
	memory to a disk file.  Off hand, I can't think of any program that
	would do this, but something in Pascal would look somewhat like this:

		PROGRAM CoreDump(input,output);

		USES MemTypes,QuickDraw,OSIntf,ToolIntf,PackIntf;
		
		VAR f,e:INTEGER; fromAddr,size:LongInt;
		
		FUNCTION MemToDisk(fromAddr,size:LongInt; toFile:INTEGER):
			INTEGER; { returns error code from write }
		BEGIN
			MemToDisk:=FSWrite(toFile,Pointer(fromAddr),size);
		END;

		BEGIN
			f:= Your favorite funtion that uses GetStdFile
				to open a file and return its file number;
			Writeln('What is the address of the data ');
			Readln(fromAddr);
			Writeln('What is the size of the data ');
			Readln(size);
			IF MemToDisk(fromAddr,size,f) <> NoErr THEN
				Writeln('There was an error in saving...')
			ELSE Writeln('Saved ok.');
		END.
	{ NOTE: I do not condone using vanilla i/o for real program, but this
		is a small program to quickly try to fix the problem.
		You can add Dialogs as appropriate }

	After saving the file (and perhaps checking it quickly), RESTART!

I do not guarentee that this will always work, since sometimes the crash
that brought this about in the first place will be so severe (especially if
the heap is badly mangled/low memory is wiped) that you will not be able to
exit to the shell.  Chances are, however, if you can, you should be able to
recover the data with this.  This will not likely work under MultiFinder
either, and trying to do this will probably make things worse.  Good luck.
(Gee, maybe I should write an INIT that patches SysError and dumps the
current heap zone to disk?  What a can of worms this could be! (Especially
if you have lots of memory and are running on floppies!)).

>Also, in searching through my megabyte I found several ASCII references to 
>Mishawana and Mishawana Bold (I think I have the name right).  Sounds like 
>a font name.  I've never installed it, I have never seen it an any font
>menu, I've never heard of it.  What is it?

If I remember correctly, it is the font that is used automatically by uw in
its windows.  You should be able to open uw up with Font/DA Mover (holding
down the option key when you select open) and you should see the font
there.  You don't have to install, nor will you see it on any font menu,
since it resides only in uw, and not the system.


>
>Kent Borg
>kent@lloyd.uucp
>or 
>hscfvax!lloyd!kent

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
= "When I was young, all I wanted was to be  | - gandreas@ub.d.umn.edu -    =
=  ruler of the universe.  Now that isn't    |   Glenn Andreas              =
=  enough" - Alex P. Keaton                  |                              =
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

spector@vx2.GBA.NYU.EDU (David HM Spector) (08/17/88)

There was in older versions of MacsBug a way to echo MacsBug's output to
a printer on the printer port.   I don't know if the current versions
(5.1 and 6.0b?) allow this.  (actually, lemme' check..) (i'm back :-)
In version 6.0 there is a command "LOG" which will log to the printer.

		DHMS
-------------------------------------------------------------------------------
David HM Spector				New York University
Senior Systems Programmer			Graduate School of Business
Arpa: SPECTOR@GBA.NYU.EDU			Academic Computing Center
UUCP:...!{allegra,rocky,harvard}!cmcl2!spector	90 Trinity Place, Rm C-4
HamRadio: N2BCA      MCIMail: DSpector          New York, New York 10006
AppleLink: D1161     CompuServe: 71260,1410     (212) 285-6080
"What computer puts out work like this?"  "Hire us and we'll tell you."
XYZZYGLORP

imp@crayview.msi.umn.edu (Chuck Lukaszewski) (08/17/88)

Macsbug 6.0 also permits dumping to a file.

It seems to me that you could also write a given segment of memory off
to disk manually so long as the unit table was still intact.  You would
essentially want to do two calls.  You would want to make a control call
to the Sony driver to eject the current disk (do this instead of the paper
clip as a cross-check that you are able to talk to the sony driver).
Put $000003A4 in A0 (address of system parameter block) and store these
values:

		Offset from $3A4		Value
		================		=====
		$16						$0001		Drive number
		$18						$FFFB		Driver refnum
		$1A						$0007		Eject code

Then invoke a control call.  If the disk ejects, then you can put a new
one in (the disk driver doesn't have to have the thing mounted in order
to write to it).  Now put these values in following offsets:

		Offset from $3A4		Value
		================		=====
		$20						Source Address
		$24						Count
		$2C						$0001		Absolute positioning
		$2E						$00000000	From sector zero

And invoke the write trap

This will write the range to the disk starting at sector zero.  At this
point you can reboot the machine and recover the hex with Fedit or write
a small program to read it back (you could use the same idea here but use
a read trap and be sure to use _NewPtr or _NewHandle to allocate enough
space for a buffer first.  You can also use MacZap Tools to disassemble
the stuff without taking it off of the disk.

Never tried it, but I think it will work.

---===---===---===---===--/* Chuck Lukaszewski */--===---===---===---===---
ARPAnet/NSFnet/MRnet:      AppleLink:  SnailMail:              Ma Bell:
imp@crayview.msi.umn.edu   UG0138      Minneapolis MN 55418    612/789-0931
---===---===---===---===--/* Chuck Lukaszewski */--===---===---===---===---
ARPAnet/NSFnet/MRnet:      AppleLink:  SnailMail:              Ma Bell:
imp@crayview.msi.umn.edu   UG0138      Minneapolis MN 55418    612/789-0931

john@trigraph.UUCP (John Chew) (08/18/88)

In article <136@lloyd.camex.uucp> kent@lloyd.camex.uucp (Kent Borg) writes:
>Is there a way from Macsbug to do a "core dump" to disk?  Recently when 
>pasteing some text into uw, my Macintosh Plus crashed.  Using Macsbug I 
>managed to find (3 copies of) my text and copy 3 pages by hand.  

Using Macsbug 6.0B1, enter the "LOG pathname" command to open a log file
on disk.  Dump the relevant portion of memory in hex dump format using
"DM".  Close the log file ("LOG").  Then use your favourite word processor
to strip the hex, keep the ASCII and restore formatting.

A caveat: periodically, the LOG command creates an empty file instead
of a log.  I do not know what causes this -- for reference, I am using
a Mac 512E with 2M (Dove) RAM, Dove SCSI and a CMS 60M external drive.

John
--
-- 
john j. chew, iii  poslfit@utorgpu.bitnet
    trigraph, inc. poslfit@gpu.utcs.toronto.edu
  toronto, canada  {uunet!mnetor!utzoo,utgpu,utcsri}!trigraph!john
  [it is my opinion that these are solely my opinions.]