-
Notifications
You must be signed in to change notification settings - Fork 5.1k
SunOS process and thread support #105403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gwr
wants to merge
10
commits into
dotnet:main
Choose a base branch
from
gwr:illumos5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+948
−115
Open
SunOS process and thread support #105403
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3eb1120
Workaround gh-116929
am11 0e7fc39
Fix compile error at minipal/debugger.c:127
gwr 5a2484a
Fix compile error in minipal/thread.h
gwr c9f8c2b
Fix compile error in oreclr/pal/src/thread/thread.cpp
gwr 0ddaca6
Fix compile error in native/libs/System.Native/pal_mount.c
gwr 93ed1b0
Fix compile error in coreclr/vm/appdomain.hpp
gwr 60cf29e
Fix compile error in coreclr/runtime/amd64/AllocFast.S
gwr ce219ee
Add HAVE_DIRENT_D_TYPE introspection
am11 5700685
Fix compile errors in coreclr/tools/superpmi/mcs/verbmerge.cpp
gwr 1fbc54b
SunOS process and thread support
gwr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#ifndef __CONFIG_H__ | ||
#define __CONFIG_H__ | ||
|
||
#cmakedefine01 HAVE_DIRENT_D_TYPE | ||
|
||
#endif // __CONFIG_H__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include(CheckStructHasMember) | ||
|
||
check_struct_has_member ("struct dirent" d_type dirent.h HAVE_DIRENT_D_TYPE) | ||
|
||
configure_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in | ||
${CMAKE_CURRENT_BINARY_DIR}/config.h) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.Definitions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
// C# equivalents for <sys/procfs.h> structures. See: struct lwpsinfo, struct psinfo. | ||
// We read directly onto these from procfs, so the layouts and sizes of these structures | ||
// must _exactly_ match those in <sys/procfs.h> | ||
|
||
// analyzer incorrectly flags fixed buffer length const | ||
// (https://github.com/dotnet/roslyn/issues/37593) | ||
#pragma warning disable CA1823 | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class @procfs | ||
{ | ||
internal const string RootPath = "/proc/"; | ||
private const string psinfoFileName = "/psinfo"; | ||
private const string lwpDirName = "/lwp"; | ||
private const string lwpsinfoFileName = "/lwpsinfo"; | ||
|
||
// Constants from sys/procfs.h | ||
private const int PRARGSZ = 80; | ||
private const int PRCLSZ = 8; | ||
private const int PRFNSZ = 16; | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal struct @timestruc_t | ||
{ | ||
public long tv_sec; | ||
public long tv_nsec; | ||
} | ||
|
||
// lwp ps(1) information file. /proc/<pid>/lwp/<lwpid>/lwpsinfo | ||
// Equivalent to sys/procfs.h struct lwpsinfo | ||
// "unsafe" because it has fixed sized arrays. | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal unsafe struct @lwpsinfo | ||
{ | ||
private int pr_flag; /* lwp flags (DEPRECATED; do not use) */ | ||
public uint pr_lwpid; /* lwp id */ | ||
private long pr_addr; /* internal address of lwp */ | ||
private long pr_wchan; /* wait addr for sleeping lwp */ | ||
public byte pr_stype; /* synchronization event type */ | ||
public byte pr_state; /* numeric lwp state */ | ||
public byte pr_sname; /* printable character for pr_state */ | ||
public byte pr_nice; /* nice for cpu usage */ | ||
private short pr_syscall; /* system call number (if in syscall) */ | ||
private byte pr_oldpri; /* pre-SVR4, low value is high priority */ | ||
private byte pr_cpu; /* pre-SVR4, cpu usage for scheduling */ | ||
public int pr_pri; /* priority, high value is high priority */ | ||
private ushort pr_pctcpu; /* fixed pt. % of recent cpu time */ | ||
private ushort pr_pad; | ||
public timestruc_t pr_start; /* lwp start time, from the epoch */ | ||
public timestruc_t pr_time; /* usr+sys cpu time for this lwp */ | ||
private fixed byte pr_clname[PRCLSZ]; /* scheduling class name */ | ||
private fixed byte pr_name[PRFNSZ]; /* name of system lwp */ | ||
private int pr_onpro; /* processor which last ran this lwp */ | ||
private int pr_bindpro; /* processor to which lwp is bound */ | ||
private int pr_bindpset; /* processor set to which lwp is bound */ | ||
private int pr_lgrp; /* lwp home lgroup */ | ||
private fixed int pr_filler[4]; /* reserved for future use */ | ||
} | ||
private const int PR_LWPSINFO_SIZE = 128; // for debug assertions | ||
|
||
// process ps(1) information file. /proc/<pid>/psinfo | ||
// Equivalent to sys/procfs.h struct psinfo | ||
// "unsafe" because it has fixed sized arrays. | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal unsafe struct @psinfo | ||
{ | ||
private int pr_flag; /* process flags (DEPRECATED; do not use) */ | ||
public int pr_nlwp; /* number of active lwps in the process */ | ||
public int pr_pid; /* unique process id */ | ||
public int pr_ppid; /* process id of parent */ | ||
public int pr_pgid; /* pid of process group leader */ | ||
public int pr_sid; /* session id */ | ||
public uint pr_uid; /* real user id */ | ||
public uint pr_euid; /* effective user id */ | ||
public uint pr_gid; /* real group id */ | ||
public uint pr_egid; /* effective group id */ | ||
private long pr_addr; /* address of process */ | ||
public ulong pr_size; /* size of process image in Kbytes */ | ||
public ulong pr_rssize; /* resident set size in Kbytes */ | ||
private ulong pr_pad1; | ||
private ulong pr_ttydev; /* controlling tty device (or PRNODEV) */ | ||
private ushort pr_pctcpu; /* % of recent cpu time used by all lwps */ | ||
private ushort pr_pctmem; /* % of system memory used by process */ | ||
public timestruc_t pr_start; /* process start time, from the epoch */ | ||
public timestruc_t pr_time; /* usr+sys cpu time for this process */ | ||
public timestruc_t pr_ctime; /* usr+sys cpu time for reaped children */ | ||
public fixed byte pr_fname[PRFNSZ]; /* name of execed file */ | ||
public fixed byte pr_psargs[PRARGSZ]; /* initial characters of arg list */ | ||
public int pr_wstat; /* if zombie, the wait() status */ | ||
public int pr_argc; /* initial argument count */ | ||
private long pr_argv; /* address of initial argument vector */ | ||
private long pr_envp; /* address of initial environment vector */ | ||
private byte pr_dmodel; /* data model of the process */ | ||
private fixed byte pr_pad2[3]; | ||
public int pr_taskid; /* task id */ | ||
public int pr_projid; /* project id */ | ||
public int pr_nzomb; /* number of zombie lwps in the process */ | ||
public int pr_poolid; /* pool id */ | ||
public int pr_zoneid; /* zone id */ | ||
public int pr_contract; /* process contract */ | ||
private fixed int pr_filler[1]; /* reserved for future use */ | ||
public lwpsinfo pr_lwp; /* information for representative lwp */ | ||
// C# magic: Accessor method to get a Span for pr_psargs[] | ||
// Does not affect the size or layout of this struct. | ||
internal ReadOnlySpan<byte> PsArgsSpan => | ||
MemoryMarshal.CreateReadOnlySpan(ref pr_psargs[0], PRARGSZ); | ||
} | ||
private const int PR_PSINFO_SIZE = 416; // for debug assertions | ||
|
||
// Ouput type for TryGetThreadInfoById() | ||
internal struct ThreadInfo | ||
{ | ||
internal uint Tid; | ||
internal int Priority; | ||
internal int NiceVal; | ||
internal char Status; | ||
internal Interop.Sys.TimeSpec StartTime; | ||
internal Interop.Sys.TimeSpec CpuTotalTime; // user+sys | ||
// add more fields when needed. | ||
} | ||
|
||
// Ouput type for TryGetProcessInfoById() | ||
internal struct ProcessInfo | ||
{ | ||
internal int Pid; | ||
internal int ParentPid; | ||
internal int SessionId; | ||
internal int Priority; | ||
internal int NiceVal; | ||
internal nuint VirtualSize; | ||
internal nuint ResidentSetSize; | ||
internal Interop.Sys.TimeSpec StartTime; | ||
internal Interop.Sys.TimeSpec CpuTotalTime; // user+sys | ||
internal string? Args; | ||
// add more fields when needed. | ||
} | ||
|
||
internal static string GetInfoFilePathForProcess(int pid) => | ||
$"{RootPath}{(uint)pid}{psinfoFileName}"; | ||
|
||
internal static string GetLwpDirForProcess(int pid) => | ||
$"{RootPath}{(uint)pid}{lwpDirName}"; | ||
|
||
internal static string GetInfoFilePathForThread(int pid, int tid) => | ||
$"{RootPath}{(uint)pid}{lwpDirName}/{(uint)tid}{lwpsinfoFileName}"; | ||
|
||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.