News for hackers. Stuff that matters.
Re:Two handy GDB breakpoint tricks by buserror on Monday January 29, 2024 @04:06AM (#39174273)
well you can always while (1) {} -- run the program, and control-C when you hear the CPU fan :-)
Re:Two handy GDB breakpoint tricks by _flux on Monday January 29, 2024 @04:25AM (#39174389)
Just

  catch infinite-loop
in gdb and you're done!
Re:Two handy GDB breakpoint tricks by speps on Monday January 29, 2024 @10:10AM (#39177111)
Would anyone know how that works internally? Sounds very useful
Re:Two handy GDB breakpoint tricks by _flux on Monday January 29, 2024 @02:13PM (#39180970)
Sadly it does not work at all, as it was a joke :/.

But I did think about how it could work. It could work by peridically sampling the instructions the current thread is running and detect trivial infinite loops that way.

With more effort more complicated infinite loops could be detected, but in the end not all, due to the halting problem.

edit: Actually maybe halting problem is not (theoretically) involved if you have a lot of memory: take snapshots every after every instruction. Once you take a snapshot you have already taken previously, you have found a loop. However you would still might need to somehow account for (emulate and include in snapshot?) or disallow external IO, such as time of day.

Re:Two handy GDB breakpoint tricks by IshKebab on Monday January 29, 2024 @05:19PM (#39183540)
QuakeC automatically detected "infinite" loops (actually >100k loops). It was very useful!