The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,819 other followers

Archive for the ‘Debugging’ Category

Drawbacks for separating TDS/TD32 symbol information in separate file for your Delphi applications? What about Visual Studio?

Posted by jpluimers on 2020/01/15

A while ago this interesting question came by: [WayBack] Delphi XE2 has got the Linking option “Place debug information in separate TDS file” … Does this have any adverse effects for Win32 Delphi executables? – Thomas Mueller (dummzeuch) – Google+

The answer is “no”.

By about mid 2018, the same holds for Visual Studio and PDB symbol information.

Delphi

Since long ago (I think about Delphi 2), the Delphi debugger understands TDS (historically also known as TD32) Turbo Debugger Symbol Information which can be either in the .EXE or in a separate .TDS file with the same name and directory as the .EXE.

Many other tools also know how to get the symbols from either place, see for instance TD32-TDS-SYMBOL-INFORMATION.

The advantage of keeping it in the EXE is that it is easier to ship to clients. Unless you do not want the clients to have it. Then it is easier to separate it in a file.

David Heffernan raises an important point though, as many people confuse these two topics:

  • the presence of Debug Symbols
  • the code generation of extra run-time checks and debug-assistance (like stack frames)

This is caused by both of the above usually being enabled in DEBUG mode and disabled in RELEASE mode.

However, nothing prevents you from generating the Debug Symbols in RELEASE mode, and they can highly help track down customer problems.

This is David’s comment:

There’s a common myth that “debug builds” perform worse than “release builds”.

Whether or not debug information is generated is completely independent from the performance of the code.

Visual Studio

For a long time, EXE files generated by Microsoft Tools could only include .DBG symbol information, but no .PDB symbol information.

[WayBack] executable – Embed .pdb debug symbol information into an .exe file in Visual Studio – Stack Overflow. Especially read the comments about:

–jeroen

Posted in Debugging, Delphi, Development, MAP Symbol Information, Software Development, TD32/TDS Symbol information | Leave a Comment »

Sasha Laundy on Twitter: “The best debugger ever made is a good night’s sleep.”

Posted by jpluimers on 2019/12/26

Very similar to “you get the best ideas while sleeping“:

[WayBack/Archive.isSasha Laundy on Twitter: “The best debugger ever made is a good night’s sleep.”

Via: [WayBack] So true it hurts – CodeProject – Google+

For me, taking a shower and contemplating during a commute are good debuggers too. But sleeping is still the best.

Hope you enjoyed Christmas, good luck on your debugging ventures!

–jeroen

Posted in Debugging, Development, Fun, Quotes, Software Development | Leave a Comment »

How to debug small programs

Posted by jpluimers on 2019/10/17

As a follow up of SSCCE, MWE and MCVE are basically the same: provide code people can use to reproduce a problem, I found [WayBackHow to debug small programs which is starts as

One of the most frequent categories of bad questions I see on StackOverflow is: I wrote this program for my assignment and it doesn’t work. [20 lines of code]. And… that’s it.

Then it goes on how to debug those pieces of code, trim them into an SSCCE/MWE/MCVW to form the base of a question which you can ask on StackOverflow/SuperUser/ServerFault/StackExchange, forum, group/community or even your co-worker.

The really cool thing about the techniques used there are that they also apply to bigger pieces of code, heck even large code bases.

They force you to trim down your problem in to manageable pieces that are easy to explain and write concise documentation and tests around them to assist you in the process.

Below are the steps in a short list. Be sure to read the original article How to debug small programs | Fabulous adventures in coding after going through the list.

  1. Turn on compiler warnings, inspect all of them, resolve or explain them
  2. Rubber duck to an imaginary person or even a live one explaining each part in simple terms
  3. If the bug is still there, break up the code into pieces
  4. Write technical specifications for all the pieces
  5. Verify the pieces against the specifications, for instance by adding pre- and postconditions to them
  6. Add assertions in the pieces for all the specifications
  7. Write test cases for the pieces
  8. Write down on paper the expected behaviour for all the lines of code
  9. Use a debugger to step through all the lines of code and verify the expected behaviour you wrote down
  10. While debugging, listen to all your doubts (gut feeling is a good thing!)

This sounds like a lot of work. It is. All good programming is.

If you apply these before writing any logic code, then your life becomes easier because you will spot bugs sooner:

  • specification
  • test cases
  • preconditions
  • postconditions
  • assertions

Does this again sound like a lot of work?

Then remember: taking a shortcut will make the actual work longer. The reason is that hunting for bugs is a tedious and time consuming process scaling very badly with complexity.

–jeroen

Posted in Conference Topics, Conferences, Debugging, Development, Event, Software Development | Leave a Comment »

It’s a blong, blong, blong road…: ‘What if?’ scenario analysis in the CPU window

Posted by jpluimers on 2019/07/31

Patching code at debug-time: [WayBackIt’s a blong, blong, blong road…: ‘What if?’ scenario analysis in the CPU window.

Remember:

  • There are dragons
  • Patching too many bytes will kill a kitten and likely your application.
  • Bytes in memory might not be what they seem, especially when having breakpoints (and the debugger frantically trying to set/remove $CC bytes for the INT 3 instruction)

I’ve done this for 20+ years and usually use the $90 byte (NOP instruction) though your experience may be different.

–jeroen

 

Posted in Debugging, Delphi, Development, Pascal, Software Development, Turbo Pascal | Leave a Comment »

Laptop fan profiling, and debugging them – related to Profiling | CommitStrip

Posted by jpluimers on 2019/07/23

A while back, I posted the “profiling” CommitStrip on[WayBack] Profiling – Jeroen Wiert Pluimers – Google+. Boy how did I not know that within a week, I bumped into a “laptop fan profiling” artefact.

A coworker noticed, that when starting a thread based equivalent of [WayBack] TTimer Class (which cannot be used in services as it depends on the VCL), then sometimes the laptop fans would spin up.

What basically happened was that for certain combinations of Enabled and Interval the Execute would loop burning 100% of one CPU core.

With 3 or more – sometimes 2 – of these threads active on a 4+4 core (4 are hyper-threaded), the processor fan would start to spin like madness.

Finding the solution was somewhat easy too:

  • Process Explorer would show the thread IDs burning the most CPU cycles
  • Delphi shows the Thread IDs in the Thread Status pane (if they are named, the ID is at the end of the name in parenthesis)
  • At around Delphi 2010, you can Freeze or Thaw threads. This allows you to debug only a single thread by freezing all others.

Focussing on one thread, allowed a close inspection of the loop, quickly finding the actual cause and repairing it.

TTimer Thread

A similar and better class is at [WayBack] multithreading – TTimerThread – Threaded timer class – Code Review Stack Exchange, based on [WayBack] timer – Using VCL TTimer in Delphi console application – Stack Overflow.

Read the rest of this entry »

Posted in Conference Topics, Conferences, Debugging, Delphi, Development, Event, Fun, Multi-Threading / Concurrency, Profiling-Performance-Measurement, Software Development | Leave a Comment »

 
%d bloggers like this: