w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RtraceTools.cpp
Go to the documentation of this file.
1// $Id: RtraceTools.cpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2019- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2019-05-12 1149 1.0.1 add level 5 (full word dump)
8// 2019-04-27 1140 1.0 Initial version
9// ---------------------------------------------------------------------------
10
17
18#include "RtraceTools.hpp"
19
20using namespace std;
21
27// all method definitions in namespace Retro
28namespace Retro {
29namespace RtraceTools {
30
31//------------------------------------------+-----------------------------------
33
34void TraceBuffer(RlogMsg& lmsg, const uint16_t* pbuf, size_t done,
35 uint32_t level)
36{
37 size_t nchar = 0;
38 switch (level) {
39 case 2: // level=2: compact ascii --------
40 for (size_t i=0; i < done; i++) {
41 uint8_t ochr = pbuf[i] & 0377;
42 if (ochr>=040 && ochr<0177) {
43 if (nchar == 0) lmsg << "\n '";
44 lmsg << char(ochr);
45 nchar += 1;
46 if (nchar >= 64) {
47 lmsg << "'";
48 nchar = 0;
49 }
50 } else {
51 if (nchar > 0) lmsg << "'";
52 lmsg << "\n ";
53 TraceChar(lmsg, ochr);
54 nchar = 0;
55 }
56 }
57 if (nchar > 0) lmsg << "'";
58 break;
59
60 case 3: // level=3: compact octal --------
61 for (size_t i=0; i < done; i++) {
62 if (nchar == 0) lmsg << "\n ";
63 uint8_t ochr = pbuf[i] & 0377;
64 lmsg << ' ' << RosPrintBvi(ochr,8);
65 nchar += 1;
66 if (nchar >= 16) nchar = 0;
67 }
68 break;
69
70 case 4: // level=4: octal + ascii --------
71 for (size_t i=0; i < done; i++) {
72 if (nchar == 0) lmsg << "\n ";
73 uint8_t ochr = pbuf[i] & 0377;
74 lmsg << " " << RosPrintBvi(ochr,8) << ' ';
75 TraceChar(lmsg, ochr);
76 nchar += 1;
77 if (nchar >= 6) nchar = 0;
78 }
79 break;
80
81 case 5: // level=4: full word dump -------
82 for (size_t i=0; i < done; i++) {
83 bool val = (pbuf[i] & 0x8000) != 0;
84 uint8_t size = (pbuf[i]>>8) & 0177;
85 uint8_t ochr = pbuf[i] & 0377;
86 lmsg << "\n " << RosPrintf(i,"d",3)
87 << " : " << val
88 << " " << RosPrintf(size,"d",3)
89 << " " << RosPrintBvi(size,8)
90 << " : " << RosPrintBvi(ochr,8)
91 << " ";
92 TraceChar(lmsg, ochr);
93 }
94 break;
95 }
96
97 return;
98}
99
100//------------------------------------------+-----------------------------------
102
103void TraceChar(RlogMsg& lmsg, uint8_t chr)
104{
105 lmsg << ((chr&0200) ? "|" : " ");
106 uint8_t chr7 = chr & 0177;
107 if (chr7 < 040) {
108 switch (chr7) {
109 case 010: lmsg << "BS "; break;
110 case 011: lmsg << "HT "; break;
111 case 012: lmsg << "LF "; break;
112 case 013: lmsg << "VT "; break;
113 case 014: lmsg << "FF "; break;
114 case 015: lmsg << "CR "; break;
115 case 033: lmsg << "ESC"; break;
116 default: lmsg << "^" << char('@'+chr7) << " ";
117 }
118 } else {
119 if (chr7 < 0177) {
120 lmsg << "'" << char(chr7) << "'";
121 } else {
122 lmsg << "DEL";
123 }
124 }
125 return;
126}
127
128} // end namespace RtraceTools
129} // end namespace Retro
FIXME_docs.
Definition: RlogMsg.hpp:24
RosPrintfS< bool > RosPrintf(bool value, const char *form=0, int width=0, int prec=0)
Creates a print object for the formatted output of a bool value.
Definition: RosPrintf.ipp:38
void TraceBuffer(RlogMsg &lmsg, const uint16_t *pbuf, size_t done, uint32_t level)
FIXME_docs.
Definition: RtraceTools.cpp:34
void TraceChar(RlogMsg &lmsg, uint8_t chr)
FIXME_docs.
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47