beasone
beasone

Reputation: 1085

Valgrind's debugging result doesn't show me the num of rows where the error happens

this is Valgrind debugging result:

 valgrind --leak-check=yes --track-origins=yes  ./ns-server 
==43648== Memcheck, a memory error detector
==43648== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==43648== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==43648== Command: ./ns-server
==43648== 
--43648-- ./ns-server:
--43648-- dSYM directory is missing; consider using --dsymutil=yes
111111111111222222222222first get nextlen 564
nextlen is 564
i am here decry
==43648== Thread 2:
==43648== Invalid read of size 1
==43648==    at 0x6C49: strlen (vg_replace_strmem.c:427)
==43648==    by 0x100133F4F: StringBuffer::setString(char const*) (in     ./ns-server)
==43648==    by 0x100158B2F: XString::setFromAnsi(char const*) (in ./ns-server)
==43648==    by 0x100024476: CkRsa::DecryptStringENC(char const*, bool, CkString&) (in ./ns-server)
==43648==    by 0x10002452A: CkRsa::decryptStringENC(char const*, bool) (in ./ns-server)
==43648==    by 0x10001222A: My_RSA::MyDecryption(char*) (in ./ns-server)
==43648==    by 0x1000013FA: Server::Register(char*, int, char*) (in ./ns-server)
==43648==    by 0x100001114: Server::Evaluate_MSG(void*) (in ./ns-server)
==43648==    by 0x409898: _pthread_body (in /usr/lib/system/libsystem_pthread.dylib)
==43648==    by 0x409729: _pthread_start (in /usr/lib/system/libsystem_pthread.dylib)
==43648==    by 0x40DFC8: thread_start (in /usr/lib/system/libsystem_pthread.dylib)
==43648==  Address 0x100476730 is 0 bytes after a block of size 128 alloc'd
==43648==    at 0x47E1: malloc (vg_replace_malloc.c:300)
==43648==    by 0x100001334: Server::Register(char*, int, char*) (in ./ns-server)
==43648==    by 0x100001114: Server::Evaluate_MSG(void*) (in ./ns-server)
==43648==    by 0x409898: _pthread_body (in /usr/lib/system/libsystem_pthread.dylib)
==43648==    by 0x409729: _pthread_start (in /usr/lib/system/libsystem_pthread.dylib)
==43648==    by 0x40DFC8: thread_start (in /usr/lib/system/libsystem_pthread.dylib)
==43648== 

This result just tells me the error happens in which file, but doesn't tell me its line num,its exact location. My files contain thousands of lines of code, how can I set the option for Valgrind so that I can get the exact num of lines the error happens?

My makefile:

LIBS = libStatic/libchilkat_i386.a libStatic/libchilkat_x86_64.a -lpthread
GPP = g++
TARGET = -o ns-server
CPP = main.cpp Server.cpp TCPConnect.cpp RSAsample.cpp

all:
    $(GPP) $(TARGET) $(CPP) $(LIBS)
clean:
    rm ns-server

Upvotes: 0

Views: 106

Answers (1)

Sourav Ghosh
Sourav Ghosh

Reputation: 134386

Without having the debug symbols in your binary, valgrind won't be able to display the filename and line number information. To put the debug information into the binary, you need to add -g option with gcc in your compilation statement.

Please refer to the online valgrind manual for more details.

Upvotes: 1

Related Questions