Recent

Author Topic: Weird thing happens. Str:='Const'+Str; spoils other data  (Read 8735 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Weird thing happens. Str:='Const'+Str; spoils other data
« Reply #15 on: March 31, 2015, 08:10:03 pm »
I would use a *hardware* breakpoint at one of the addresses that get corrupted.

That is what I referred to as "watchpoint"

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Weird thing happens. Str:='Const'+Str; spoils other data
« Reply #16 on: March 31, 2015, 08:24:13 pm »
I would use a *hardware* breakpoint at one of the addresses that get corrupted.

That is what I referred to as "watchpoint"

Ahh! I was not aware that these "watchpoints" are actually hardware breakpoints. Thanks.

mm7

  • Full Member
  • ***
  • Posts: 193
  • PDP-11 RSX Pascal, Turbo Pascal, Delphi, Lazarus
Re: Weird thing happens. Str:='Const'+Str; spoils other data
« Reply #17 on: March 31, 2015, 09:08:23 pm »
I understood that watchpoint watches for access, like read/write, not for deallocation.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Weird thing happens. Str:='Const'+Str; spoils other data
« Reply #18 on: March 31, 2015, 09:21:25 pm »
I understood that watchpoint watches for access, like read/write, not for deallocation.
Right, but when you use -gh (heaptrc) the memory is filled with trash on dealloc. So it will trigger.

Of course it will trigger many many more times before. That is why you do not stop (break) each time. You only take a snapshot. That gets you a stack (with 5 frames, or if the stack window is open, with 10 frames). The snapshot is stored, and the app continues to run.

When you hit the error, you can go through the snapshots (from the bottom upwards).

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Weird thing happens. Str:='Const'+Str; spoils other data
« Reply #19 on: March 31, 2015, 09:26:50 pm »
Ahh! I was not aware that these "watchpoints" are actually hardware breakpoints. Thanks.

Well to be exact: they are hardware breakpoint if your architecture supports this. Otherwise they may either fail to be set (the IDE will indicate this), or gdb may silently convert them into a none hardware watchpoint. The latter is very slow, it effectively means gdb single steps the app and checks on every step.

The gdb command is: -break-watch

For more on this, please start a new topic, as it is off topic to the OT

mm7

  • Full Member
  • ***
  • Posts: 193
  • PDP-11 RSX Pascal, Turbo Pascal, Delphi, Lazarus
Re: Weird thing happens. Str:='Const'+Str; spoils other data
« Reply #20 on: April 01, 2015, 01:50:32 am »
Thank you guys.
I've found the issue by setting breakpoint into destructor.
The object was destroyed in cycle of processing of its own sub-objects.  %)
Yes it should be destroyed because it should be split to other two.
But, I think, destruction should be done later. I need to think through the logic...

Thank you all!

 

TinyPortal © 2005-2018