procfs.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Definitions for core files and libthread_db. Generic Linux version.
  17. Copyright (C) 1996-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _SYS_PROCFS_H
  31. #define _SYS_PROCFS_H 1
  32. /* This is somewhat modelled after the file of the same name on SVR4
  33. systems. It provides a definition of the core file format for ELF
  34. used on Linux. It doesn't have anything to do with the /proc file
  35. system, even though Linux has one.
  36. Anyway, the whole purpose of this file is for GDB and GDB only.
  37. Don't read too much into it. Don't use it for anything other than
  38. GDB unless you know what you are doing. */
  39. #include <features.h>
  40. #include <sys/time.h>
  41. #include <sys/types.h>
  42. #include <sys/user.h>
  43. /* bits/procfs.h, provided by each architecture, must define
  44. elf_gregset_t, elf_fpregset_t and any other architecture-specific
  45. types needed. */
  46. #include <bits/procfs.h>
  47. /* bits/procfs-id.h must define __pr_uid_t and __pr_gid_t, the types
  48. of pr_uid and pr_gid. */
  49. #include <bits/procfs-id.h>
  50. __BEGIN_DECLS
  51. /* Signal info. */
  52. struct elf_siginfo
  53. {
  54. int si_signo; /* Signal number. */
  55. int si_code; /* Extra code. */
  56. int si_errno; /* Errno. */
  57. };
  58. /* Definitions to generate Intel SVR4-like core files. These mostly
  59. have the same names as the SVR4 types with "elf_" tacked on the
  60. front to prevent clashes with Linux definitions, and the typedef
  61. forms have been avoided. This is mostly like the SVR4 structure,
  62. but more Linuxy, with things that Linux does not support and which
  63. GDB doesn't really use excluded. */
  64. struct elf_prstatus
  65. {
  66. struct elf_siginfo pr_info; /* Info associated with signal. */
  67. short int pr_cursig; /* Current signal. */
  68. unsigned long int pr_sigpend; /* Set of pending signals. */
  69. unsigned long int pr_sighold; /* Set of held signals. */
  70. __pid_t pr_pid;
  71. __pid_t pr_ppid;
  72. __pid_t pr_pgrp;
  73. __pid_t pr_sid;
  74. struct timeval pr_utime; /* User time. */
  75. struct timeval pr_stime; /* System time. */
  76. struct timeval pr_cutime; /* Cumulative user time. */
  77. struct timeval pr_cstime; /* Cumulative system time. */
  78. elf_gregset_t pr_reg; /* GP registers. */
  79. int pr_fpvalid; /* True if math copro being used. */
  80. };
  81. #define ELF_PRARGSZ (80) /* Number of chars for args. */
  82. struct elf_prpsinfo
  83. {
  84. char pr_state; /* Numeric process state. */
  85. char pr_sname; /* Char for pr_state. */
  86. char pr_zomb; /* Zombie. */
  87. char pr_nice; /* Nice val. */
  88. unsigned long int pr_flag; /* Flags. */
  89. __pr_uid_t pr_uid;
  90. __pr_gid_t pr_gid;
  91. int pr_pid, pr_ppid, pr_pgrp, pr_sid;
  92. /* Lots missing */
  93. char pr_fname[16]; /* Filename of executable. */
  94. char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
  95. };
  96. /* The rest of this file provides the types for emulation of the
  97. Solaris <proc_service.h> interfaces that should be implemented by
  98. users of libthread_db. */
  99. /* Addresses. */
  100. typedef void *psaddr_t;
  101. #include <bits/procfs-prregset.h>
  102. /* Register sets. Linux has different names. */
  103. typedef __prgregset_t prgregset_t;
  104. typedef __prfpregset_t prfpregset_t;
  105. /* We don't have any differences between processes and threads,
  106. therefore have only one PID type. */
  107. typedef __pid_t lwpid_t;
  108. /* Process status and info. In the end we do provide typedefs for them. */
  109. typedef struct elf_prstatus prstatus_t;
  110. typedef struct elf_prpsinfo prpsinfo_t;
  111. __END_DECLS
  112. /* On some architectures, provide other-ABI variants of the above
  113. types. */
  114. #include <bits/procfs-extra.h>
  115. #endif /* sys/procfs.h. */