Skip to main content

The valgrind logs parser. Creates the html report from txt logs.

Project description

Build Status

Valgrind Parser Tool


This tool helps to parse the valgrind logs generated by a valgrind tool.

Pre-requisites

The only package needed for successful run of valgrind_log_parser.py is mentioned in requirements.txt.
Use pip to install these requirements.

pip install -r requriements.txt

Pip install

One can install valgrind parser tool from pip as well.

pip install valgrind_parser

Import the package as

>>> from valgrind_parser import ValgrindLogParser
>>> vlp = ValgrindLogParser('/path/to/valgrind_logs.txt')
>>> vlp.generate_html_report()

This will dump the html report for input valgrind_logs.txt in the same directory from where the program was called.

Cloning the repo

Valgrind-Log-Parser can also be used by cloning the repo locally and using the python file directly. Clone the repo with below command and use as given in next sections.

git clone git@github.com:<your username>/Valgrind-Log-Parser.git

How to use

Under test_leaker directory, test_leaker.c file is present. This file is having a memory leak and a condition check with a variable which is not initialized before.
When run with valgrind, the valgrind report should highlight these two things.

#include<stdio.h>
#include<stdlib.h>

int main(){
    int *memory_allocation_var = malloc(1000); // Leaked memory which is never freed
    int conditional_jump_variable_without_initialize;
    if (conditional_jump_variable_without_initialize > 0){ // Variable used without initialization
        printf("Variable not initialized still using here \n");
    }
    return 0;
}

Compile C file

To compile c file on Linux environment, one must use gcc with -g option which enables debug symbols from the binary.

gcc -g test_leaker.c -o test_leaker

Post successful compilation, install valgrind from its official source mentioned at valgrind_website and execute with our test_leaker binary.

valgrind -v --leak-check=full --show-reachable=yes --log-file=valgrind_log.txt ./test_leaker

This will dump the valgrind logs in valgrind_log.txt

Using valgrind_log_parser.py

The --help argument can help to understand how to use this parser.

python valgrind_log_parser.py --help
usage: valgrind_log_parser.py [-h] --valgrind_file VALGRIND_FILE

optional arguments:
  -h, --help            show this help message and exit
  --valgrind_file VALGRIND_FILE
                        Provide the path of the valgrind file. Files must be
                        of .txt format

Provide valgrind_log.txt file in argument to valgrind_log_parser.py and it will create a HTML report out of it in the same directory.

python valgrind_log_parser.py --valgrind_file <path to valgrind_log.txt file>

Following table will be generated with the above run. Valgrind HTML Report

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

valgrind_parser-2.0.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

valgrind_parser-2.0.3-py2-none-any.whl (7.9 kB view details)

Uploaded Python 2

File details

Details for the file valgrind_parser-2.0.3.tar.gz.

File metadata

  • Download URL: valgrind_parser-2.0.3.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.12

File hashes

Hashes for valgrind_parser-2.0.3.tar.gz
Algorithm Hash digest
SHA256 ce06855da2eb06d5395f86307998299e7864a901bf6a7ebb958c4c9590fbec83
MD5 970e87ddaaa6e76dd3dda375456be7ce
BLAKE2b-256 5dbb137cbade5244b8db8facb2c037fd5710ad30bbaafe2ea53a73909f494527

See more details on using hashes here.

File details

Details for the file valgrind_parser-2.0.3-py2-none-any.whl.

File metadata

  • Download URL: valgrind_parser-2.0.3-py2-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.12

File hashes

Hashes for valgrind_parser-2.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 a5b0b158b76f2691e9afe5a2141a3d359437bcec5386e40e4d3b4bf5a0967a42
MD5 492e7e9bb6e57e8d280fb9040d90b507
BLAKE2b-256 fe71dabfca9315cb2381ec13ec08d90433ca3c321fe4fa2ff52d6c1b067da954

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page