Miscellaneous slides

Here are some presentations we made about various subjects. They might be interesting for people wanting to use and/or modify Diablo.

DWARF2 debug information

I am currently working on the incorporation of debug information in Diablo. I will implement a DWARF2 backend, and once this information can be read nicely we will have to look on how to represent and use it in the Diablo infrastructure.

I am currently aiming at presenting line number information in Lancet. The latter will improve the understanding of the control flow graphs and the code therein.

For the moment, reading line number info seems to work well and the info is attached to the instructions using a dynamic member.

Submitting patches

When you find and fix a bug in the Diablo source code, or when you add new functionality to Diablo, you can get your changes incorporated in the next Diablo release by submitting a patch.

Before we explain how to do so, some important points:

  • First of all, Diablo is GPL, so all patches to Diablo need also be GPL. If you want to get your patch accepted, you must allow that your code will be released as GPL.
  • Second, if that is no problem, make sure that your code compiles correctly when applied on a (fairly) recent version of Diabl
  • Third, we use GNU coding standards. If your not familiar with these standards please read http://www.gnu.org/prep/standards. Your code must follow these standards, even in new files.

Infrastructure and support API

This section introduces Diablo's underlying programming infrastructure.

The Flowgraph Layer

2. The Flowgraph Layer

On top of the diabloobject library, Diablo also offers the diabloflowgraph library. This library offers a more detailed view of the program code sections by splitting them in individual instructions and constructing a control flow graph. This control flow graph, combined with the data dependency graph from the link layer, forms the Augmented Whole-Program Control Flow Graph (AWPCFG), which is Diablo's most detailed representation of the program that is being rewritten.

The basic data structures in this layer are:

  1. t_cfg: the control flow graph.

The Link Layer

1. The Link Layer

At the link layer, represented by the diabloobject library, there are five important data structures:

  1. t_object: an object file (relocatable or executable)
  2. t_relocatable: the base class for all relocatable entities
  3. t_section: an object file section (code or data or ...). This is a relocatable entity and thus derived from t_relocatable.
  4. t_symbol: a "label" attached to a relocatable entity
  5. t_reloc: a relocation. This structure conveys information about the relations existing between different relocatable entities.

Input/Output

Diablo provides a number of wrappers to facilitate IO:

The functions described hereafter print a message which can contain conversion specifiers, each of which results in fetching zero or more subsequent arguments. These conversion specifiers will be discussed later.

VERBOSE((t_int32 verboselevel), (t_string message, ...));

This function will print the message if diablosupport_options.verbose is larger than or equal to verboselevel.

FATAL((t_string message, ...));

This function can be used to print out a message before terminating the program.

Memory Management

To facilitate dynamic memory management, diablo provides an interface which can help in the detection of memory leaks. To use this functionality, a programmer should not use the default functions to allocate and free dynamic memory, but should revert to the diablo variants. Their usage is identical to that of the standard c functions. The only difference is that they start with capital letters.

void * Calloc(size_t nmemb, size_t size);
void * Malloc(size_t size);
void * Realloc(void *ptr, size_t size);
void Free(void *ptr);

Adding Commandline Options

Diablo provides with an easy way to specify options. The format to specify an option is as follows:

[group "name_of_group"] [hidden] [required|forbidden [ifset|ifnotset (option_list)]]option_type option_name
{
  [short="";]
  [long="";]
  [default=;]
  [description="description of the option"]
  [environment=""]
}

Options can be grouped by giving them the same group name.

If the hidden flag is set, they will not be printed when diablo is invoked with the help option.

One can specify wheter the option is required and/or forbidden as such or in the presence of other options. The option_list consist of options combined by (), && and || in their usual meaning.

The Function Broker

The Function Broker mechanism enables the usage of different implementations to perform a function depending on the backend, application, etc., while maintaining a single, stable core fit for all the different backends and applications. The Broker interface consists of three functions:

void DiabloBrokerCallInstall(char * name, char * prototype, void * implementation, t_bool final, ...);

This function can be used to install an implementation for the function with name name. The boolean argument indicates whether or not this implementation can be extended by other applications.

Syndicate content