From: David C. <dcc...@ac...> - 2020-06-17 17:47:21
|
(please don't top-post - it is harder to follow the conversation) On 6/17/2020 10:20 AM, Kunal Chauhan wrote: > > On 17 Jun 2020 13:50, "Paul FLOYD" <pj...@wa... > <mailto:pj...@wa...>> wrote: > > > Hi Team, > > > Q.As for a valgrind usage , is valgrind only checks the memory > leakage of code which hits only? > > > Q As for a can valgrind checks the all the code of binary > without hitting rhe scenerio. In code? > > Kunal > > Broadly speaking, there are two categories of software analysis tools. > > 1. Static analysis tools. For instance, clang analyzer. See > https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis > <https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis> > > > These tools parse all the code to produce some sort of model and > then do lots of 'what-if' analysis on all code paths. > Advantages: does not depend on your test coverage, can check for > very many kinds of errors. > Disadvantages: tools have to make tradeoffs between runtime and > really checking all possibilities. Also the models > are usually limited in scope which can cause false positives. > > 2. Dynamic analysis tools like Valgrind. Again wikipedia has a > page listing tools > https://en.wikipedia.org/wiki/Dynamic_program_analysis > <https://en.wikipedia.org/wiki/Dynamic_program_analysis> > > These tools test running code. > Advantages: lower rate of false positives. > Disadvantage. Only as good as your tests - you should be measuring > your code coverage! Performance - usually there is a large memory > and/or runtime overhead, which can make running > dynamic tools on large applications/data imprectical. > > A+ > Paul > > > _______________________________________________ > Valgrind-users mailing list > Val...@li... > <mailto:Val...@li...> > https://lists.sourceforge.net/lists/listinfo/valgrind-users > <https://lists.sourceforge.net/lists/listinfo/valgrind-users> > > > Hi Team, > > 1. Is valgrind use particular format, to show memory leaks like double > free in c code. > > 2. If we have multiple pointers and some sig abort happens in code, is > valgrind works for that part also.? > > Thnks > Kunal > 1. The memcheck tool within valgrind will report repeated calls to free(): https://www.valgrind.org/info/tools.html 2. valgrind/memcheck will report the state of memory when the program exits, whatever the reason. If the error handler in your code does not clean up all memory before the program exits, valgrind will generate a very long report of the memory still in use. Because abort() calls can occur anywhere in the code, many developers do not attempt to clean up everything - the code to do so can be very complex. Item 2 sounds very limiting, but if your program is crashing because of one or more invalid memory accesses, valgrind will report where that occurred. You can fix the access error(s), ignore the report of memory still in use, then rerun valgrind. This is a very powerful debugging method. -- David Chapman dcc...@ac... Chapman Consulting -- San Jose, CA EDA Software Developer, Expert Witness www.chapman-consulting-sj.com 2018-2019 Chair, IEEE Consultants' Network of Silicon Valley |