Changeset 491


Ignore:
Timestamp:
Jun 22, 2010, 1:31:09 AM (15 years ago)
Author:
David Azarewicz
Message:

missing symbol fix, sorted output, etc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified GPL/trunk/tools/wat2map.cmd

    r305 r491  
    1 /* $Id: wat2map.cmd,v 1.1.1.1 2003/07/02 13:57:04 eleph Exp $ */
    2 
    3 /* SCCSID = %W% %E% */
     1/* $Id: wat2map.cmd,v 1.2 2002/04/26 23:09:44 smilcke Exp $ */
     2
     3/* SCCSID = src/dev/mme/pciaudio/wat2map.cmd, pciaudio, c.basedd 99/08/20 */
    44/****************************************************************************
    55 *                                                                          *
     
    1212 *                                                                          *
    1313 ****************************************************************************/
    14 /**@internal %W%
     14
     15/* 05 Jul 05 SHL - Correct do/end errors, close files
     16   05 Jul 05 SHL - Partial 16/32 bit support (see f32bit)
     17*/
     18
     19/**@internal src/dev/mme/pciaudio/wat2map.cmd, pciaudio, c.basedd
    1520 * WAT2MAP - translate symbol map from Watcom format to MS format.
    16  * @version %I%
     21 * @version 1.1
    1722 * @context
    1823 *  Unless otherwise noted, all interfaces are Ring-0, 16-bit, kernel stack.
     
    4752/* <End of helpText> - don't modify this string - used to flag end of help. */
    4853/****************************************************************************/
     54
    4955CALL RXFUNCADD 'sysloadfuncs','rexxutil','sysloadfuncs'
    5056call sysloadfuncs
     57
     58f32bit = 0      /* fixme to autodetect */
    5159
    5260Parse Arg arg1 arg2 rest
     
    7482   watcomText = LineIn( mapFile )
    7583   Parse Value watcomText With "Executable Image: " fileName "." fileExt
    76 
    7784   If fileName <> "" Then Do;   /* Found match */
    7885      call lineout outfile ,' '
     
    103110
    104111/*--- 4.  Translate segment table.  ---*/
    105 call lineout outfile , " Start     Length     Name                   Class"
     112if f32bit then
     113  call lineout outfile , " Start         Length     Name                   Class"
     114else
     115  call lineout outfile , " Start     Length     Name                   Class"
     116
    106117Do While Lines( mapFile ) <> 0
    107118   watcomText = LineIn( mapFile )
    108119   Parse Value watcomText With segName className groupName address size .
    109120   If segName = "" Then Leave;          /* Empty line, break from loop. */
    110    length = Substr( size, 4, 5 ) || 'H     '
     121   if f32bit then
     122     length = size || 'H  '
     123   else
     124     length = Substr( size, 4, 5 ) || 'H     '
    111125   segName = Left( segName, 23 )
    112126   call lineout outfile ,' ' || address || ' ' || length || segName || className
     
    122136/* call lineout outfile ,' '*/
    123137
    124 Do While Lines( mapFile ) <> 0
    125    watcomText = LineIn( mapFile )
    126    Parse Value watcomText With seg ':' ofs 10 . 16 declaration
     138LineTbl.0=0;
     139LineIX = 0;
     140Do While Lines( mapFile ) <> 0
     141   watcomText = LineIn( mapFile )
     142   Parse Value watcomText With seg ':' ofs declaration
     143   if length(ofs) = 5 then
     144     ofs = left(ofs, 4) || strip(translate(right(ofs, 1),, '+*'))
     145   if length(ofs) = 9 then
     146     ofs = left(ofs, 8) || strip(translate(right(ofs, 1),, '+*'))
     147
    127148   is_Adress = (is_Hex(seg) = 1) & (is_Hex(ofs) = 1)
    128149   If (is_Adress = 1) Then Do;
    129150
     151      if \ f32bit then
     152        ofs = right(ofs, 4)
     153
    130154      /*--- Haven't done the work to xlate operator symbols - skip the line. */
    131155      If Pos( '::operator', declaration ) <> 0 Then Iterate;
     
    135159
    136160      /*--- Strip array brackets if this is an array. */
    137       sqBracket = Pos( '[', declaration )
     161      sqBracket = Pos( '[', declaration );
    138162      If sqBracket <> 0
    139163         Then declaration = Substr(declaration, 1, sqBracket-1);
     
    141165      /*--- Strip leading tokens from the function name.
    142166         Eg., remove function return type, near/far, etc.  */
    143       declaration = Word( declaration, Words(declaration) )
     167      declaration = Word( declaration, Words(declaration) );
    144168
    145169      /*--- Strip any remaining parens around function name. ---*/
    146       declaration = ReplaceSubstr( '(', ' ', declaration )
    147       declaration = ReplaceSubstr( ')', ' ', declaration )
     170      declaration = ReplaceSubstr( '(', ' ', declaration );
     171      declaration = ReplaceSubstr( ')', ' ', declaration );
    148172
    149173      /*--- Debug kernel doesn't like symbol for scoping operator "::"
    150174         in symbol names.  Replace :: with double underscore "__". ---*/
    151       declaration = ReplaceSubstr( '::', '__', declaration )
     175      declaration = ReplaceSubstr( '::', '__', declaration );
    152176
    153177      /*--- Debug kernel doesn't like symbol for destructor "~"
    154178         in symbol names.  Replace ~ with character "d" for "destructor.
    155179         Note destructor for a class will translate "A::~A" -> "A__dA". ---*/
    156       declaration = ReplaceSubstr( '~', 'd', declaration )
    157 
    158       call lineout outfile ,' ' || seg || ':' || ofs || '       ' || declaration
     180      declaration = ReplaceSubstr( '~', 'd', declaration );
     181
     182      /* remove any trailing underscore */
     183      declaration = STRIP(declaration, 't', '_');
     184
     185      /* remove the first underscore (if any) */
     186      if (LEFT(declaration,1) = '_') then do;
     187        declaration = RIGHT(declaration, LENGTH(declaration)-1);
     188      end;
     189
     190      fill = copies(' ', 7)
     191      LineIX = LineIX + 1;
     192      LineTbl.LineIX = seg || ':' || ofs || fill || declaration;
     193      LineTbl.0 = LineIX;
    159194   End;
    160195End; /* End While through symbol section, end of input file. */
     196
     197/* Sort the data */
     198do i=2 to LineTbl.0;
     199   t=LineTbl.i;
     200   do j=i-1 to 1 by -1 while t<LineTbl.j;
     201      k=j+1;
     202      LineTbl.k=LineTbl.j;
     203   end;
     204   j=j+1;
     205   LineTbl.j=t;
     206end;
     207
     208/* output the data */
     209do LineIX = 1 to LineTbl.0;
     210  call lineout outfile , ' ' || LineTbl.LineIX;
     211end;
     212
     213call stream mapfile, 'C', 'CLOSE'
     214call lineout outfile
    161215
    162216Return;  /* End of program.  */
     
    184238      Return StripMatchedParen( string )
    185239   End;
    186 End;
     240
    187241
    188242ReplaceSubstr:
     
    198252   End;
    199253   Return string
    200 End;
     254
    201255
    202256is_Hex:
     
    204258   Parse Arg string
    205259   Return (Length(string) > 0) &  (Verify( string, '0123456789abcdefABCDEF' ) = 0)
    206 End;
Note: See TracChangeset for help on using the changeset viewer.