StuBS
output.h File Reference

Debug macros enabling debug output on a separate window for each core. More...

#include "debug/nullstream.h"
#include "device/textstream.h"
#include "machine/core.h"
Include dependency graph for output.h:
This graph shows which files directly or indirectly include this file:

Macros

#define DBG_VERBOSE   nullstream
 An output stream, which is only displayed in the debug window in verbose mode.
 
#define DBG   *copyout[Core::getID()]
 An output stream, which is displayed in the debug window of the core it was executed on.
 

Variables

TextStream dout [Core::MAX]
 Debug window for the CGA screen.
 
OutputStreamcopyout [Core::MAX]
 Debug window with copy function to serial.
 

Detailed Description

Debug macros enabling debug output on a separate window for each core.

Macro Definition Documentation

◆ DBG

#define DBG   *copyout[Core::getID()]

An output stream, which is displayed in the debug window of the core it was executed on.

In single core (OOStuBS) this is just an alias to the debug window object dout. However, on a multi core system a debug window for each core is required, therefore dout has to be an TextStream object array with the core ID as array index – the selection is done via Core::getID()

Warning
In case of a very unfavorable scheduling, it is theoretically possible that the debug output in a multi core system is displayed on the wrong (previous) core.

◆ DBG_VERBOSE

#define DBG_VERBOSE   nullstream

An output stream, which is only displayed in the debug window in verbose mode.

Note
If a serial console has been implemented, the output can be redirected to the serial stream instead (by changing the macro) – this makes the (usually) very large output more readable (since it allows scrolling back)

Variable Documentation

◆ copyout

OutputStream* copyout[Core::MAX]
extern

Debug window with copy function to serial.

Provide an additional layer to ouput one debug output also to serial. While this is a simple CopyStream pointer in the single core case, it is an array in the multi core case, which consists of thre TextStreams and one CopyStream. For that, construction is done like:

The class OutputStream corresponds, essentially, to the class ostream from the C++ IO-Stream library.
Definition: outputstream.h:61
const unsigned MAX
Maximum number of supported CPUs.
Definition: core.h:28
OutputStream * copyout[Core::MAX]
Debug window with copy function to serial.
Definition: main.cc:21
TextStream dout[Core::MAX]
Debug window for the CGA screen.
Definition: main.cc:7

◆ dout

TextStream dout[Core::MAX]
extern

Debug window for the CGA screen.

Debug output using DBG like DBG << "var = " << var << endl should be displayed in window dedicated to the core it is executed on.

While this is quite easy on single core systems like OOStuBS – they only require a single TextStream object called dout – multi core systems like MPStuBS need an object array with one window per core. In the latter case direct list initialization can be used:

{0, 40, 17, 21}, // Debug window for core 0, like TextStream(0, 40, 17, 21)
{40, 80, 17, 21}, // Debug window for core 1, like TextStream(40, 80, 17, 21)
//...
};
Output text (form different data type sources) on screen in text mode.
Definition: textstream.h:23

The debug windows in should be located right below the normal output window without any overlap and should be able to display at least 3 lines. In MPStuBS, two windows can be placed side-by-side, having 40 columns each.