flowbber.plugins.sources.valgrind.drd

Valgrind DRD

This source parses and collects information from the XML generated by Valgrind’s DRD tool.

Such XML file can be generated with:

$ valgrind \
    --tool=drd \
    --gen-suppressions=all \
    --read-var-info=yes \
    --error-exitcode=1 \
    --xml=yes \
    --xml-file=drd.xml \
    ./executable

Data collected:

Important

Sadly, Valgrind’s XML format doesn’t include a field with the total number of errors, just an array of which errors were found. A total_errors field is injected to allow the user to easily track the evolution of the amount of errors.

{
    "protocolversion":"4"
    "protocoltool":"drd"
    "preamble":{
        "line":[
            "drd, a thread error detector",
            "Copyright (C) 2006-2015, and GNU GPL'd, by Bart Van Assche.",
            "Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info",
            "Command: ./binary"
        ]
    },
    "pid":"10812"
    "ppid":"2162",
    "tool": "drd"
    "args":{
        "vargv":{
            "exe":"/usr/bin/valgrind.bin",
            "arg":[
                "--tool=drd",
                "--gen-suppressions=all",
                "--read-var-info=yes",
                "--error-exitcode=1",
                "--xml=yes",
                "--xml-file=drd.xml",
            ]
        },
        "argv":{
            "exe":"./binary",
            "arg":[]
        }
    }
    "status":[
        {
            "state":"RUNNING",
            "time":"00:00:00:01.603"
        },
        {
            "state":"FINISHED",
            "time":"00:00:00:48.866"
        }
    ],
    "total_errors": 1,
    "error":[
        {
            "unique":"0x968"
            "tid":"5",
            "kind":"ConflictingAccess",
            "what":"Conflicting load by thread 5 at 0x12cddc28 size 1"
            "stack":[
                {
                    "frame":[
                        {
                            "ip":"0xED467F",
                            "obj":"/home/library/binary",
                            "fn":"check_thread",
                            "dir":"/home/library",
                            "file":"hello.cpp"
                            "line":"76",
                        },
                        {
                            "ip":"0xED4DF2",
                            "obj":"/home/library/binary",
                            "fn":"main()",
                            "dir":"/home/library",
                            "file":"hello.cpp"
                            "line":"130",
                        },
                    ]
                },
            ],
            "auxwhat":"Location 0x12cd1c28 is 0 bytes inside thread_data[1].valid,"
            "xauxwhat":{
                "text":"a global variable declared at hello_world.c:152"
                "file":"hello_world.c"
                "line":"152"
            }
            "other_segment_start":[
                {
                    "stack":[
                        {
                            "frame":[
                                {
                                    "ip":"0xED467F",
                                    "obj":"/usr/lib/valgrind/vgpreload_drd-amd64-linux.so",
                                    "fn":"pthread_rwlock_rdlock",
                                },
                                {
                                    "ip":"0xED4DF2",
                                    "obj":"/home/library/binary",
                                    "fn":"main",
                                    "dir":"/home/library",
                                    "file":"hello.cpp"
                                    "line":"245",
                                },
                            ]
                        },
                    ],
                },
                {
                    "stack":[
                        {
                            "frame":[
                                {
                                    "ip":"0xED467F",
                                    "obj":"/usr/lib/valgrind/vgpreload_drd-amd64-linux.so",
                                    "fn":"pthread_mutex_unlock",
                                },
                                {
                                    "ip":"0xED4DF2",
                                    "obj":"/home/library/binary",
                                    "fn":"__rwlock_rdlock",
                                    "dir":"/home/library",
                                    "file":"hello.cpp"
                                    "line":"534",
                                },
                                {
                                    "ip":"0xED4DF2",
                                    "obj":"/home/library/binary",
                                    "fn":"main",
                                    "dir":"/home/library",
                                    "file":"hello.cpp"
                                    "line":"130",
                                },
                            ]
                        },
                    ],
                }
            ],
            "other_segment_end":[
                {
                    "stack":[
                        {
                            "frame":[
                                {
                                    "ip":"0xED467F",
                                    "obj":"/usr/lib/valgrind/vgpreload_drd-amd64-linux.so",
                                    "fn":"pthread_rwlock_rdlock",
                                },
                                {
                                    "ip":"0xED4DF2",
                                    "obj":"/home/library/binary",
                                    "fn":"main",
                                    "dir":"/home/library",
                                    "file":"hello.cpp"
                                    "line":"245",
                                },
                            ]
                        },
                    ],
                },
                {
                    "stack":[
                        {
                            "frame":[
                                {
                                    "ip":"0xED467F",
                                    "obj":"/usr/lib/valgrind/vgpreload_drd-amd64-linux.so",
                                    "fn":"pthread_mutex_unlock",
                                },
                                {
                                    "ip":"0xED4DF2",
                                    "obj":"/home/library/binary",
                                    "fn":"__rwlock_rdlock",
                                    "dir":"/home/library",
                                    "file":"hello.cpp"
                                    "line":"534",
                                },
                                {
                                    "ip":"0xED4DF2",
                                    "obj":"/home/library/binary",
                                    "fn":"main",
                                    "dir":"/home/library",
                                    "file":"hello.cpp"
                                    "line":"130",
                                },
                            ]
                        },
                    ],
                }
            ],
}

Dependencies:

pip3 install flowbber[valgrind_drd]

Usage:

[[sources]]
type = "valgrind_drd"
id = "..."

    [sources.config]
    xmlpath = "drd.xml"
{
    "sources": [
        {
            "type": "valgrind_drd",
            "id": "...",
            "config": {
                "xmlpath": "drd.xml"
            }
        }
    ]
}

xmlpath

Path to Valgrind’s DRD XML output.

  • Default: N/A

  • Optional: False

  • Schema:

    {
        'type': 'string',
        'empty': False,
    }
    
  • Secret: False

Classes

class flowbber.plugins.sources.valgrind.drd.ValgrindDrdSource(index, type_, id_, optional=False, timeout=None, config=None)

Inheritance

Inheritance diagram of ValgrindDrdSource