Re: Valgrind - used gdb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi John

--- John Love-Jensen <eljay@xxxxxxxxx> wrote:

> Hi Srivatsan,
> 
> > it again says that the error occured in the
> function.
> > parseString() (but no line number is shown :-( )
> 
> Isn't this...
> 
> > #0  ABCParser::parseString (this=0x344b86f0) at
> > stl_vector.h:501
> > #1  0x341bb8f3 in ABCParser::execute
> (this=0x344b86f0)
> > at ABCParser.cpp:97
> 
> ...in parseString?

parseString() is a function in my file ABCParser.cpp
parseString() is invoked by the execute() function in
the same file ABCParser.cpp.

however the vector stuff like you said is perhaps
inline code.....but still why should it not atleast
tell me what were the lines in parseString() before
the inlined vector code??



> 
> Remember, std::vector is a template, which means
> that it is instantiated,
> and many of its routines are inlined.  Maybe use the
> -fno-inline flag.
> 
> What happens when you step through the routine?
> 

dividing and conquering...I should try (I have not
used gdb before....I used to use the dumb way of
writing print statements to use divide and
conquer..... it did help...but i am not very happy
with that approach).

what does the -fno-inline flag do? should i include
this along with that db-attach flags?




> Divide and conquer the bugs.  Set breadcrumb
> breakpoints inching forward,
> such as "good to line 80"... "now good to line
> 86"... hmmm "broken between
> line 86 and line 105" (the bug gets triggered
> somewhere in there)... restart
> the app, get to line 86, single-step... blows up in
> line 92, set a break
> point at line 91... oops, there is no line 91 since
> that's a comment...
> breakpoint at line 90.  Restart.  Line 90, okay
> single-step and dive into
> subroutines.  Subroutine A is called, line 1000 of A
> is good, 1001, 1002,
> 1003, 1007 broken.  Hmm, bug triggers between 1003
> and 1007.  Restart.
> Breakpoint at 1003.  Continue.  Hits breakpoint 90. 
> Continue.  Hits
> breakpoint 1003.  Dive into sub-subroutine B. 
> Single-step.  Et cetera.
> 
> > it doesn't seem to say anything more....i know
> that
> > the invalid read is cause when a vector variable
> is
> > read beyond its boundary....but which one?? there
> are
> > so many vectors in my prog...and it is a one huge
> > function.
> 
> Sounds like your function is TOO huge.  Strive to
> make routines do "one unit
> of work".  If the cyclometric complexity of the
> routine is greater than, oh,
> 7 or so, it's likely doing too much.


yeah that is the whole problem....the function is too
huge...but it is NOT MINE :-), someone else had
written it (who isn't much familiar with programming
as he is more of an algo expert....), rewriting this
program into smaller chunks wud take more time...so it
is not an option as of now.....



> 
> And "too much" translates into "hard to understand,
> hard to maintain, hard
> to debug".
> 
> HTH,
> --Eljay


any further directions wud be really helpful.

thanks
vatsan.



> 


"MAN'S EGO IS THE FOUNTAINHEAD OF HUMAN PROGRESS"
                                          Ayn Rand.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux