aboutsummaryrefslogtreecommitdiff
path: root/tools/dtrace-tool.pl
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-05-17 02:16:48 +0200
committercrueter <crueter@eden-emu.dev>2026-05-17 02:16:48 +0200
commit8330940eca609a0ee4568c187dc0d463e23f2e3c (patch)
treecce4ef13539d234c20d63ff5f77c3bf4a26961e8 /tools/dtrace-tool.pl
parent4d49341918981a782395fe379a8e6846e1fd11b2 (diff)
[docs] add CodingStyle + Coding guidelines, HOS kernel basics, 'Settings' and add external resources, add better docs for dtrace-tool.pl (#3964)
Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3964 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'tools/dtrace-tool.pl')
-rwxr-xr-xtools/dtrace-tool.pl66
1 files changed, 29 insertions, 37 deletions
diff --git a/tools/dtrace-tool.pl b/tools/dtrace-tool.pl
index 2c4e7d6876..d143d36f3e 100755
--- a/tools/dtrace-tool.pl
+++ b/tools/dtrace-tool.pl
@@ -9,9 +9,11 @@ use warnings;
use POSIX qw(strftime);
my $input;
-my $sampling_hz = '4000';
-my $sampling_time = '5';
+my $sampling_hz = '997';
+my $sampling_time = '60';
my $sampling_pid = `pgrep eden`;
+chomp($sampling_pid);
+
my $sampling_program = 'eden';
my $sampling_type = 0;
@@ -39,43 +41,27 @@ sub dtrace_ask_params {
sub dtrace_probe_profiling {
if ($sampling_type eq 0) {
+ # profile both kernel stacks and user stacks
return "
-profile-".$sampling_hz." /pid == ".$sampling_pid." && arg0/ {
- @[stack(100)] = count();
-}
-profile-".$sampling_hz." /pid == ".$sampling_pid." && arg1/ {
- @[ustack(100)] = count();
-}
-tick-".$sampling_time."s {
- exit(0);
-}";
+profile-".$sampling_hz." /pid == ".$sampling_pid." && arg0/ { @[stack(100)] = count(); }
+profile-".$sampling_hz." /pid == ".$sampling_pid." && arg1/ { @[ustack(100)] = count(); }
+tick-".$sampling_time."s { exit(0); }";
} elsif ($sampling_type eq 1) {
+ # trace syscall entries
return "
-syscall:::entry /pid == ".$sampling_pid."/ {
- \@traces[ustack(100)] = count();
-}
-tick-".$sampling_time."s {
- exit(0);
-}";
+syscall:::entry /pid == ".$sampling_pid."/ { \@traces[ustack(100)] = count(); }
+tick-".$sampling_time."s { exit(0); }";
} elsif ($sampling_type eq 2) {
+ # profile both kernel and user stacks with thread names attached
return "
-profile-".$sampling_hz." /pid == ".$sampling_pid." && arg0/ {
- @[stringof(curthread->td_name), stack(100)] = count();
-}
-profile-".$sampling_hz." /pid == ".$sampling_pid." && arg1/ {
- @[stringof(curthread->td_name), ustack(100)] = count();
-}
-tick-".$sampling_time."s {
- exit(0);
-}";
+profile-".$sampling_hz." /pid == ".$sampling_pid." && arg0/ { @[stringof(curthread->td_name), stack(100)] = count(); }
+profile-".$sampling_hz." /pid == ".$sampling_pid." && arg1/ { @[stringof(curthread->td_name), ustack(100)] = count(); }
+tick-".$sampling_time."s { exit(0); }";
} elsif ($sampling_type eq 3) {
+ # trace I/O requests
return "
-io::start /pid == ".$sampling_pid."/ {
- @[ustack(100)] = count();
-}
-tick-".$sampling_time."s {
- exit(0);
-}";
+io::start /pid == ".$sampling_pid."/ { @[ustack(100)] = count(); }
+tick-".$sampling_time."s { exit(0); }";
} else {
die "idk";
}
@@ -111,11 +97,17 @@ sub dtrace_generate {
foreach my $i (0 .. $#ARGV) {
if ($ARGV[$i] eq '-h') {
- print "Usage: $0\n";
- printf "%-20s%s\n", "-p", "Prompt for parameters";
- printf "%-20s%s\n", "-g", "Generate dtrace output";
- printf "%-20s%s\n", "-s", "Continously generate output until Ctrl^C";
- printf "%-20s%s\n", "-<n>", "Select dtrace type";
+ print "
+Usage: $0\n
+-p Prompt for parameters\n
+-g Generate dtrace output\n
+-s Continously generate output until Ctrl^C\n
+-<n> Select dtrace type\n
+ 0: Profile kernel + user stacks (default)\n
+ 1: Trace syscall entries\n
+ 2: Profile kernel + user stacks with thread names\n
+ 3: Trace I/O requests\n
+";
} elsif ($ARGV[$i] eq '-g') {
dtrace_generate;
} elsif ($ARGV[$i] eq '-s') {