[M3devel] This disgusting TEXT business

Rodney M. Bates rodney.bates at wichita.edu
Tue Dec 23 04:06:37 CET 2008


Mika Nystrom wrote:

 > Note to self and others: m3gdb is not completely useful here.  If
 > you look at the structure of a TextCat.T, you see that fields a and
 > b are TEXTs, but m3gdb doesn't really let you look inside them,
 > since, well, they are TEXTs and printed as such.  (You don't
 > get to see the whole gory mess of pointers.)  Is there a way to
 > turn off this (normally very helpful) m3gdb feature?


Yes. Perhaps a couple of years ago, I added a /k format letter to m3gdb
for printing TEXT values showing the internal object, rather than
the characters in quotes.  At the time, I only announced this in the
CVS checkin logs (which show up in the m3commit mailing list), but
recently, I added a good-sized bit of collected documentation for
m3gdb, which describes this in more detail. From:

http://modula3.elegosoft.com/cm3/doc/help/m3gdb/m3gdb-onepage.html#id2517604

-----------------------------------------------------------------------------

Normally, m3gdb displays TEXT  values in Modula-3 lexical syntax, with double 
quotes, escape sequences, and, if appropriate, a leading 'W'. However, the /k 
option in a print command will cause it instead to display the TEXT value's 
internal data structure. For PM3 et. al., this is a traced reference to an open 
array of characters. For CM3, this will be one of the several object subtypes of 
TEXT. m3gdb properly recognizes and displays values of CM3 type TextLiteral.T. 
Here, it takes the length of the text from the appropriate field, instead of 
from the declared type, which contains a fixed array whose length is amost 
always far too long.

Even without specifying the /k option, if you happen to know what the internal 
representation is, you can apply appropriate operators to it, e.g., 
dereferencing, field selection, subscripting, or even method calls.

-----------------------------------------------------------------------------
Examples:

(m3gdb) p T6
$15 = (*16_b740e1dc*) "TextLiteralabcdefghij"
(m3gdb) p/k T6
$16 = (*16_b740e1dc*) OBJECT a = 16_0804a670; b = 16_b740e0c8; a_len = 11; b_len 
= 10; a_or_b_wide = FALSE;  END
(m3gdb) p/k T6.a
$17 = (*16_0804a670*) (*TextLiteral.T*) cnt = 11; buf = "TextLiteral" END
(m3gdb) p/k T6.b
$18 = (*16_b740e0c8*) OBJECT len = 10; contents = {'a', 'b', 'c', 'd', 'e', 'f', 
'g', 'h', 'i', 'j', '\000',
     '\000', '\000', '\000', '\000', '\000'};  END

-----------------------------------------------------------------------------

It would be nicer if m3gdb also always printed the name of the type of the 
object, but I haven't figured out what to do here in general, because an
object type can have no name, or more than one name.  But I see I am now
printing  (*TextLiteral.T*) as a special case, so the other CM3 subtypes
of TEXT could be handled the same way.  'Nother item for my long m3gdb
to-do list.

Rodney Bates

> 
>      Mika
> 
> 




More information about the M3devel mailing list