Make LLDB break even if the exit code is 0 - debugging

How do I make LLDB break when the program exits with 0?
The program exits with code 0 when the checksum doesn't match (I guess)
and I'm trying to find that checksum function.
I tried debugging it on Xcode too but still no luck.

Related

start bash with last exit code of 0

When I start a new bash shell, if I run the command echo $? as the first thing, I get 1. How can I run bash with the "default" exit code being 0?
Context: I am running msys2 in a terminal window in VS Code. If I start msys2, and then realize I didn't need a shell now and just type exit, bash exits with 1, causing VS Code to pop up an annoying warning.
Most likely something in your profile is failing and setting the status code to 1. Since status codes are overwritten by each process that runs, it'll probably be something towards the end.

Negate exit code in powershell

How do I negate the exit code of an executable in powershell? I would like my script to succeed if an executable terminated with a non-zero exit code, or fail if the executable terminated with a zero exit code.
I tried the following ! (...) and it prints True, which sounds promising, however it also makes the script fail with exit code 1.
! (program.exe) # I want this line to fail if program.exe returns 0
Output:
True
Error: Process completed with exit code 1.
Note that I'm just interested in checking the exit code of the executable. If the executable fails for other reasons (e.g. missing libraries) then it's fine for the script to fail.
This question has some similarities to this question for -nix systems. However, I'm writing a powershell script to be run on Windows 10.

lldb - How do I kill commands stuck in infinite loops

Simple question, but I can't seem to find the answer anywhere online and it's really frustrating.
Suppose I have this buggy code I'm trying to debug:
int myBug()
{
while(1);
return 0;
}
If I'm debugging this with LLDB and type print myBug() I get no result, ever (no surprises). However this means I can no longer debug because LLDB is stuck and cannot continue. Is there a way to kill the print myBug() command? So far the only workaround is quitting and restarting everything -- far from convient.
I'm using LLDB in Xcode 4.6.1 and I've trying a bunch of keystrokes like Ctrl+C, Ctrl+T, but nothing seems to work :(
Yeah, from within Xcode there isn't an easy way to interrupt this expression evaluation. If you're using command-line lldb, control-C will work as expected. You can send a signal to your process, killall -INT appname. You can give lldb a timeout for an expression evaluation, expressed in microseconds, so a five second timeout calling myBug() looks like
(lldb) expr -t 5000000 -- myBug()
error: Execution was interrupted, reason: breakpoint 1.1.
The process has been returned to the state before expression evaluation.
(lldb)
You can file a bug report about this on Xcode at http://bugreport.apple.com/ if this is something that comes up in your workflow.

How to write bash script to test if program crashes?

I have a program x which sometimes crashes on certain input files.
How do I write a bash script that returns the following?
0 if the program x terminates fine or runs for longer than 1/20th of a second
1 if the program x segfaults
Note that the program will segfault or run forever, so I need to stop it somehow with the script. can you show me please
Thank you for any ideas
Most of the programs when they do not terminate correctly return 0. That information can be gleaned from the bash variable $?. So, after you run the program, check if $? is 0. If it is, the program ran successfully. Otherwise, there was a problem.
This is, of course, assuming that the program is following proper conventions.
echo $? should let you know whether or not the program succeeded.
http://www.devshed.com/c/a/BrainDump/Executing-Commands-with-bash/1/

NSIS silent installer returning exit code 1

I compile an NSIS script to a .exe install file. I launch the .exe with command line \S silent option.
Installation performs silently as wanted, but there is exit code 1. Exit code 1 corresponds to case with user choosing cancel on the wizard. However, install is successful and mode is silent (no user interaction). Also, where does this exit code comes from, and how to manually enforce an exit code 0?
I have an idea i could do something in .onInstSuccess function, to enforce an exit code 1 if installation is successful.
Also, ExecWait is capturing the exit code into a variable, but has got no 'set' option.
What would you recommend?
Thanks and regards
Without any sample code it is a bit hard to guess what the problem could be!
You can set a specific exit code with SetErrorLevel.
As far as ExecWait goes, setting anything makes no sense, when it returns the child process has ended. If you want to use the exit code of a child process all you need is to get it:
ExecWait '"c:\foo.exe"' $0
SetErrorLevel $0

Resources