⛏️ index : haiku.git

author Jérôme Duval <jerome.duval@gmail.com> 2025-11-29 18:18:12.0 +01:00:00
committer Adrien Destugues <pulkomandy@pulkomandy.tk> 2025-11-30 7:56:05.0 +00:00:00
commit
c7c819c28f91d60f4e6510c141a0aa8f53b0bf07 [patch]
tree
4cf9b24430123f2c0aa0db8479dc3928f8efcaea
parent
49a702dd58581694c2e8999df2fa225dad0738c4
download
c7c819c28f91d60f4e6510c141a0aa8f53b0bf07.tar.gz

strace: send_signal and sigaction now use signal names

Change-Id: I5080da504899c96642bb4695eada2805fcffd773
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10036
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>

Diff

 src/bin/debug/strace/rlimit.cpp  |  3 ---
 src/bin/debug/strace/signals.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
 2 files changed, 50 insertions(+), 45 deletions(-)

diff --git a/src/bin/debug/strace/rlimit.cpp b/src/bin/debug/strace/rlimit.cpp
index fbffb8f..666b5a6 100644
--- a/src/bin/debug/strace/rlimit.cpp
+++ b/src/bin/debug/strace/rlimit.cpp
@@ -16,9 +16,6 @@
#include "TypeHandler.h"



static EnumTypeHandler::EnumMap kResourceNames;

struct enum_info {
	unsigned int index;
	const char *name;
diff --git a/src/bin/debug/strace/signals.cpp b/src/bin/debug/strace/signals.cpp
index 3a2165d..696d217 100644
--- a/src/bin/debug/strace/signals.cpp
+++ b/src/bin/debug/strace/signals.cpp
@@ -16,44 +16,6 @@
#include "TypeHandler.h"


// signal names
static const char *kSignalName[] = {
	/*  0 */ "SIG0",
	/*  1 */ "SIGHUP",
	/*  2 */ "SIGINT",
	/*  3 */ "SIGQUIT",
	/*  4 */ "SIGILL",
	/*  5 */ "SIGCHLD",
	/*  6 */ "SIGABRT",
	/*  7 */ "SIGPIPE",
	/*  8 */ "SIGFPE",
	/*  9 */ "SIGKILL",
	/* 10 */ "SIGSTOP",
	/* 11 */ "SIGSEGV",
	/* 12 */ "SIGCONT",
	/* 13 */ "SIGTSTP",
	/* 14 */ "SIGALRM",
	/* 15 */ "SIGTERM",
	/* 16 */ "SIGTTIN",
	/* 17 */ "SIGTTOU",
	/* 18 */ "SIGUSR1",
	/* 19 */ "SIGUSR2",
	/* 20 */ "SIGWINCH",
	/* 21 */ "SIGKILLTHR",
	/* 22 */ "SIGTRAP",
	/* 23 */ "SIGPOLL",
	/* 24 */ "SIGPROF",
	/* 25 */ "SIGSYS",
	/* 26 */ "SIGURG",
	/* 27 */ "SIGVTALRM",
	/* 28 */ "SIGXCPU",
	/* 29 */ "SIGXFSZ",
	/* 30 */ "SIGBUS",
	/* 31 */ "SIGRESERVED1",
	/* 32 */ "SIGRESERVED2",
};


struct enum_info {
	int index;
	const char *name;
@@ -61,7 +23,47 @@

#define ENUM_INFO_ENTRY(name) \
	{ name, #name }

static const enum_info kSignals[] = {
	{ 0, "SIG0"}, 					/* 0 */
	ENUM_INFO_ENTRY(SIGHUP),
	ENUM_INFO_ENTRY(SIGINT),
	ENUM_INFO_ENTRY(SIGQUIT),
	ENUM_INFO_ENTRY(SIGILL),
	ENUM_INFO_ENTRY(SIGCHLD),
	ENUM_INFO_ENTRY(SIGABRT),
	ENUM_INFO_ENTRY(SIGPIPE),
	ENUM_INFO_ENTRY(SIGFPE),
	ENUM_INFO_ENTRY(SIGKILL),
	ENUM_INFO_ENTRY(SIGSTOP),	/* 10 */
	ENUM_INFO_ENTRY(SIGSEGV),
	ENUM_INFO_ENTRY(SIGCONT),
	ENUM_INFO_ENTRY(SIGTSTP),
	ENUM_INFO_ENTRY(SIGALRM),
	ENUM_INFO_ENTRY(SIGTERM),
	ENUM_INFO_ENTRY(SIGTTIN),
	ENUM_INFO_ENTRY(SIGTTOU),
	ENUM_INFO_ENTRY(SIGUSR1),
	ENUM_INFO_ENTRY(SIGUSR2),
	ENUM_INFO_ENTRY(SIGWINCH),	/* 20 */
	ENUM_INFO_ENTRY(SIGKILLTHR),
	ENUM_INFO_ENTRY(SIGTRAP),
	ENUM_INFO_ENTRY(SIGPOLL),
	ENUM_INFO_ENTRY(SIGPROF),
	ENUM_INFO_ENTRY(SIGSYS),
	ENUM_INFO_ENTRY(SIGURG),
	ENUM_INFO_ENTRY(SIGVTALRM),
	ENUM_INFO_ENTRY(SIGXCPU),
	ENUM_INFO_ENTRY(SIGXFSZ),
	ENUM_INFO_ENTRY(SIGBUS),	/* 30 */
	ENUM_INFO_ENTRY(SIGRESERVED1),
	ENUM_INFO_ENTRY(SIGRESERVED2),
	{ 0, NULL }
};

static EnumTypeHandler::EnumMap kSignalsMap;


static const enum_info kSigmaskHow[] = {
	ENUM_INFO_ENTRY(SIG_BLOCK),
	ENUM_INFO_ENTRY(SIG_UNBLOCK),
@@ -118,8 +120,9 @@
std::string
signal_name(int signal)
{
	if (signal >= 0 && signal <= SIGRESERVED2)
		return kSignalName[signal];
	EnumTypeHandler::EnumMap::const_iterator i = kSignalsMap.find(signal);
	if (i != kSignalsMap.end() && i->second != NULL)
		return i->second;

	static char buffer[32];
	sprintf(buffer, "%d", signal);
@@ -329,9 +332,10 @@
{
	for (int i = 0; kSigmaskFlagsInfo[i].name != NULL; i++)
		kSigmaskFlags.push_back(kSigmaskFlagsInfo[i]);
	for (int i = 0; kSigmaskHow[i].name != NULL; i++) {
	for (int i = 0; kSigmaskHow[i].name != NULL; i++)
		kSigmaskHowMap[kSigmaskHow[i].index] = kSigmaskHow[i].name;
	}
	for (int i = 0; kSignals[i].name != NULL; i++)
		kSignalsMap[kSignals[i].index] = kSignals[i].name;
	Syscall *setSignalMask = get_syscall("_kern_set_signal_mask");
	setSignalMask->GetParameter("how")->SetHandler(new EnumTypeHandler(kSigmaskHowMap));
	setSignalMask->GetParameter("set")->SetHandler(new SigsetTypeHandler());
@@ -349,4 +353,8 @@
	sigpending->GetParameter("set")->SetHandler(new SigsetTypeHandler());
	sigpending->GetParameter("set")->SetOut(true);

	Syscall *sendSignal = get_syscall("_kern_send_signal");
	sendSignal->GetParameter("signal")->SetHandler(new EnumTypeHandler(kSignalsMap));
	Syscall *sigaction = get_syscall("_kern_sigaction");
	sigaction->GetParameter("sig")->SetHandler(new EnumTypeHandler(kSignalsMap));
}