Re: Seems to be related to the debugger..



"Fredrik Wahlgren" <fredrik.p.wahlgren@xxxxxxxxxxxxxxxxxx> wrote in
message news:OBQ4G91LGHA.2300@xxxxxxxxxxxxxxxxxxxx
I now found that if I use "Start Without Debugging", everything works
OK. I only get garbage when I use "Start Debugging". I use VS2005
version 8.0.50727.42 I guess it's a MS bug. Weird!

Is sSum declared as wstring, by any chance? Are you seeing "garbage"
when watching it in debugger, but it's fine when you, say, print it or
otherwise manipulate programmatically?

If both are true, this is a known problem. std::string and wstring
implement small string optimization, where short strings are stored
directly within the instance of the class but longer strings are
allocated on the heap and a pointer is stored in the instance. This
greatly confuses the debugger - it shows the longer strings correctly,
but when the short string is stored internally, deugger basically
interpets first four bytes of the string as though they formed a pointer
and shows you the random garbage this "pointer" is pointing to. The
string is still fine, you just can't see its contents while debugging.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Seems to be related to the debugger..
    ... I only get garbage when I use "Start Debugging". ... Is sSum declared as wstring, ... string is stored internally, deugger basically interpets first four bytes ...
    (microsoft.public.vc.atl)
  • Seems to be related to the debugger..
    ... I now found that if I use "Start Without Debugging", ... The result should be the string "0,6". ... All I get is garbage unless I ... nothing to do with it - it is the artifact of #import-generated wrappers. ...
    (microsoft.public.vc.atl)
  • Re: Thread exiting with code 1282 (0x502)
    ... the application exits when I display a dialog that contains text boxes with some large strings. ... I start debugging with VS2005, interact with the application so that it displays a properties dialog for one of the graphics objects we have, then I click on a button that displays another dialog with four Combo Boxes. ... 3.- I get to the Combo Box again and I enter the new long string and this time I quickly press "OK" and save the object. ... Please let me know if the implementation of OnToolTipNotify() should be different. ...
    (microsoft.public.vc.mfc)
  • Re: Comments on Comments (was Re: Getting to 100 (#119))
    ... Computer Programming," comments can actually impede debugging. ... # yield each partitioning of the receiver into count partitions ... # an initial substring of increasing length, ... # the string into count-1 partitions. ...
    (comp.lang.ruby)
  • Re: About VS C++
    ... I like is that every object can be simply converted to a string and therefore simply printed - big plus for debugging. ... I base most of my objects on the TtiObject class which includes handy features such as the Visitor and Iterator design pattern. ... I can also do things like MyObject.AsDebugString which then outputs the objects to a string, including a few other handy things like the ObjectState. ... I searched about such information on the FPC site, but haven't found anything about generics. ...
    (borland.public.delphi.non-technical)