trace-cmd: Remove all die()s from trace-cmd library

The die() call is used for a fatal error. It terminates the current
program with exit(). The program should not be terminated from a library
routine, the die() call should not be used in the trace-cmd library
context.

But as all these logs indicate a fatal error in the library, it is
useful to have them. The die() call is replaced with tracecmd_lib_fatal()
library function, which prints the error message. By default,
the application is not terminated when a fatal error is encountered in
the library. If the library runs in debug mode, the _lib_fatal() call
behaves like die() - calls exit() to terminate the application.
The library debug mode can be switched using tracecmd_set_debug() API.

The tracecmd_lib_fatal() function is defined as weak and can be
overridden by the application.

Link: https://lore.kernel.org/linux-trace-devel/20210405092100.869572-1-tz.stoyanov@gmail.com

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
3 files changed