Be sure to watch the presenter Stefan Eggermont (StackOverflow, Twitter, LinkedIn, GitHub, FOSDEM, website www.legacycode.nl) as this kind of analysis (that is also possible for other languages and tools) can highly speedup your work.
Yes I did, and I was quoted in the (back then famous) FAQPAS3.TXT from (now Professor Emeritus) Timo Salmi: The third set of frequently (and not so frequently) asked Turbo Pascal questions with Timo’s answers. The items are in no particular order.
From ts@uwasa.fi Fri Nov 8 00:00:56 1996
Subject: Decompiling a TP .EXE
56.
Q: How can I reverse a TP .EXE or .TPU back into source code?
A: This is simply asking too much. You cannot decompile a TPprogram in a manner that would give you back the original source.This method of reverse engineering is not on in actual practice.
Quoting Jeroen Pluimers jeroenp@dragons.nest.nl
“During thecompilation, important information gets lost about variables,types, identifiers etc. Writing a Pascal Decompiler is impossible.The best you can achieve is a disassembler that can help yourecognize some Pascal statements.”
Since then I learned that compilers emit highly predictable CPU code that – with the right, and sometimes complex, algorithms – can be reconstructed into language structures.
Of course you are missing the identifiers and comments, but you can some remarkable info, especially with well structured code.
Reminder to self: some great ideas to hunt for memory leaks while your application is running: differencing allocation dumps, DDDebug Memory Profiler, etc.
Even in unsuspiciously looking code, the wit statement can bite you, especially if you need to do refactoring and (because of that) introduce two names in the same scope.
Whilst upgrading the code to remove the Containers unit (its not supported on NextGen platforms, so I have to make things work with Generics.Collections instead, (bye bye D7 support for this code) and refactor a couple stupidities in my original design (they always creep in, don’t they) I ended up with two class members of the same name. The with block then looked OK but I was in fact not access the member I thought I was.
About the REST support in Delphi: make sure you take a look at the REST Debugger application, as you get full source code for it and is an excellent starting point to see how the REST components work together (it is written using the FireMonkey UI framework so it runs on a Mac as well as on Windows).
Every once in a while you have multiple threads or processes wanting to write a short message to the same log file. Append then will give you an I/O error 32 (ERROR_SHARING_VIOLATION), but the below small routine will sleep a bit while retrying a couple of times.
in $I- mode, you access the IOResult to obtain the results of those I/O operations
IOResult gets the result of the last failed operation (if any) or zero if none failed
IOResult clears the underlying storage to zero
$IFOPT checks for a certain state of a compiler flag
You can store the state of $OPT in a temporary conditional define
Note there are a few tables of codes you can get back through IOResult as basically you can get many GetLastError results in IOResult as well: Read the rest of this entry »