Skip to main content

valparse, a parser for Valgrind-generated XML files

PyPI License GitHub issues Build Status codecov Docs

valparse supports protocol version 4 with Memcheck only, but can be easily modified to support Helgrind and other protocol tools.

Installation

valparse can be insalled by running

pip install valparse

Anaconda hosting may be added in the future.

About Valgrind .xml files

By default, Valgrind output is printed to stderr. While readable, Valgrind's unmodified output is not very easily parsable. However, output can be generated in the form of XML code and redirected to a .xml file by running Valgrind with the following options:

valgrind --leak-check=full --xml=yes --xml-file=<xml-file-name> ./<executable> <args>

Some examples of .xml files generated by Valgrind are included in the /examples directory.

Valgrind does not support XML output for fd leaks as of version 3.18.1.

Usage

Below is an example of basic valparse usage:

import valparse

xml_file = valparse.Parser('./test.xml')
if xml_file.hasLeaks() or xml_file.hasErrors():
    print("Leaks or errors found!")

Features

  • Error generation for nonexistent/incorrectly formatted TOPLEVEL tags

  • Error generation for nonexistent/incorrectly formatted PROTOCOL tags

  • Basic Valgrind output parsing

    • Check for existence of errors or leaks
  • Check for fatal signal

    • Count errors and leaks (if applicable)

    • Error and leak parsing (if applicable)

    • Fatal signal parsing (if applicable)

  • Optional user-friendly .supp file generation

TOPLEVEL tags

valparse checks for the existence and correct formatting of the following TOPLEVEL tags:

  • protocolversion (4)

  • protocoltool (memcheck)

PROTOCOL tags

valparse checks for the existence and correct formatting of the following PROTOCOL tags:

  • preamble

  • pid

  • ppid

  • tool

  • args

  • status

  • suppcounts

Note: Valgrind supplies an 'errorcounts' tag, but it seems largely unreliable. We've decided to generate this information manually.

Basic Valgrind output parsing

The primary function of valparse is to generate usable content from Valgrind output. valparse was created with our grading scripts in mind, so it counts the number of errors, leaks, unique errors, unique leaks, and total bytes leaked. valparse also checks for the presence of a fatal signal.

.supp file generation

Within each <suppression> tag, Valgrind supplies a <rawtext> tag that can be used to make .supp files, but it's cryptic and requires direct editing. We've assembled this information manually to make it more user-friendly, customizable, and generally better. valparse supports the dynamic generation of .supp files, which can be utilised when running Valgrind to suppress certain leaks or errors. Files can be generated in write (default) or append mode, and users can specify suppression names as well as .supp file names.

Metadata

Release files for valparse 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for valparse 0.2.1
File Size Uploaded
valparse-0.2.1.tar.gz 16.1 kB Details

Release files / valparse-0.2.1.tar.gz

Download URL valparse-0.2.1.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
39d8466d43e931e67bde0dfd57809c2b4c6edb4d8fedaca03813b132c45822c8
BLAKE2b-256 checksum
How to use checksums
ceac668580f34e2759d741e9f749a673c8099b137919862305db8f0631116012
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.2.1 This release

1 release file

0.2.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page