OOStuBS - Technische Informatik II (TI-II)  2.4
analyse.cc
gehe zur Dokumentation dieser Datei
1 #include "user/analyse.h"
2 #include "common/o_stream.h"
3 #include "object/kout.h"
4 
5 O_Stream& printFormatted(void* value){
6  unsigned long test=(unsigned long)value;
7  int toFill=2*sizeof(void*);
8  if(!test)toFill--;
9  while(test){
10  toFill--;
11  test>>=4;
12  }
13  while(toFill){
14  kout << ' ';
15  toFill--;
16  }
17  return kout << hex << value;
18 }
19 
20 void analyseException(unsigned short slot, void** esp){
21  //Ausgabe, was passiert ist
22  kout << endl;
23  kout << "analyseException(" << slot << ", " << esp << ") called" << endl;
24 }
25 
26 void analyseProcedureStack(void** esp, const char* function){
27  //Ausgabe, was passiert ist
28  kout << endl;
29  kout << function << "(" << esp << ") called" << endl;
30 
31  /* * * * * * * * * * * * * * * * * * *\
32  # Start ToDo-Bereich #
33  \* * * * * * * * * * * * * * * * * * */
34  //TODO Analyse-Ausgaben hier hin
35  int i, k;
36  bool bGoOn;
37 
38  kout << "Stack:" << endl;
39  bGoOn = true;
40  for(i=0; bGoOn && i<20; i++){
41  kout << (int*)(esp)+ i*4;
42  kout << " ";
43  for(k=0; k<4 && bGoOn; k++){
44  //Abbruchbedingung
45  bGoOn = (esp[i*4+k]!=(void*)0xEEEEEEEE);
46 
47  //falls kein Abbruch, weiter
48  if(bGoOn){
49  printFormatted(esp[i*4+k]) << " ";
50  }
51  }
52  if(k==4){
53  kout << endl;
54  }
55  }
56  //Ende ausgeben
57  if(!bGoOn){
58  //zu weite Zaehlung korrigieren
59  i--;
60  k--;
61  //ausgeben
62  if(k!=0){
63  kout << " ";
64  }
65  printFormatted(esp[i*4+k]) << " ";
66  printFormatted(esp[i*4+k+1]) << " ";
67  printFormatted(esp[i*4+k+2]) << " ";
68  printFormatted(esp[i*4+k+3]) << endl;
69  }
70  kout.flush();
71  kout << dec;
72 
73  /* * * * * * * * * * * * * * * * * * *\
74  # Ende ToDo-Bereich #
75  \* * * * * * * * * * * * * * * * * * */
76 }