LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2DebugStack.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 0.0 % 407 0
Test Date: 2024-03-23 14:05:01 Functions: 0.0 % 35 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* do not edit automatically generated by mc from M2DebugStack.  */
       2                 :             : /* M2DebugStack.mod display parameter stack.
       3                 :             : 
       4                 :             : Copyright (C) 2011-2024 Free Software Foundation, Inc.
       5                 :             : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
       6                 :             : 
       7                 :             : This file is part of GNU Modula-2.
       8                 :             : 
       9                 :             : GNU Modula-2 is free software; you can redistribute it and/or modify
      10                 :             : it under the terms of the GNU General Public License as published by
      11                 :             : the Free Software Foundation; either version 3, or (at your option)
      12                 :             : any later version.
      13                 :             : 
      14                 :             : GNU Modula-2 is distributed in the hope that it will be useful, but
      15                 :             : WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :             : General Public License for more details.
      18                 :             : 
      19                 :             : You should have received a copy of the GNU General Public License
      20                 :             : along with GNU Modula-2; see the file COPYING3.  If not see
      21                 :             : <http://www.gnu.org/licenses/>.  */
      22                 :             : 
      23                 :             : #include "config.h"
      24                 :             : #include "system.h"
      25                 :             : #include <stdbool.h>
      26                 :             : #   if !defined (PROC_D)
      27                 :             : #      define PROC_D
      28                 :             :        typedef void (*PROC_t) (void);
      29                 :             :        typedef struct { PROC_t proc; } PROC;
      30                 :             : #   endif
      31                 :             : 
      32                 :             : #   if !defined (TRUE)
      33                 :             : #      define TRUE (1==1)
      34                 :             : #   endif
      35                 :             : 
      36                 :             : #   if !defined (FALSE)
      37                 :             : #      define FALSE (1==0)
      38                 :             : #   endif
      39                 :             : 
      40                 :             : #   include "Gmcrts.h"
      41                 :             : #if defined(__cplusplus)
      42                 :             : #   undef NULL
      43                 :             : #   define NULL 0
      44                 :             : #endif
      45                 :             : #define _M2DebugStack_H
      46                 :             : #define _M2DebugStack_C
      47                 :             : 
      48                 :             : #   include "GDynamicStrings.h"
      49                 :             : #   include "GSymbolTable.h"
      50                 :             : #   include "GStringConvert.h"
      51                 :             : #   include "GNameKey.h"
      52                 :             : #   include "GFIO.h"
      53                 :             : #   include "GSFIO.h"
      54                 :             : #   include "GM2Error.h"
      55                 :             : #   include "GM2Printf.h"
      56                 :             : 
      57                 :             : typedef struct M2DebugStack_ProcedureWord_p M2DebugStack_ProcedureWord;
      58                 :             : 
      59                 :             : typedef struct M2DebugStack_ProcedureString_p M2DebugStack_ProcedureString;
      60                 :             : 
      61                 :             : #   define Debugging false
      62                 :             : typedef unsigned int (*M2DebugStack_ProcedureWord_t) (unsigned int);
      63                 :             : struct M2DebugStack_ProcedureWord_p { M2DebugStack_ProcedureWord_t proc; };
      64                 :             : 
      65                 :             : typedef DynamicStrings_String (*M2DebugStack_ProcedureString_t) (unsigned int);
      66                 :             : struct M2DebugStack_ProcedureString_p { M2DebugStack_ProcedureString_t proc; };
      67                 :             : 
      68                 :             : static M2DebugStack_ProcedureWord OperandTok;
      69                 :             : static M2DebugStack_ProcedureWord OperandT;
      70                 :             : static M2DebugStack_ProcedureWord OperandF;
      71                 :             : static M2DebugStack_ProcedureWord OperandA;
      72                 :             : static M2DebugStack_ProcedureWord OperandD;
      73                 :             : static M2DebugStack_ProcedureWord OperandRW;
      74                 :             : static M2DebugStack_ProcedureString OperandAnno;
      75                 :             : 
      76                 :             : /*
      77                 :             :    DebugStack - displays the stack.
      78                 :             : */
      79                 :             : 
      80                 :             : extern "C" void M2DebugStack_DebugStack (unsigned int amount, M2DebugStack_ProcedureWord opt, M2DebugStack_ProcedureWord opf, M2DebugStack_ProcedureWord opa, M2DebugStack_ProcedureWord opd, M2DebugStack_ProcedureWord oprw, M2DebugStack_ProcedureWord optk, M2DebugStack_ProcedureString opanno);
      81                 :             : 
      82                 :             : /*
      83                 :             :    x - checks to see that a=b.
      84                 :             : */
      85                 :             : 
      86                 :             : static DynamicStrings_String x (DynamicStrings_String a, DynamicStrings_String b);
      87                 :             : 
      88                 :             : /*
      89                 :             :    IsWhite - returns TRUE if, ch, is a space.
      90                 :             : */
      91                 :             : 
      92                 :             : static bool IsWhite (char ch);
      93                 :             : 
      94                 :             : /*
      95                 :             :    ConCatWord - joins sentances, a, b, together.
      96                 :             : */
      97                 :             : 
      98                 :             : static DynamicStrings_String ConCatWord (DynamicStrings_String a, DynamicStrings_String b);
      99                 :             : 
     100                 :             : /*
     101                 :             :    symDesc -
     102                 :             : */
     103                 :             : 
     104                 :             : static DynamicStrings_String symDesc (unsigned int sym, DynamicStrings_String o);
     105                 :             : 
     106                 :             : /*
     107                 :             :    Output - output string, s, to Stdout.  It also disposes of the string, s.
     108                 :             : */
     109                 :             : 
     110                 :             : static void Output (DynamicStrings_String s);
     111                 :             : 
     112                 :             : /*
     113                 :             :    GetComment -
     114                 :             : */
     115                 :             : 
     116                 :             : static int GetComment (DynamicStrings_String s);
     117                 :             : 
     118                 :             : /*
     119                 :             :    doName - concatenate namekey, o, to, p.
     120                 :             : */
     121                 :             : 
     122                 :             : static DynamicStrings_String doName (DynamicStrings_String p, unsigned int o);
     123                 :             : 
     124                 :             : /*
     125                 :             :    doSymName - concatenate symbol, o, name to, p.
     126                 :             : */
     127                 :             : 
     128                 :             : static DynamicStrings_String doSymName (DynamicStrings_String p, unsigned int o);
     129                 :             : 
     130                 :             : /*
     131                 :             :    doNumber - convert, o, to a cardinal and increment the length, l,
     132                 :             :               by the number of characters required to represent, o.
     133                 :             : */
     134                 :             : 
     135                 :             : static DynamicStrings_String doNumber (DynamicStrings_String p, unsigned int o);
     136                 :             : 
     137                 :             : /*
     138                 :             :    doSymbol - handles a symbol indicated by, o.
     139                 :             : */
     140                 :             : 
     141                 :             : static DynamicStrings_String doSymbol (DynamicStrings_String p, unsigned int o);
     142                 :             : 
     143                 :             : /*
     144                 :             :    doOperand -
     145                 :             : */
     146                 :             : 
     147                 :             : static DynamicStrings_String doOperand (DynamicStrings_String p, DynamicStrings_String s, int *i, int e, unsigned int o);
     148                 :             : 
     149                 :             : /*
     150                 :             :    doPercent -
     151                 :             : */
     152                 :             : 
     153                 :             : static DynamicStrings_String doPercent (DynamicStrings_String o, DynamicStrings_String s, int *i, int e, unsigned int n);
     154                 :             : 
     155                 :             : /*
     156                 :             :    doNameLength - increment, l, by the ascii length of string determined by, o.
     157                 :             : */
     158                 :             : 
     159                 :             : static void doNameLength (unsigned int *l, unsigned int o);
     160                 :             : 
     161                 :             : /*
     162                 :             :    doSymNameLength - increment, l, by the ascii length of symbol, o.
     163                 :             : */
     164                 :             : 
     165                 :             : static void doSymNameLength (unsigned int *l, unsigned int o);
     166                 :             : 
     167                 :             : /*
     168                 :             :    doNumberLength - convert, o, to a cardinal and increment the length, l,
     169                 :             :                     by the number of characters required to represent, o.
     170                 :             : */
     171                 :             : 
     172                 :             : static void doNumberLength (unsigned int *l, unsigned int o);
     173                 :             : 
     174                 :             : /*
     175                 :             :    doSymbolLength - handles a symbol indicated by, o.
     176                 :             : */
     177                 :             : 
     178                 :             : static void doSymbolLength (unsigned int *l, unsigned int o);
     179                 :             : 
     180                 :             : /*
     181                 :             :    doOperandLength -
     182                 :             : */
     183                 :             : 
     184                 :             : static void doOperandLength (DynamicStrings_String s, int *i, int e, unsigned int *l, unsigned int o);
     185                 :             : 
     186                 :             : /*
     187                 :             :    doPercentLength -
     188                 :             : */
     189                 :             : 
     190                 :             : static void doPercentLength (DynamicStrings_String s, int *i, int e, unsigned int *l, unsigned int n);
     191                 :             : 
     192                 :             : /*
     193                 :             :    doFieldLength - compute the string length given in annotation
     194                 :             :                    at position, n, on the stack between characters
     195                 :             :                    b and e.
     196                 :             : 
     197                 :             :                    The string description between: b..e can contain any
     198                 :             :                    of these patterns:
     199                 :             : 
     200                 :             :                    %a           ascii name key.
     201                 :             :                    %s           symbol number.
     202                 :             :                    %d           decimal cardinal number.
     203                 :             :                    |            indicates the next field.
     204                 :             : */
     205                 :             : 
     206                 :             : static unsigned int doFieldLength (int b, int e, unsigned int n);
     207                 :             : 
     208                 :             : /*
     209                 :             :    stop -
     210                 :             : */
     211                 :             : 
     212                 :             : static void stop (void);
     213                 :             : 
     214                 :             : /*
     215                 :             :    doMaxCard - returns the maximum of two CARDINALs.
     216                 :             : */
     217                 :             : 
     218                 :             : static unsigned int doMaxCard (unsigned int a, unsigned int b);
     219                 :             : 
     220                 :             : /*
     221                 :             :    GetAnnotationFieldLength -
     222                 :             : */
     223                 :             : 
     224                 :             : static unsigned int GetAnnotationFieldLength (unsigned int n, unsigned int f);
     225                 :             : 
     226                 :             : /*
     227                 :             :    GetAnnotationLength -
     228                 :             : */
     229                 :             : 
     230                 :             : static unsigned int GetAnnotationLength (unsigned int n, unsigned int f);
     231                 :             : 
     232                 :             : /*
     233                 :             :    GetFieldLength - returns the number of characters used in field, f,
     234                 :             :                     at position, n, on the stack.
     235                 :             : */
     236                 :             : 
     237                 :             : static unsigned int GetFieldLength (unsigned int n, unsigned int f);
     238                 :             : 
     239                 :             : /*
     240                 :             :    GetMaxFieldAnno - returns the maximum number of characters required
     241                 :             :                      by either the annotation or field, f, at position, n,
     242                 :             :                      on the stack.
     243                 :             : */
     244                 :             : 
     245                 :             : static unsigned int GetMaxFieldAnno (unsigned int n, unsigned int f);
     246                 :             : 
     247                 :             : /*
     248                 :             :    GetStackFieldLengths - assigns, tn, and, fn, with the
     249                 :             :                           maximum field width values.
     250                 :             : */
     251                 :             : 
     252                 :             : static void GetStackFieldLengths (unsigned int *tn, unsigned int *fn, unsigned int *tk, unsigned int amount);
     253                 :             : 
     254                 :             : /*
     255                 :             :    DisplayRow -
     256                 :             : */
     257                 :             : 
     258                 :             : static void DisplayRow (unsigned int tn, unsigned int fn, unsigned int tk, bool initOrFinal);
     259                 :             : 
     260                 :             : /*
     261                 :             :    SkipToField -
     262                 :             : */
     263                 :             : 
     264                 :             : static int SkipToField (DynamicStrings_String s, unsigned int n);
     265                 :             : 
     266                 :             : /*
     267                 :             :    Pad - padds out string, s, to paddedLength characters.
     268                 :             : */
     269                 :             : 
     270                 :             : static DynamicStrings_String Pad (DynamicStrings_String o, unsigned int paddedLength);
     271                 :             : 
     272                 :             : /*
     273                 :             :    doField - compute the string length given in annotation
     274                 :             :              at position, n, on the stack between characters
     275                 :             :              b and e.
     276                 :             : 
     277                 :             :              The string description between: b..e can contain any
     278                 :             :              of these patterns:
     279                 :             : 
     280                 :             :              %a           ascii name key.
     281                 :             :              %s           symbol number.
     282                 :             :              %d           decimal cardinal number.
     283                 :             :              |            indicates the next field.
     284                 :             : */
     285                 :             : 
     286                 :             : static DynamicStrings_String doField (DynamicStrings_String s, unsigned int n, unsigned int f, unsigned int l);
     287                 :             : 
     288                 :             : /*
     289                 :             :    doAnnotation -
     290                 :             : */
     291                 :             : 
     292                 :             : static DynamicStrings_String doAnnotation (DynamicStrings_String s, unsigned int n, unsigned int field, unsigned int width);
     293                 :             : 
     294                 :             : /*
     295                 :             :    DisplayFields -
     296                 :             : */
     297                 :             : 
     298                 :             : static void DisplayFields (unsigned int n, unsigned int tn, unsigned int fn, unsigned int tk);
     299                 :             : 
     300                 :             : 
     301                 :             : /*
     302                 :             :    x - checks to see that a=b.
     303                 :             : */
     304                 :             : 
     305                 :           0 : static DynamicStrings_String x (DynamicStrings_String a, DynamicStrings_String b)
     306                 :             : {
     307                 :           0 :   if (a != b)
     308                 :             :     {
     309                 :           0 :       M2Error_InternalError ((const char *) "different string returned", 25);
     310                 :             :     }
     311                 :           0 :   return a;
     312                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     313                 :             :   __builtin_unreachable ();
     314                 :             : }
     315                 :             : 
     316                 :             : 
     317                 :             : /*
     318                 :             :    IsWhite - returns TRUE if, ch, is a space.
     319                 :             : */
     320                 :             : 
     321                 :           0 : static bool IsWhite (char ch)
     322                 :             : {
     323                 :           0 :   return ch == ' ';
     324                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     325                 :             :   __builtin_unreachable ();
     326                 :             : }
     327                 :             : 
     328                 :             : 
     329                 :             : /*
     330                 :             :    ConCatWord - joins sentances, a, b, together.
     331                 :             : */
     332                 :             : 
     333                 :           0 : static DynamicStrings_String ConCatWord (DynamicStrings_String a, DynamicStrings_String b)
     334                 :             : {
     335                 :           0 :   if (((DynamicStrings_Length (a)) == 1) && ((DynamicStrings_char (a, 0)) == 'a'))
     336                 :             :     {
     337                 :           0 :       a = x (a, DynamicStrings_ConCatChar (a, 'n'));
     338                 :             :     }
     339                 :           0 :   else if ((((DynamicStrings_Length (a)) > 1) && ((DynamicStrings_char (a, -1)) == 'a')) && (IsWhite (DynamicStrings_char (a, -2))))
     340                 :             :     {
     341                 :             :       /* avoid dangling else.  */
     342                 :           0 :       a = x (a, DynamicStrings_ConCatChar (a, 'n'));
     343                 :             :     }
     344                 :           0 :   if (((DynamicStrings_Length (a)) > 0) && (! (IsWhite (DynamicStrings_char (a, -1)))))
     345                 :             :     {
     346                 :           0 :       a = x (a, DynamicStrings_ConCatChar (a, ' '));
     347                 :             :     }
     348                 :           0 :   return x (a, DynamicStrings_ConCat (a, b));
     349                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     350                 :             :   __builtin_unreachable ();
     351                 :             : }
     352                 :             : 
     353                 :             : 
     354                 :             : /*
     355                 :             :    symDesc -
     356                 :             : */
     357                 :             : 
     358                 :           0 : static DynamicStrings_String symDesc (unsigned int sym, DynamicStrings_String o)
     359                 :             : {
     360                 :           0 :   if (sym == SymbolTable_NulSym)
     361                 :             :     {
     362                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "NulSym", 6)));
     363                 :             :     }
     364                 :           0 :   else if (SymbolTable_IsConstLit (sym))
     365                 :             :     {
     366                 :             :       /* avoid dangling else.  */
     367                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "constant literal", 16)));
     368                 :             :     }
     369                 :           0 :   else if (SymbolTable_IsConstSet (sym))
     370                 :             :     {
     371                 :             :       /* avoid dangling else.  */
     372                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "constant set", 12)));
     373                 :             :     }
     374                 :           0 :   else if (SymbolTable_IsConstructor (sym))
     375                 :             :     {
     376                 :             :       /* avoid dangling else.  */
     377                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "constructor", 11)));
     378                 :             :     }
     379                 :           0 :   else if (SymbolTable_IsConst (sym))
     380                 :             :     {
     381                 :             :       /* avoid dangling else.  */
     382                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "constant", 8)));
     383                 :             :     }
     384                 :           0 :   else if (SymbolTable_IsArray (sym))
     385                 :             :     {
     386                 :             :       /* avoid dangling else.  */
     387                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "array", 5)));
     388                 :             :     }
     389                 :           0 :   else if (SymbolTable_IsVar (sym))
     390                 :             :     {
     391                 :             :       /* avoid dangling else.  */
     392                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "variable", 8)));
     393                 :             :     }
     394                 :           0 :   else if (SymbolTable_IsEnumeration (sym))
     395                 :             :     {
     396                 :             :       /* avoid dangling else.  */
     397                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "enumeration type", 16)));
     398                 :             :     }
     399                 :           0 :   else if (SymbolTable_IsFieldEnumeration (sym))
     400                 :             :     {
     401                 :             :       /* avoid dangling else.  */
     402                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "enumeration field", 17)));
     403                 :             :     }
     404                 :           0 :   else if (SymbolTable_IsUnbounded (sym))
     405                 :             :     {
     406                 :             :       /* avoid dangling else.  */
     407                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "unbounded parameter", 19)));
     408                 :             :     }
     409                 :           0 :   else if (SymbolTable_IsProcType (sym))
     410                 :             :     {
     411                 :             :       /* avoid dangling else.  */
     412                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "procedure type", 14)));
     413                 :             :     }
     414                 :           0 :   else if (SymbolTable_IsProcedure (sym))
     415                 :             :     {
     416                 :             :       /* avoid dangling else.  */
     417                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "procedure", 9)));
     418                 :             :     }
     419                 :           0 :   else if (SymbolTable_IsPointer (sym))
     420                 :             :     {
     421                 :             :       /* avoid dangling else.  */
     422                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "pointer", 7)));
     423                 :             :     }
     424                 :           0 :   else if (SymbolTable_IsParameter (sym))
     425                 :             :     {
     426                 :             :       /* avoid dangling else.  */
     427                 :           0 :       if (SymbolTable_IsParameterVar (sym))
     428                 :             :         {
     429                 :           0 :           return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "var parameter", 13)));
     430                 :             :         }
     431                 :             :       else
     432                 :             :         {
     433                 :           0 :           return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "parameter", 9)));
     434                 :             :         }
     435                 :             :     }
     436                 :           0 :   else if (SymbolTable_IsType (sym))
     437                 :             :     {
     438                 :             :       /* avoid dangling else.  */
     439                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "type", 4)));
     440                 :             :     }
     441                 :           0 :   else if (SymbolTable_IsRecord (sym))
     442                 :             :     {
     443                 :             :       /* avoid dangling else.  */
     444                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "record", 6)));
     445                 :             :     }
     446                 :           0 :   else if (SymbolTable_IsRecordField (sym))
     447                 :             :     {
     448                 :             :       /* avoid dangling else.  */
     449                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "record field", 12)));
     450                 :             :     }
     451                 :           0 :   else if (SymbolTable_IsVarient (sym))
     452                 :             :     {
     453                 :             :       /* avoid dangling else.  */
     454                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "varient record", 14)));
     455                 :             :     }
     456                 :           0 :   else if (SymbolTable_IsModule (sym))
     457                 :             :     {
     458                 :             :       /* avoid dangling else.  */
     459                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "module", 6)));
     460                 :             :     }
     461                 :           0 :   else if (SymbolTable_IsDefImp (sym))
     462                 :             :     {
     463                 :             :       /* avoid dangling else.  */
     464                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "definition or implementation module", 35)));
     465                 :             :     }
     466                 :           0 :   else if (SymbolTable_IsSet (sym))
     467                 :             :     {
     468                 :             :       /* avoid dangling else.  */
     469                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "set", 3)));
     470                 :             :     }
     471                 :           0 :   else if (SymbolTable_IsSubrange (sym))
     472                 :             :     {
     473                 :             :       /* avoid dangling else.  */
     474                 :           0 :       return ConCatWord (o, DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "subrange", 8)));
     475                 :             :     }
     476                 :             :   else
     477                 :             :     {
     478                 :             :       /* avoid dangling else.  */
     479                 :             :       return o;
     480                 :             :     }
     481                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     482                 :             :   __builtin_unreachable ();
     483                 :             : }
     484                 :             : 
     485                 :             : 
     486                 :             : /*
     487                 :             :    Output - output string, s, to Stdout.  It also disposes of the string, s.
     488                 :             : */
     489                 :             : 
     490                 :           0 : static void Output (DynamicStrings_String s)
     491                 :             : {
     492                 :           0 :   s = SFIO_WriteS (FIO_StdOut, s);
     493                 :           0 :   s = DynamicStrings_KillString (s);
     494                 :           0 : }
     495                 :             : 
     496                 :             : 
     497                 :             : /*
     498                 :             :    GetComment -
     499                 :             : */
     500                 :             : 
     501                 :           0 : static int GetComment (DynamicStrings_String s)
     502                 :             : {
     503                 :           0 :   int c;
     504                 :             : 
     505                 :           0 :   c = DynamicStrings_Index (s, '|', 0);
     506                 :           0 :   while (c >= 0)
     507                 :             :     {
     508                 :           0 :       c += 1;
     509                 :           0 :       if (c >= ((int ) (DynamicStrings_Length (s))))
     510                 :             :         {
     511                 :             :           return -1;
     512                 :             :         }
     513                 :           0 :       else if ((DynamicStrings_char (s, c)) == '|')
     514                 :             :         {
     515                 :             :           /* avoid dangling else.  */
     516                 :           0 :           return c+1;
     517                 :             :         }
     518                 :           0 :       c = DynamicStrings_Index (s, '|', static_cast<unsigned int> (c));
     519                 :             :     }
     520                 :             :   return -1;
     521                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     522                 :             :   __builtin_unreachable ();
     523                 :             : }
     524                 :             : 
     525                 :             : 
     526                 :             : /*
     527                 :             :    doName - concatenate namekey, o, to, p.
     528                 :             : */
     529                 :             : 
     530                 :           0 : static DynamicStrings_String doName (DynamicStrings_String p, unsigned int o)
     531                 :             : {
     532                 :           0 :   return DynamicStrings_ConCat (p, DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (o)));
     533                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     534                 :             :   __builtin_unreachable ();
     535                 :             : }
     536                 :             : 
     537                 :             : 
     538                 :             : /*
     539                 :             :    doSymName - concatenate symbol, o, name to, p.
     540                 :             : */
     541                 :             : 
     542                 :           0 : static DynamicStrings_String doSymName (DynamicStrings_String p, unsigned int o)
     543                 :             : {
     544                 :           0 :   return DynamicStrings_ConCat (p, DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (o))));
     545                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     546                 :             :   __builtin_unreachable ();
     547                 :             : }
     548                 :             : 
     549                 :             : 
     550                 :             : /*
     551                 :             :    doNumber - convert, o, to a cardinal and increment the length, l,
     552                 :             :               by the number of characters required to represent, o.
     553                 :             : */
     554                 :             : 
     555                 :           0 : static DynamicStrings_String doNumber (DynamicStrings_String p, unsigned int o)
     556                 :             : {
     557                 :           0 :   return DynamicStrings_ConCat (p, StringConvert_CardinalToString ((unsigned int ) (o), 0, ' ', 10, true));
     558                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     559                 :             :   __builtin_unreachable ();
     560                 :             : }
     561                 :             : 
     562                 :             : 
     563                 :             : /*
     564                 :             :    doSymbol - handles a symbol indicated by, o.
     565                 :             : */
     566                 :             : 
     567                 :           0 : static DynamicStrings_String doSymbol (DynamicStrings_String p, unsigned int o)
     568                 :             : {
     569                 :           0 :   return symDesc (o, p);
     570                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     571                 :             :   __builtin_unreachable ();
     572                 :             : }
     573                 :             : 
     574                 :             : 
     575                 :             : /*
     576                 :             :    doOperand -
     577                 :             : */
     578                 :             : 
     579                 :           0 : static DynamicStrings_String doOperand (DynamicStrings_String p, DynamicStrings_String s, int *i, int e, unsigned int o)
     580                 :             : {
     581                 :           0 :   (*i) += 1;
     582                 :           0 :   if ((*i) < e)
     583                 :             :     {
     584                 :           0 :       switch (DynamicStrings_char (s, (*i)))
     585                 :             :         {
     586                 :           0 :           case 's':
     587                 :           0 :             (*i) += 1;  /* symbol number  */
     588                 :           0 :             return doSymbol (p, o);
     589                 :           0 :             break;
     590                 :             : 
     591                 :           0 :           case 'd':
     592                 :           0 :             (*i) += 1;  /* decimal number  */
     593                 :           0 :             return doNumber (p, o);
     594                 :           0 :             break;
     595                 :             : 
     596                 :           0 :           case 'a':
     597                 :           0 :             (*i) += 1;  /* symbol name key  */
     598                 :           0 :             return doSymName (p, o);
     599                 :           0 :             break;
     600                 :             : 
     601                 :           0 :           case 'n':
     602                 :           0 :             (*i) += 1;  /* ascii name key  */
     603                 :           0 :             return doName (p, o);
     604                 :           0 :             break;
     605                 :             : 
     606                 :             : 
     607                 :           0 :           default:
     608                 :           0 :             M2Error_InternalError ((const char *) "incorrect format specifier expecting one of 's', 'd' or 'a'", 59);
     609                 :             :             break;
     610                 :             :         }
     611                 :             :     }
     612                 :             :   return p;
     613                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     614                 :             :   __builtin_unreachable ();
     615                 :             : }
     616                 :             : 
     617                 :             : 
     618                 :             : /*
     619                 :             :    doPercent -
     620                 :             : */
     621                 :             : 
     622                 :           0 : static DynamicStrings_String doPercent (DynamicStrings_String o, DynamicStrings_String s, int *i, int e, unsigned int n)
     623                 :             : {
     624                 :           0 :   (*i) += 1;
     625                 :           0 :   if ((*i) < e)
     626                 :             :     {
     627                 :           0 :       switch (DynamicStrings_char (s, (*i)))
     628                 :             :         {
     629                 :           0 :           case '1':
     630                 :           0 :             return doOperand (o, s, i, e, static_cast<unsigned int> ((*OperandT.proc) (n)));
     631                 :           0 :             break;
     632                 :             : 
     633                 :           0 :           case '2':
     634                 :           0 :             return doOperand (o, s, i, e, static_cast<unsigned int> ((*OperandF.proc) (n)));
     635                 :           0 :             break;
     636                 :             : 
     637                 :           0 :           case '3':
     638                 :           0 :             return doOperand (o, s, i, e, static_cast<unsigned int> ((*OperandTok.proc) (n)));
     639                 :           0 :             break;
     640                 :             : 
     641                 :             : 
     642                 :           0 :           default:
     643                 :           0 :             M2Error_InternalError ((const char *) "unrecognised format specifier - expecting 1, 2 or 3 after the %", 63);
     644                 :           0 :             break;
     645                 :             :         }
     646                 :             :     }
     647                 :           0 :   M2Error_InternalError ((const char *) "end of field found before format specifier - expecting 1, 2 or 3 after the %", 76);
     648                 :             :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2DebugStack.def", 20, 1);
     649                 :             :   __builtin_unreachable ();
     650                 :             : }
     651                 :             : 
     652                 :             : 
     653                 :             : /*
     654                 :             :    doNameLength - increment, l, by the ascii length of string determined by, o.
     655                 :             : */
     656                 :             : 
     657                 :           0 : static void doNameLength (unsigned int *l, unsigned int o)
     658                 :             : {
     659                 :           0 :   DynamicStrings_String s;
     660                 :             : 
     661                 :           0 :   s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (o));
     662                 :           0 :   (*l) += DynamicStrings_Length (s);
     663                 :           0 :   s = DynamicStrings_KillString (s);
     664                 :           0 : }
     665                 :             : 
     666                 :             : 
     667                 :             : /*
     668                 :             :    doSymNameLength - increment, l, by the ascii length of symbol, o.
     669                 :             : */
     670                 :             : 
     671                 :           0 : static void doSymNameLength (unsigned int *l, unsigned int o)
     672                 :             : {
     673                 :           0 :   DynamicStrings_String s;
     674                 :             : 
     675                 :           0 :   s = DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (SymbolTable_GetSymName (o)));
     676                 :           0 :   (*l) += DynamicStrings_Length (s);
     677                 :           0 :   s = DynamicStrings_KillString (s);
     678                 :           0 : }
     679                 :             : 
     680                 :             : 
     681                 :             : /*
     682                 :             :    doNumberLength - convert, o, to a cardinal and increment the length, l,
     683                 :             :                     by the number of characters required to represent, o.
     684                 :             : */
     685                 :             : 
     686                 :           0 : static void doNumberLength (unsigned int *l, unsigned int o)
     687                 :             : {
     688                 :           0 :   DynamicStrings_String s;
     689                 :             : 
     690                 :           0 :   s = StringConvert_CardinalToString ((unsigned int ) (o), 0, ' ', 10, true);
     691                 :           0 :   (*l) += DynamicStrings_Length (s);
     692                 :           0 :   s = DynamicStrings_KillString (s);
     693                 :           0 : }
     694                 :             : 
     695                 :             : 
     696                 :             : /*
     697                 :             :    doSymbolLength - handles a symbol indicated by, o.
     698                 :             : */
     699                 :             : 
     700                 :           0 : static void doSymbolLength (unsigned int *l, unsigned int o)
     701                 :             : {
     702                 :           0 :   DynamicStrings_String s;
     703                 :             : 
     704                 :           0 :   s = symDesc (o, DynamicStrings_InitString ((const char *) "", 0));
     705                 :           0 :   (*l) += DynamicStrings_Length (s);
     706                 :           0 :   s = DynamicStrings_KillString (s);
     707                 :           0 : }
     708                 :             : 
     709                 :             : 
     710                 :             : /*
     711                 :             :    doOperandLength -
     712                 :             : */
     713                 :             : 
     714                 :           0 : static void doOperandLength (DynamicStrings_String s, int *i, int e, unsigned int *l, unsigned int o)
     715                 :             : {
     716                 :           0 :   (*i) += 1;
     717                 :           0 :   if ((*i) < e)
     718                 :             :     {
     719                 :           0 :       switch (DynamicStrings_char (s, (*i)))
     720                 :             :         {
     721                 :           0 :           case 's':
     722                 :           0 :             (*i) += 1;  /* symbol number  */
     723                 :           0 :             doSymbolLength (l, o);
     724                 :           0 :             break;
     725                 :             : 
     726                 :           0 :           case 'd':
     727                 :           0 :             (*i) += 1;  /* decimal number  */
     728                 :           0 :             doNumberLength (l, o);
     729                 :           0 :             break;
     730                 :             : 
     731                 :           0 :           case 'a':
     732                 :           0 :             (*i) += 1;  /* ascii name key  */
     733                 :           0 :             doSymNameLength (l, o);
     734                 :           0 :             break;
     735                 :             : 
     736                 :           0 :           case 'n':
     737                 :           0 :             (*i) += 1;  /* ascii name key  */
     738                 :           0 :             doNameLength (l, o);
     739                 :           0 :             break;
     740                 :             : 
     741                 :             : 
     742                 :           0 :           default:
     743                 :           0 :             M2Error_InternalError ((const char *) "incorrect format specifier expecting one of 's', 'd' or 'a'", 59);
     744                 :             :             break;
     745                 :             :         }
     746                 :             :     }
     747                 :           0 : }
     748                 :             : 
     749                 :             : 
     750                 :             : /*
     751                 :             :    doPercentLength -
     752                 :             : */
     753                 :             : 
     754                 :           0 : static void doPercentLength (DynamicStrings_String s, int *i, int e, unsigned int *l, unsigned int n)
     755                 :             : {
     756                 :           0 :   (*i) += 1;
     757                 :           0 :   if ((*i) < e)
     758                 :             :     {
     759                 :           0 :       switch (DynamicStrings_char (s, (*i)))
     760                 :             :         {
     761                 :           0 :           case '1':
     762                 :           0 :             doOperandLength (s, i, e, l, static_cast<unsigned int> ((*OperandT.proc) (n)));
     763                 :           0 :             break;
     764                 :             : 
     765                 :           0 :           case '2':
     766                 :           0 :             doOperandLength (s, i, e, l, static_cast<unsigned int> ((*OperandF.proc) (n)));
     767                 :           0 :             break;
     768                 :             : 
     769                 :           0 :           case '3':
     770                 :           0 :             doOperandLength (s, i, e, l, static_cast<unsigned int> ((*OperandTok.proc) (n)));
     771                 :           0 :             break;
     772                 :             : 
     773                 :             : 
     774                 :           0 :           default:
     775                 :           0 :             M2Error_InternalError ((const char *) "unrecognised format specifier - expecting 1, 2 or 3 after the %", 63);
     776                 :             :             break;
     777                 :             :         }
     778                 :             :     }
     779                 :           0 : }
     780                 :             : 
     781                 :             : 
     782                 :             : /*
     783                 :             :    doFieldLength - compute the string length given in annotation
     784                 :             :                    at position, n, on the stack between characters
     785                 :             :                    b and e.
     786                 :             : 
     787                 :             :                    The string description between: b..e can contain any
     788                 :             :                    of these patterns:
     789                 :             : 
     790                 :             :                    %a           ascii name key.
     791                 :             :                    %s           symbol number.
     792                 :             :                    %d           decimal cardinal number.
     793                 :             :                    |            indicates the next field.
     794                 :             : */
     795                 :             : 
     796                 :           0 : static unsigned int doFieldLength (int b, int e, unsigned int n)
     797                 :             : {
     798                 :           0 :   unsigned int l;
     799                 :           0 :   int i;
     800                 :           0 :   DynamicStrings_String s;
     801                 :             : 
     802                 :           0 :   if (b == -1)
     803                 :             :     {
     804                 :             :       return 0;
     805                 :             :     }
     806                 :           0 :   s = static_cast<DynamicStrings_String> ((*OperandAnno.proc) (n));
     807                 :           0 :   if (e == -1)
     808                 :             :     {
     809                 :           0 :       e = DynamicStrings_Length (s);
     810                 :             :     }
     811                 :           0 :   l = 0;
     812                 :           0 :   i = b;
     813                 :           0 :   while (i < e)
     814                 :             :     {
     815                 :           0 :       switch (DynamicStrings_char (s, i))
     816                 :             :         {
     817                 :           0 :           case '|':
     818                 :           0 :             return l;
     819                 :           0 :             break;
     820                 :             : 
     821                 :           0 :           case '%':
     822                 :           0 :             doPercentLength (s, &i, e, &l, n);
     823                 :           0 :             break;
     824                 :             : 
     825                 :             : 
     826                 :           0 :           default:
     827                 :           0 :             l += 1;
     828                 :           0 :             break;
     829                 :             :         }
     830                 :           0 :       i += 1;
     831                 :             :     }
     832                 :           0 :   return l;
     833                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     834                 :             :   __builtin_unreachable ();
     835                 :             : }
     836                 :             : 
     837                 :             : 
     838                 :             : /*
     839                 :             :    stop -
     840                 :             : */
     841                 :             : 
     842                 :           0 : static void stop (void)
     843                 :             : {
     844                 :           0 : }
     845                 :             : 
     846                 :             : 
     847                 :             : /*
     848                 :             :    doMaxCard - returns the maximum of two CARDINALs.
     849                 :             : */
     850                 :             : 
     851                 :           0 : static unsigned int doMaxCard (unsigned int a, unsigned int b)
     852                 :             : {
     853                 :           0 :   if ((a > 100) || (b > 100))
     854                 :             :     {
     855                 :           0 :       stop ();
     856                 :             :     }
     857                 :           0 :   if (a > b)
     858                 :             :     {
     859                 :             :       return a;
     860                 :             :     }
     861                 :             :   else
     862                 :             :     {
     863                 :           0 :       return b;
     864                 :             :     }
     865                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     866                 :             :   __builtin_unreachable ();
     867                 :             : }
     868                 :             : 
     869                 :             : 
     870                 :             : /*
     871                 :             :    GetAnnotationFieldLength -
     872                 :             : */
     873                 :             : 
     874                 :           0 : static unsigned int GetAnnotationFieldLength (unsigned int n, unsigned int f)
     875                 :             : {
     876                 :           0 :   int c;
     877                 :           0 :   int e;
     878                 :             : 
     879                 :           0 :   c = GetComment (static_cast<DynamicStrings_String> ((*OperandAnno.proc) (n)));
     880                 :           0 :   if (c > 0)
     881                 :             :     {
     882                 :           0 :       if (Debugging)
     883                 :             :         {
     884                 :             :           M2Printf_printf0 ((const char *) "full anno is: ", 14);
     885                 :             :           Output (DynamicStrings_Dup (static_cast<DynamicStrings_String> ((*OperandAnno.proc) (n))));
     886                 :             :           M2Printf_printf0 ((const char *) "\\n", 2);
     887                 :             :           M2Printf_printf0 ((const char *) "comment field is: ", 18);
     888                 :             :           Output (DynamicStrings_Slice (static_cast<DynamicStrings_String> ((*OperandAnno.proc) (n)), c, 0));
     889                 :             :           M2Printf_printf0 ((const char *) "\\n", 2);
     890                 :             :         }
     891                 :           0 :       e = DynamicStrings_Index (static_cast<DynamicStrings_String> ((*OperandAnno.proc) (n)), '|', static_cast<unsigned int> (c));
     892                 :           0 :       if (f == 0)
     893                 :             :         {
     894                 :           0 :           return doFieldLength (c, e, n);
     895                 :             :         }
     896                 :             :       else
     897                 :             :         {
     898                 :           0 :           if (e >= 0)
     899                 :             :             {
     900                 :           0 :               e += 1;
     901                 :             :             }
     902                 :           0 :           return doFieldLength (e, -1, n);
     903                 :             :         }
     904                 :             :     }
     905                 :             :   else
     906                 :             :     {
     907                 :             :       return 0;
     908                 :             :     }
     909                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     910                 :             :   __builtin_unreachable ();
     911                 :             : }
     912                 :             : 
     913                 :             : 
     914                 :             : /*
     915                 :             :    GetAnnotationLength -
     916                 :             : */
     917                 :             : 
     918                 :           0 : static unsigned int GetAnnotationLength (unsigned int n, unsigned int f)
     919                 :             : {
     920                 :           0 :   unsigned int l;
     921                 :             : 
     922                 :           0 :   if (((*OperandAnno.proc) (n)) == NULL)
     923                 :             :     {
     924                 :           0 :       l = 0;
     925                 :           0 :       if (f == 0)
     926                 :             :         {
     927                 :           0 :           doNumberLength (&l, static_cast<unsigned int> ((*OperandT.proc) (n)));
     928                 :             :         }
     929                 :             :       else
     930                 :             :         {
     931                 :           0 :           doNumberLength (&l, static_cast<unsigned int> ((*OperandF.proc) (n)));
     932                 :             :         }
     933                 :           0 :       return l;
     934                 :             :     }
     935                 :             :   else
     936                 :             :     {
     937                 :           0 :       return GetAnnotationFieldLength (n, f);
     938                 :             :     }
     939                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     940                 :             :   __builtin_unreachable ();
     941                 :             : }
     942                 :             : 
     943                 :             : 
     944                 :             : /*
     945                 :             :    GetFieldLength - returns the number of characters used in field, f,
     946                 :             :                     at position, n, on the stack.
     947                 :             : */
     948                 :             : 
     949                 :           0 : static unsigned int GetFieldLength (unsigned int n, unsigned int f)
     950                 :             : {
     951                 :           0 :   int c;
     952                 :           0 :   int b;
     953                 :           0 :   int e;
     954                 :             : 
     955                 :           0 :   c = GetComment (static_cast<DynamicStrings_String> ((*OperandAnno.proc) (n)));
     956                 :           0 :   if (c > 1)
     957                 :             :     {
     958                 :           0 :       e = c-2;
     959                 :             :     }
     960                 :             :   else
     961                 :             :     {
     962                 :           0 :       e = DynamicStrings_Length (static_cast<DynamicStrings_String> ((*OperandAnno.proc) (n)));
     963                 :             :     }
     964                 :           0 :   if (f == 0)
     965                 :             :     {
     966                 :             :       b = 0;
     967                 :             :     }
     968                 :             :   else
     969                 :             :     {
     970                 :           0 :       b = DynamicStrings_Index (static_cast<DynamicStrings_String> ((*OperandAnno.proc) (n)), '|', 0);
     971                 :           0 :       if (b == -1)
     972                 :             :         {
     973                 :             :           return 0;
     974                 :             :         }
     975                 :             :       else
     976                 :             :         {
     977                 :           0 :           b += 1;
     978                 :             :         }
     979                 :             :     }
     980                 :           0 :   return doFieldLength (b, e, n);
     981                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     982                 :             :   __builtin_unreachable ();
     983                 :             : }
     984                 :             : 
     985                 :             : 
     986                 :             : /*
     987                 :             :    GetMaxFieldAnno - returns the maximum number of characters required
     988                 :             :                      by either the annotation or field, f, at position, n,
     989                 :             :                      on the stack.
     990                 :             : */
     991                 :             : 
     992                 :           0 : static unsigned int GetMaxFieldAnno (unsigned int n, unsigned int f)
     993                 :             : {
     994                 :           0 :   return doMaxCard (GetAnnotationLength (n, f), GetFieldLength (n, f));
     995                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     996                 :             :   __builtin_unreachable ();
     997                 :             : }
     998                 :             : 
     999                 :             : 
    1000                 :             : /*
    1001                 :             :    GetStackFieldLengths - assigns, tn, and, fn, with the
    1002                 :             :                           maximum field width values.
    1003                 :             : */
    1004                 :             : 
    1005                 :           0 : static void GetStackFieldLengths (unsigned int *tn, unsigned int *fn, unsigned int *tk, unsigned int amount)
    1006                 :             : {
    1007                 :           0 :   unsigned int i;
    1008                 :             : 
    1009                 :           0 :   i = 1;
    1010                 :           0 :   (*tn) = 0;
    1011                 :           0 :   (*fn) = 0;
    1012                 :           0 :   (*tk) = 0;
    1013                 :           0 :   while (i <= amount)
    1014                 :             :     {
    1015                 :           0 :       (*tn) = doMaxCard ((*tn), GetMaxFieldAnno (i, 0));
    1016                 :           0 :       (*fn) = doMaxCard ((*fn), GetMaxFieldAnno (i, 1));
    1017                 :           0 :       (*tk) = doMaxCard ((*tk), GetMaxFieldAnno (i, 2));
    1018                 :           0 :       i += 1;
    1019                 :             :     }
    1020                 :           0 : }
    1021                 :             : 
    1022                 :             : 
    1023                 :             : /*
    1024                 :             :    DisplayRow -
    1025                 :             : */
    1026                 :             : 
    1027                 :           0 : static void DisplayRow (unsigned int tn, unsigned int fn, unsigned int tk, bool initOrFinal)
    1028                 :             : {
    1029                 :           0 :   unsigned int i;
    1030                 :             : 
    1031                 :           0 :   M2Printf_printf0 ((const char *) "+-", 2);
    1032                 :           0 :   for (i=1; i<=tn; i++)
    1033                 :             :     {
    1034                 :           0 :       M2Printf_printf0 ((const char *) "-", 1);
    1035                 :             :     }
    1036                 :           0 :   if ((fn == 0) && (tk == 0))
    1037                 :             :     {
    1038                 :           0 :       if (initOrFinal)
    1039                 :             :         {
    1040                 :           0 :           M2Printf_printf0 ((const char *) "-+-", 3);
    1041                 :             :         }
    1042                 :             :       else
    1043                 :             :         {
    1044                 :           0 :           M2Printf_printf0 ((const char *) "-|-", 3);
    1045                 :             :         }
    1046                 :             :     }
    1047                 :             :   else
    1048                 :             :     {
    1049                 :           0 :       if (initOrFinal)
    1050                 :             :         {
    1051                 :           0 :           M2Printf_printf0 ((const char *) "-+-", 3);
    1052                 :             :         }
    1053                 :             :       else
    1054                 :             :         {
    1055                 :           0 :           M2Printf_printf0 ((const char *) "-|-", 3);
    1056                 :             :         }
    1057                 :           0 :       if (fn != 0)
    1058                 :             :         {
    1059                 :           0 :           for (i=1; i<=fn; i++)
    1060                 :             :             {
    1061                 :           0 :               M2Printf_printf0 ((const char *) "-", 1);
    1062                 :             :             }
    1063                 :             :         }
    1064                 :           0 :       if (initOrFinal)
    1065                 :             :         {
    1066                 :           0 :           M2Printf_printf0 ((const char *) "-+-", 3);
    1067                 :             :         }
    1068                 :             :       else
    1069                 :             :         {
    1070                 :           0 :           M2Printf_printf0 ((const char *) "-|-", 3);
    1071                 :             :         }
    1072                 :           0 :       if (tk != 0)
    1073                 :             :         {
    1074                 :           0 :           for (i=1; i<=tk; i++)
    1075                 :             :             {
    1076                 :           0 :               M2Printf_printf0 ((const char *) "-", 1);
    1077                 :             :             }
    1078                 :           0 :           M2Printf_printf0 ((const char *) "-+\\n", 4);
    1079                 :             :         }
    1080                 :             :     }
    1081                 :           0 : }
    1082                 :             : 
    1083                 :             : 
    1084                 :             : /*
    1085                 :             :    SkipToField -
    1086                 :             : */
    1087                 :             : 
    1088                 :           0 : static int SkipToField (DynamicStrings_String s, unsigned int n)
    1089                 :             : {
    1090                 :           0 :   int i;
    1091                 :           0 :   int h;
    1092                 :             : 
    1093                 :           0 :   i = 0;
    1094                 :           0 :   h = DynamicStrings_Length (s);
    1095                 :           0 :   while ((n > 0) && (i < h))
    1096                 :             :     {
    1097                 :           0 :       if ((DynamicStrings_Index (s, '|', static_cast<unsigned int> (i))) > 0)
    1098                 :             :         {
    1099                 :           0 :           n -= 1;
    1100                 :           0 :           if ((i < h) && ((DynamicStrings_char (s, i+1)) == '|'))
    1101                 :             :             {
    1102                 :             :               /* comment seen, no field available  */
    1103                 :             :               return -1;
    1104                 :             :             }
    1105                 :           0 :           i = DynamicStrings_Index (s, '|', static_cast<unsigned int> (i));
    1106                 :             :         }
    1107                 :             :       else
    1108                 :             :         {
    1109                 :             :           return -1;
    1110                 :             :         }
    1111                 :           0 :       i += 1;
    1112                 :             :     }
    1113                 :           0 :   if (i == h)
    1114                 :             :     {
    1115                 :           0 :       i = -1;
    1116                 :             :     }
    1117                 :             :   return i;
    1118                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1119                 :             :   __builtin_unreachable ();
    1120                 :             : }
    1121                 :             : 
    1122                 :             : 
    1123                 :             : /*
    1124                 :             :    Pad - padds out string, s, to paddedLength characters.
    1125                 :             : */
    1126                 :             : 
    1127                 :           0 : static DynamicStrings_String Pad (DynamicStrings_String o, unsigned int paddedLength)
    1128                 :             : {
    1129                 :           0 :   unsigned int i;
    1130                 :             : 
    1131                 :           0 :   i = DynamicStrings_Length (o);
    1132                 :           0 :   if (i < paddedLength)
    1133                 :             :     {
    1134                 :           0 :       do {
    1135                 :           0 :         o = DynamicStrings_ConCatChar (o, ' ');
    1136                 :           0 :         i += 1;
    1137                 :           0 :       } while (! (i == paddedLength));
    1138                 :             :     }
    1139                 :           0 :   return o;
    1140                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1141                 :             :   __builtin_unreachable ();
    1142                 :             : }
    1143                 :             : 
    1144                 :             : 
    1145                 :             : /*
    1146                 :             :    doField - compute the string length given in annotation
    1147                 :             :              at position, n, on the stack between characters
    1148                 :             :              b and e.
    1149                 :             : 
    1150                 :             :              The string description between: b..e can contain any
    1151                 :             :              of these patterns:
    1152                 :             : 
    1153                 :             :              %a           ascii name key.
    1154                 :             :              %s           symbol number.
    1155                 :             :              %d           decimal cardinal number.
    1156                 :             :              |            indicates the next field.
    1157                 :             : */
    1158                 :             : 
    1159                 :           0 : static DynamicStrings_String doField (DynamicStrings_String s, unsigned int n, unsigned int f, unsigned int l)
    1160                 :             : {
    1161                 :           0 :   int h;
    1162                 :           0 :   int i;
    1163                 :           0 :   int j;
    1164                 :           0 :   DynamicStrings_String o;
    1165                 :             : 
    1166                 :           0 :   h = DynamicStrings_Length (s);
    1167                 :           0 :   i = SkipToField (s, f);
    1168                 :           0 :   o = DynamicStrings_InitString ((const char *) "", 0);
    1169                 :           0 :   if (i >= 0)
    1170                 :             :     {
    1171                 :           0 :       j = SkipToField (s, f+1);
    1172                 :           0 :       if (j == -1)
    1173                 :             :         {
    1174                 :           0 :           j = h;
    1175                 :             :         }
    1176                 :           0 :       while (i < h)
    1177                 :             :         {
    1178                 :           0 :           switch (DynamicStrings_char (s, i))
    1179                 :             :             {
    1180                 :           0 :               case '|':
    1181                 :           0 :                 i = h;
    1182                 :           0 :                 break;
    1183                 :             : 
    1184                 :           0 :               case '%':
    1185                 :           0 :                 o = doPercent (o, s, &i, h, n);
    1186                 :           0 :                 break;
    1187                 :             : 
    1188                 :             : 
    1189                 :           0 :               default:
    1190                 :           0 :                 o = DynamicStrings_ConCatChar (o, DynamicStrings_char (s, i));
    1191                 :           0 :                 i += 1;
    1192                 :           0 :                 break;
    1193                 :             :             }
    1194                 :             :         }
    1195                 :             :     }
    1196                 :           0 :   o = Pad (o, l);
    1197                 :           0 :   return o;
    1198                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1199                 :             :   __builtin_unreachable ();
    1200                 :             : }
    1201                 :             : 
    1202                 :             : 
    1203                 :             : /*
    1204                 :             :    doAnnotation -
    1205                 :             : */
    1206                 :             : 
    1207                 :           0 : static DynamicStrings_String doAnnotation (DynamicStrings_String s, unsigned int n, unsigned int field, unsigned int width)
    1208                 :             : {
    1209                 :           0 :   int c;
    1210                 :           0 :   DynamicStrings_String cf;
    1211                 :           0 :   DynamicStrings_String o;
    1212                 :             : 
    1213                 :           0 :   c = GetComment (s);
    1214                 :           0 :   if (c >= 0)
    1215                 :             :     {
    1216                 :           0 :       cf = DynamicStrings_Slice (s, c, 0);
    1217                 :           0 :       o = doField (cf, n, field, width);
    1218                 :           0 :       cf = DynamicStrings_KillString (cf);
    1219                 :           0 :       return o;
    1220                 :             :     }
    1221                 :             :   else
    1222                 :             :     {
    1223                 :           0 :       return DynamicStrings_InitString ((const char *) "", 0);
    1224                 :             :     }
    1225                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    1226                 :             :   __builtin_unreachable ();
    1227                 :             : }
    1228                 :             : 
    1229                 :             : 
    1230                 :             : /*
    1231                 :             :    DisplayFields -
    1232                 :             : */
    1233                 :             : 
    1234                 :           0 : static void DisplayFields (unsigned int n, unsigned int tn, unsigned int fn, unsigned int tk)
    1235                 :             : {
    1236                 :           0 :   DynamicStrings_String s;
    1237                 :           0 :   unsigned int t;
    1238                 :           0 :   unsigned int f;
    1239                 :           0 :   unsigned int k;
    1240                 :             : 
    1241                 :           0 :   s = static_cast<DynamicStrings_String> ((*OperandAnno.proc) (n));
    1242                 :           0 :   if (s == NULL)
    1243                 :             :     {
    1244                 :           0 :       t = static_cast<unsigned int> ((*OperandT.proc) (n));
    1245                 :           0 :       f = static_cast<unsigned int> ((*OperandF.proc) (n));
    1246                 :           0 :       k = static_cast<unsigned int> ((*OperandTok.proc) (n));
    1247                 :           0 :       M2Printf_printf0 ((const char *) "| ", 2);
    1248                 :           0 :       Output (Pad (StringConvert_CardinalToString ((unsigned int ) (t), 0, ' ', 10, true), tn));
    1249                 :           0 :       M2Printf_printf0 ((const char *) " | ", 3);
    1250                 :           0 :       Output (Pad (StringConvert_CardinalToString ((unsigned int ) (f), 0, ' ', 10, true), fn));
    1251                 :           0 :       M2Printf_printf0 ((const char *) " | ", 3);
    1252                 :           0 :       Output (Pad (StringConvert_CardinalToString ((unsigned int ) (k), 0, ' ', 10, true), tk));
    1253                 :           0 :       M2Printf_printf0 ((const char *) " |\\n", 4);
    1254                 :             :     }
    1255                 :             :   else
    1256                 :             :     {
    1257                 :           0 :       if (tn > 0)
    1258                 :             :         {
    1259                 :           0 :           M2Printf_printf0 ((const char *) "| ", 2);
    1260                 :           0 :           Output (doField (s, n, 0, tn));
    1261                 :             :         }
    1262                 :           0 :       if (fn > 0)
    1263                 :             :         {
    1264                 :           0 :           M2Printf_printf0 ((const char *) " | ", 3);
    1265                 :           0 :           Output (doField (s, n, 1, fn));
    1266                 :             :         }
    1267                 :           0 :       if (tk > 0)
    1268                 :             :         {
    1269                 :           0 :           M2Printf_printf0 ((const char *) " | ", 3);
    1270                 :           0 :           Output (doField (s, n, 2, tk));
    1271                 :             :         }
    1272                 :           0 :       M2Printf_printf0 ((const char *) " |\\n", 4);
    1273                 :           0 :       if (tn > 0)
    1274                 :             :         {
    1275                 :           0 :           M2Printf_printf0 ((const char *) "| ", 2);
    1276                 :           0 :           Output (doAnnotation (s, n, 0, tn));
    1277                 :             :         }
    1278                 :           0 :       if (fn > 0)
    1279                 :             :         {
    1280                 :           0 :           M2Printf_printf0 ((const char *) " | ", 3);
    1281                 :           0 :           Output (doAnnotation (s, n, 1, fn));
    1282                 :             :         }
    1283                 :           0 :       if (tk > 0)
    1284                 :             :         {
    1285                 :           0 :           M2Printf_printf0 ((const char *) " | ", 3);
    1286                 :           0 :           Output (doAnnotation (s, n, 2, tk));
    1287                 :             :         }
    1288                 :           0 :       M2Printf_printf0 ((const char *) " |\\n", 4);
    1289                 :             :     }
    1290                 :           0 : }
    1291                 :             : 
    1292                 :             : 
    1293                 :             : /*
    1294                 :             :    DebugStack - displays the stack.
    1295                 :             : */
    1296                 :             : 
    1297                 :           0 : extern "C" void M2DebugStack_DebugStack (unsigned int amount, M2DebugStack_ProcedureWord opt, M2DebugStack_ProcedureWord opf, M2DebugStack_ProcedureWord opa, M2DebugStack_ProcedureWord opd, M2DebugStack_ProcedureWord oprw, M2DebugStack_ProcedureWord optk, M2DebugStack_ProcedureString opanno)
    1298                 :             : {
    1299                 :           0 :   unsigned int i;
    1300                 :           0 :   unsigned int tn;
    1301                 :           0 :   unsigned int fn;
    1302                 :           0 :   unsigned int tk;
    1303                 :             : 
    1304                 :           0 :   OperandT = opt;
    1305                 :           0 :   OperandF = opf;
    1306                 :           0 :   OperandA = opa;
    1307                 :           0 :   OperandD = opd;
    1308                 :           0 :   OperandRW = oprw;
    1309                 :           0 :   OperandAnno = opanno;
    1310                 :           0 :   OperandTok = optk;
    1311                 :           0 :   GetStackFieldLengths (&tn, &fn, &tk, amount);
    1312                 :           0 :   i = 1;
    1313                 :           0 :   while (i <= amount)
    1314                 :             :     {
    1315                 :           0 :       if (i == 1)
    1316                 :             :         {
    1317                 :           0 :           DisplayRow (tn, fn, tk, true);
    1318                 :             :         }
    1319                 :           0 :       DisplayFields (i, tn, fn, tk);
    1320                 :           0 :       DisplayRow (tn, fn, tk, i == amount);
    1321                 :           0 :       i += 1;
    1322                 :             :     }
    1323                 :           0 : }
    1324                 :             : 
    1325                 :           0 : extern "C" void _M2_M2DebugStack_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
    1326                 :             : {
    1327                 :           0 : }
    1328                 :             : 
    1329                 :           0 : extern "C" void _M2_M2DebugStack_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
    1330                 :             : {
    1331                 :           0 : }
        

Generated by: LCOV version 2.0-1

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.