GithubHelp home page GithubHelp logo

orbitcowboy / valgrind-log-parser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from siddheshsathe/valgrind-log-parser

0.0 2.0 0.0 139 KB

License: MIT License

C 2.45% Python 85.06% HTML 12.49%

valgrind-log-parser's Introduction

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 function as

>>> from valgrind_parser import generate_valgrind_report
>>> generate_valgrind_report('/path/to/valgrind_logs.txt', '/path/to/html_report.html')

This will dump the html report for input valgrind_logs.txt at the path provided or 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 [email protected]:<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

valgrind-log-parser's People

Contributors

siddheshsathe avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.