Sometimes logging of an application's events is the only debugging method. The logging method's disadvantage is the large size of the code which you have to write manually to save the whole necessary information. The article touches upon the method allowing you to build a system of automatic logging of C/C++ code.
Debugging and optimization of multi-thread OpenMP-programsPVS-Studio
The task of familiarizing programmers with the sphere of developing parallel applications is getting more and more urgent. This article is a brief introduction into creation of multi-thread applications based on OpenMP technology. The approaches to debugging and optimization of parallel applications are described.
Debugging and optimization of multi-thread OpenMP-programsPVS-Studio
The task of familiarizing programmers with the sphere of developing parallel applications is getting more and more urgent. This article is a brief introduction into creation of multi-thread applications based on OpenMP technology. The approaches to debugging and optimization of parallel applications are described.
Introduction to Visual Basic 6.0 FundamentalsSanay Kumar
A powerpoint presentation on Intoduction To Visual Basic 6.0. This ppt contains slides on variuos topics of visual programming, IDE, and COM based Microsoft's software VB 6.0.
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio
This document advertises the PVS-Studio static analyzer. It describes how using PVS-Studio reduces the number of errors in code of C/C++/C++11 projects and costs on code testing, debugging and maintenance. A lot of examples of errors are cited found by the analyzer in various Open-Source projects. The document describes PVS-Studio at the time of version 4.38 on October 12-th, 2011, and therefore does not describe the capabilities of the tool in the next versions. To learn about new capabilities, visit the product's site http://www.viva64.com or search for an updated version of this article.
This presentation is co-authored with my son for a website project that demonstrates a sort of autobiography of his life. The purpose is to learn powerpoint and how to build a simple website.
Introduction to Visual Basic 6.0 FundamentalsSanay Kumar
A powerpoint presentation on Intoduction To Visual Basic 6.0. This ppt contains slides on variuos topics of visual programming, IDE, and COM based Microsoft's software VB 6.0.
PVS-Studio advertisement - static analysis of C/C++ codePVS-Studio
This document advertises the PVS-Studio static analyzer. It describes how using PVS-Studio reduces the number of errors in code of C/C++/C++11 projects and costs on code testing, debugging and maintenance. A lot of examples of errors are cited found by the analyzer in various Open-Source projects. The document describes PVS-Studio at the time of version 4.38 on October 12-th, 2011, and therefore does not describe the capabilities of the tool in the next versions. To learn about new capabilities, visit the product's site http://www.viva64.com or search for an updated version of this article.
This presentation is co-authored with my son for a website project that demonstrates a sort of autobiography of his life. The purpose is to learn powerpoint and how to build a simple website.
Catholic University of America College of Library and Information Sciences LSC 747 Special Collections lecture summer 2011 at the Smithsonian Institution
The pragmatic programmer 1999
Andy Hunt, Dave Thomas
Chapter 3 / The Basic Tools
Quick review about programmer's tools , power of plain text, debugging, source code control and so on...
Advantages of golang development services & 10 most used go frameworksKaty Slemon
Golang is a programming language trusted by companies like Dropbox, Facebook, Netflix & Uber. Here we are providing Golang pros & list of top 10 Golang Frameworks.
Testing parallel software is a more complicated task in comparison to testing a standard program. The programmer should be aware both of the traps he can face while testing parallel code and existing methodologies and toolkit.
Angular is a powerful tool for managing the display of data. However, like any powerful tool there can be trouble if misused. Below we’ll look at some common AngularJS mistakes. They vary in severity, but ultimately can conspire to make developing an AngularJS application more of a headache than it needs to be. We’ll cover five of these common mistakes, and ways to avoid them.
Secret Twists to Efficiently Develop Reactive Software SystemsBart Jonkers
A successful software design for reactive software systems follows the three design principles:
■ Divide and conquer, then reuse effectively
■ Visualize your system
■ Automatically and formally verify everything, always
These principles are easy in theory. With traditional programming, however, it is extremely challenging to master them.
Reactive blocks, on the other hand, are a new type of software modules that make the three design principles a natural part of the design process.I
n this whitepaper, we present the secret twists to make these principles work for you and your organization.
Polyline download and visualization over terrain modelsgraphitech
The project implements a number of optimizations to allow
better performance in the visualization of the height model. A client-server architecture allows different themes to be stored within a server, and downloaded using the terrain viewer. Realized using JOGL library.
Management of errors in multi-tenant cloud based applications remains a challenging problem. This
problem is compounded due to (i) multiple versions of application serving different clients, (ii) agile nature
in which the applications are released to the clients, and (iii) variations in specific usage patterns of each
client. We propose a framework for isolating and managing errors in such applications. The proposed
framework is evaluated with two different popular cloud based applications and empirical results are
presented.
Error Isolation and Management in Agile Multi-Tenant Cloud Based Applications neirew J
Management of errors in multi-tenant cloud based applications remains a challenging problem. This
problem is compounded due to (i) multiple versions of application serving different clients, (ii) agile nature
in which the applications are released to the clients, and (iii) variations in specific usage patterns of each
client. We propose a framework for isolating and managing errors in such applications. The proposed
framework is evaluated with two different popular cloud based applications and empirical results are
presented.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Let's dive deeper into the world of ODC! Ricardo Alves (OutSystems) will join us to tell all about the new Data Fabric. After that, Sezen de Bruijn (OutSystems) will get into the details on how to best design a sturdy architecture within ODC.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Building of systems of automatic C/C++ code logging
1. Building of systems of automatic C/C++
code logging
Author: Andrey Karpov
Date: 13.05.2008
Abstract
Sometimes logging of an application's events is the only debugging method. The logging method's
disadvantage is the large size of the code which you have to write manually to save the whole necessary
information. The article touches upon the method allowing you to build a system of automatic logging
of C/C++ code.
Introduction
Despite the current epoch C and C++ languages remain leaders in many programming spheres. And this
will hardly change in nearest 10 years. A lot of nice and interesting languages have appeared but C and
C++ are more preferable in practice. They are ones of the best existing languages - universal, high-
performance and with wide support. If you want to learn why these languages are so attractive, I
recommend you to get acquainted with the article "Tools and performance" [1] and an interesting
collection of messages from comp.lang.c++.moderated forum "Why do you program in c++?" [2]. All this
means that development of a toolkit for C/C++ languages is still topical.
In all the languages there are errors made by developers, and C/C++ are not an exclusion. Moreover, as
well as many professional tools, they require more attention and accuracy. As the result one of the most
important tasks while developing applications is code debugging, i.e. search and correction of errors.
Debugging methods can be divided into the following main groups:
• Interactive debugging tools;
• Runtime-diagnosis;
• Visual (graphical) debugging tools;
• Unit Testing;
• Functional tests;
• Logging;
• Crash-dumps debugging;
• Code review;
• Static code analysis.
Each of the mentioned methods has its advantages and disadvantages about which you may read in the
article "Ways of debugging applications" [3]. But within the framework of our article we'll speak about
logging and methods of its automation.
2. 1. Why logging?
At first logging of applications' work may seem non-topical. Perhaps, it's just an atavism of those times
when the results of a program's work would be immediately printed? No, this is a very effective and
often very essential method allowing you to debug complex, parallel or specific applications.
Let's consider the spheres where logging is irreplaceable because of its convenience and efficiency:
1. Debugging of release-versions of an application. Sometimes a release-version behaves in a
different way than a debug-version and it may be related to the errors of uninitialized memory
etc. But it is often inconvenient to work with the release-version in debugger. And besides,
although it happens quite seldom, there are compiler's errors which appear only in release-
versions. Logging in these cases is a good substitute for compiler.
2. Debugging of security mechanisms. Development of applications with hardware security (for
example, on the basis of Hasp keys) is often difficult because debugging is impossible here.
Logging in this case seems to be the only way of searching for errors.
3. Logging is the only possible debugging method for an application, launched on the end user's
computer. Accurate use of the log file will allow the developers to get the full information
necessary for diagnosis of appearing problems.
4. Logging allows you to debug devices' drivers and programs for embedded systems.
5. Logging allows you to quicker detect errors after batch launch of functional or load tests.
6. One more interesting case of using logs is to view differences between two different versions
(diff). The reader can think himself where in his projects it can be useful.
7. Logging enables remote debugging when interactive means are impossible or inaccessible. This
is convenient for high-performance multi-user systems where the user puts his tasks into a
queue and waits for them to be fulfilled. This approach is used nowadays in institutions and
other organizations working with computing clusters.
8. Possibility to debug parallel applications. In such applications errors often occur when creating a
lot of threads or when there are problems with synchronization. Errors in parallel programs are
rather difficult to correct. A good method of detecting such errors is periodical logging of
systems which relate to the error and examining of the log's data after program crash [ 1].
This list is too large to reject logging method. I hope that this article will help you to find other ways to
use the described logging method with success.
2. Creation of a logging system
Let's begin with demands fulfilled by a modern logging system:
• The code providing logging of data in the debug-version shouldn't be present in the release-
version of a program product. Firstly, it is related to speeding up performance and decreasing
the size of the program product. Secondly, it makes impossible to use the logging information
for cracking the application or other illegal actions. Pay attention that it is the final version of
the program that is meant as the log may be created by both debug- and release-versions.
• Logging system's interfaces should be compact in order not to overload the main program code.
• Saving of data should be carried as quickly as possible in order to bring the minimum change
into temporary characteristics of parallel algorithms.
• The received log should be understandable and easy to analyze. There should be a possibility to
divide information received from different threads and to vary the number of its details.
3. • Besides logging of the application's events themselves, it is useful to collect data about the
computer.
• It is desirable that the system save the unit's name, the file's name and the string's number
where data record occurred. Sometimes it is useful to save the time when the event took place.
A logging system meeting these demands allows you to fulfill various tasks from developing security
mechanism to searching for errors in parallel algorithms [4].
Although this article is devoted to a system of data logging, it won't touch upon some particular
complete version of such a system. The universal version is impossible as it much depends upon the
development environment, the project's peculiarities, the developer's preferences etc. By the way,
consider some articles concerning these questions: "Logging in C++" [5] and "Ways of debugging
applications: Logging" [6].
Now let's speak about some technical solutions which will help you to create a convenient and efficient
logging system when you need it.
The simplest way to carry out logging is to use a function similar to printf as in the following example:
int x = 5, y = 10;
...
printf("Coordinate = (%d, %d)n", x, y);
The natural disadvantage here is that information will be shown both in the debug-mode and in the
release-version. That's why we should modify the code in the following way:
#ifdef DEBUG_MODE
#define WriteLog printf
#else
#define WriteLog(a)
#endif
WriteLog("Coordinate = (%d, %d)n", x, y);
This is better. And pay attention that to implement WriteLog function we use our own macro
DEBUG_MODE instead of the standard _DEBUG. This allows you to include logging information into
release-versions what is important when debugging at large data size.
Unfortunately, now when compiling a non-debug version, for example in Visual C++ environment, a
warning message appears: "warning C4002: too many actual parameters for macro 'WriteLog'". You may
disable this warning but it will be a bad style. You can rewrite the code as follows:
#ifdef DEBUG_MODE
#define WriteLog(a) printf a
#else
#define WriteLog(a)
4. #endif
WriteLog(("Coordinate = (%d, %d)n", x, y));
This code is not smart as you have to use double bracket pairs and you can lose them. That's why let's
improve it a bit:
#ifdef DEBUG_MODE
#define WriteLog printf
#else
inline int StubElepsisFunctionForLog(...) { return 0; }
static class StubClassForLog {
public:
inline void operator =(size_t) {}
private:
inline StubClassForLog &operator =(const StubClassForLog &)
{ return *this; }
} StubForLogObject;
#define WriteLog
StubForLogObject = sizeof StubElepsisFunctionForLog
#endif
WriteLog("Coordinate = (%d, %d)n", x, y);
This code looks complicated but it allows you to write single brackets. When DEBUG_MODE is disabled
this code turns to nothing and you can safely use it in critical code sections.
The next improvement is to add to the logging function such parameters as the number of details and
the type of printed information. The number of details can be defined as a parameter, for example:
enum E_LogVerbose {
Main,
Full
};
#ifdef DEBUG_MODE
void WriteLog(E_LogVerbose,
const char *strFormat, ...)
5. {
...
}
#else
...
#endif
WriteLog (Full, "Coordinate = (%d, %d)n", x, y);
This method is convenient because the decision whether to filter unimportant messages or not can be
made after the program's shutdown by using a special utility. This method's disadvantage is that the full
information is always printed, both important and unimportant what may decrease the performance.
That's why you may create several functions of WriteLogMain- and WriteLogFull-type and similar to
them, implementation of which will depend upon the program build mode.
We mentioned that record of logging information must influence the speed of the algorithm's work as
little as possible. You may get it by creating a system of collecting messages which are recorded in a
parallel thread. Now it has even more advantages because of wide spread of multi-core (multi-
processor) systems. The scheme of this mechanism is shown on picture 1.
6. Picture 1.Logging system with delayed data record.
As you may see on the picture, the next data portion is recorded into an intermediate array with strings
of fixed length. The fixed length of the array and its strings allows you to avoid expensive operation of
memory allocation. It doesn't decrease this system's possibilities at all. You can just select the strings'
length and the array's size with some reserve. For example, 5000 strings of 4000-symbol length will be
enough for debugging nearly any system. I think you agree that 20-MB memory size necessary for this is
not critical for modern systems. But if an overflow of the array still occurs, you can easily create a
mechanism of anticipatory information record into the file.
This mechanism provides nearly instant execution of WriteLog function. If there are unloaded processor
cores in the system, the file record will be transparent for main threads of the program being logged.
The advantage of the described system is that it can work practically without changes when debugging a
parallel program, when several threads are written into the log simultaneously. You should only add
saving of a thread-indicator so that you can later see from which threads messages were received (see
Picture 2).
7.
8. Picture 2. Logging system when debugging multithread applications.
This scheme can cause change of temporal characteristics as several threads being logged have to wait
for each other to carry out information record. If it is critical you may create separate message storages
for each of the threads as is shown on Picture 3. In this case you should also record the time of the
events so that you could later merge two logs into one.
9.
10. Picture 3. Improved logging system when debugging multithread applications.
The last improvement I would like to offer is providing demonstration of message nesting level when
calling functions or in the beginning of a logical block. You can easily implement it by using a special class
which writes the block's beginning identifier into the log in the constructer and the block's end identifier
in the destructor. By writing a small utility you may transform the log relying on the information about
identifiers. Let's try to show it by example.
11. Program code:
class NewLevel {
public:
NewLevel() { WriteLog("__BEGIN_LEVEL__n"); }
~NewLevel() { WriteLog("__END_LEVEL__n"); }
};
#define NEW_LEVEL NewLevel tempLevelObject;
void MyFoo() {
WriteLog("Begin MyFoo()n");
NEW_LEVEL;
int x = 5, y = 10;
printf("Coordinate = (%d, %d)n", x, y);
WriteLog("Begin Loop:n");
for (unsigned i = 0; i != 3; ++i)
{
NEW_LEVEL;
WriteLog("i=%un", i);
}
}
The log's content:
Begin MyFoo()
__BEGIN_LEVEL__
Coordinate = (5, 10)
Begin Loop:
__BEGIN_LEVEL__
i=0
__END_LEVEL__
__BEGIN_LEVEL__
i=1
__END_LEVEL__
12. __BEGIN_LEVEL__
i=2
__END_LEVEL__
Coordinate = (5, 10)
__END_LEVEL__
The log after transformation:
Begin MyFoo()
Coordinate = (5, 10)
Begin Loop:
i=0
i=1
i=2
Coordinate = (5, 10)
3. Automation of logging system
We have considered principles on which a logging system can be implemented. All the demands
described in the first part can be implemented in such a system. But a serious disadvantage of this
system is the necessity to write a great amount of code for recording all the necessary data. There are
other disadvantages too:
1. Impossibility to implement smart logging functions for C language as it lacks classes and
templates. As the result the code for logging is different for C and C++ files.
2. Necessity to keep in mind that you should write NEW_LEVEL in every block or function if you
wish your code look smart.
3. Impossibility to automatically save names of all called functions. Necessity to manually write the
input function arguments.
4. Overload of source texts with additional constructions as, for example, NEW_LEVEL.
5. Necessity to make an effort to control that all the logging constructions should be excluded from
the final version of the program.
6. Necessity to write functions for initializing a logging system, to write all the necessary "#include"
and perform other auxiliary actions.
All these and other inconveniences can be avoided if you build a system of automatic logging of testing
of applications.
This system can be implemented on the basis of metaprogramming method, introducing new
constructions of data record into C/C++ language.
Metaprogramming is creation of programs which in their turn create other programs [7]. There are two
main trends in metaprogramming: code generation and self-modified code. We are interested in the
first one. In this case the program code with embedded logging mechanisms is not written manually but
13. created automatically by a generator-program on the basis of another, simpler program. This allows you
to get a program at less time and effort costs than in the case when a programmer implements the
whole code himself.
There are languages in which metaprogramming is their constituent part. Such an example is Nemerle
language [8]. But it is more difficult for C/C++ and metaprogramming in them is implemented in two
following ways:
1. Templates in C++ and preprocessor in C. Unfortunately, as was shown before, it's not enough.
2. Outer language means. The generator's language is composed in the way to automatically or
with a programmer's minimum effort implement paradigm's rules or necessary special
functions. In fact, a more high-level programming language is created. It is this approach that
can be used for creation of a system of automated program logging.
By introducing new keywords into C/C++ you can get a flexible and convenient programming system
with very powerful logging possibilities. Use of metalanguage provides great possibilities of choosing the
form in which the necessary information will be recorded. You may log the data by introducing the
common function format:
EnableLogFunctionCallForFhisFile(true);
...
ObjectsArray &objects = getObjects();
WriteLog("objects.size = %u", objects.size());
for (size_t i = 0; i != objects.size(); ++i) {
WriteLog("object type = %i", int(objects[i]->getType()));
if (objects[i]->getType() != TYPE_1)
...
Since the code generator can recognize the data types being used, you may simplify logging of variables
and shorten the record. For example:
ObjectsArray &objects = getObjects();
MyLog "objects.size = ", objects.size()
for (size_t i = 0; i != objects.size(); ++i) {
MyLog "object type = ", int(objects[i]->getType())
if (objects[i]->getType() != TYPE_1)
...
You may go further as everything here depends upon the author's fantasy:
thisfile.log.FunctionCall = ON
...
14. ObjectsArray &objects = getObjects();
for (size_t i = 0;
i != <log>"objects.size = "objects.size()<log>;
++i) {
LOG: "object type = " {as int} objects[i]->getType();
if (objects[i]->getType() != TYPE_1)
...
The new metalanguage can be implemented as an intermediate constituent between a preprocessor
and a compiler. It depends upon the development environment how this intermediate component for
translating a metaprogram should look. In general, the functioning scheme looks as on Picture 4.
15. Picture 4. Role of metalanguage translator in the compilation process.
Now let's consider the translator itself. Its functional scheme is shown on Picture 5.
16. Picture 5. Functional scheme of language translator for generating code with logging support.
17. Let's dwell upon the code generator. It is an algorithm of traversing the tree and carrying out three
operations over it. The first is collecting types of all the functions and objects and estimating their
visibility scope. It will allow you to automatically generate code for correct record of arguments of
functions and other objects. Secondly, metalanguage constructions are opened into new tree branches.
And thirdly, processed code branches are recorded back into the file.
It is not so simple to implement such a generator as well as a syntactic analyzer. But there are
corresponding libraries which will be described further.
Let's see how generation of program code solves the above mentioned disadvantages of a system built
only on the basis of macros and templates.:
1. Logging constructions in C may look as smart as in C++. The generator performs the duty of
turning reserved words into code for writing messages. It is transparent for the user that this
code will look in different ways in C and C++ files.
2. The generator can automatically insert code for marking the beginning and the end of functions
or blocks. There is no need to use NEW_LEVEL macro.
3. You may automatically save the names of all or some of the functions being called. You may also
automatically save values of input parameters for basic data types.
4. The text is no more overloaded with auxiliary constructions.
5. It is guaranteed that all the functions, sources and objects won't be present in the final version
of the program product. The generator can just skip all the special elements related to logging in
the program text.
6. There is no need to write initializing functions, to insert "#include" and perform other auxiliary
actions as they can be implemented at the step of code translation.
But this scheme has a problem of debugging of such modified programs with the help of a debugger. On
the one hand, if there is a logging system, the debugger is not an important component of application
development. But on the other hand, it is often a very useful tool and you don't want to refuse it.
The trouble is that after code translation (opening of operators for logging) there is a problem of
navigation on strings' numbers. It can be solved with the help of specific program means which are
individual for each development environment. But there is a simpler way. You may use the approach
similar to one in OpenMP, i.e. use "#pragma". In this case the logging code will look like this:
ObjectsArray &objects = getObjects();
#pragma Log("objects.size = ", objects.size())
for (size_t i = 0; i != objects.size(); ++i) {
#pragma Log("object type = ", objects [i]->getType())
if (objects[i]->getType() != TYPE_1)
...
It's not so smart because of the word "#pragma" but this program text has great advantages. This code
can be safely compiled on another system where a system of automatic logging is not used. This code
can be ported on another system or be given to third-party developers. And of course there are no
obstacles in working with this code in the debugger.
18. 4. Toolkit
Unfortunately, I don't know if there are metalanguage-based tools of automated logging similar in
functionality to those described in the article. If further research shows the absence of such
developments, perhaps I will take part in a new project which is being designed now. One may say this
article is a kind of research whether a universal logging system for C/C++ languages is topical.
And for the present I offer the readers who got interested to create a logging system by themselves.
Whether it is just a set of templates and macros or a full system of code generation depends upon the
need for such a system and the amount of resources necessary to create it.
If you will stop at creation of a metalanguage we'll advise you on what basis it can be created.
There are two most suitable free libraries allowing you to represent a program as a tree, translate it and
save it as a program again.
One of them is OpenC++ (OpenCxx) [9]. It is an open free library which is a "source-to-source" translator.
The library supports metaprogramming and allows you to create on its basis extensions of C++ language.
On the basis of this library such solutions were created as an execution environment OpenTS for T++
programming language (product by Institution of program systems RAS) and Synopsis tool for preparing
documentation on the source code.
The second library is VivaCore which is a development of OpenC++ library oriented on Microsoft Visual
Studio 2005/2008 development environment [10]. This library is also open and free. Its main differences
are implemented support of C language and of some modern elements of C++ language. Static analyzers
Viva64 and VivaMP are examples how such a library can be used.
If you would like to use these libraries to create your own extensions you will need a preprocessor that
must be launched before they start working. Most likely, preprocessing means embedded into the
compiler will be enough. Otherwise you may try to use The Wave C++ preprocessor library.
Conclusion
The article is of a theoretical character but I hope that developers will find here a lot of interesting and
useful ideas related to the sphere of logging of their programs' code. Good luck!
Sources
1. Scott Bilas. Tools & Productivity. Casual Connect Magazine (Winter 2007) -
http://www.viva64.com/go.php?url=108.
2. Over at comp.lang.c++.moderated, there is a thread created by the c++ guru Scott Meyers on
the subject: "Why do you program in c++?" http://www.viva64.com/go.php?url=35
3. Dmitriy Dolgov. Ways of debugging applications. http://www.viva64.com/go.php?url=36
4. Andrey Karpov, Evgeniy Ryzhkov. Development of resource-intensive applications in Visual C++
http://www.viva64.com/art-1-2-2014169752.html
5. Petru Marginean. Logging In C++. http://www.viva64.com/go.php?url=37
6. Dmitriy Dolgov. Methods of debugging applications: Logging.
http://www.viva64.com/go.php?url=38
7. Jonathan Bartlett. The art of metaprogramming, Part 1: Introduction to metaprogramming.
http://www.viva64.com/go.php?url=109
19. 8. Nemerle. http://nemerle.org/
9. Grzegorz Jakack. OpenC++ - A C++ Metacompiler and Introspection Library.
http://www.viva64.com/go.php?url=41
10. Andrey Karpov, Evgeniy Ryzhkov. The essence of the code analysis library VivaCore.
http://www.viva64.com/art-2-2-449187005.html
About the author
Andrey Karpov, Candidate of Physico-mathematical Sciences, science consultant of OOO "Program
Verification Systems" specializing in questions of increasing quality of program systems. Solves
theoretical and practical questions of static code analysis. Takes part in creation of VivaCore library and
code analyzers Viva64, VivaMP.
Page on LinkedIn site: http://www.viva64.com/go.php?url=471
E-Mail: karpov@viva64.com