procps.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Utility routines.
  4. *
  5. * Copyright 1998 by Albert Cahalan; all rights reserved.
  6. * Copyright (C) 2002 by Vladimir Oleynik <dzo@simtreas.ru>
  7. * SELinux support: (c) 2007 by Yuichi Nakamura <ynakam@hitachisoft.jp>
  8. *
  9. * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  10. */
  11. #include "libbb.h"
  12. typedef struct unsigned_to_name_map_t {
  13. long id;
  14. char name[USERNAME_MAX_SIZE];
  15. } unsigned_to_name_map_t;
  16. typedef struct cache_t {
  17. unsigned_to_name_map_t *cache;
  18. int size;
  19. } cache_t;
  20. static cache_t username, groupname;
  21. static void clear_cache(cache_t *cp)
  22. {
  23. free(cp->cache);
  24. cp->cache = NULL;
  25. cp->size = 0;
  26. }
  27. void FAST_FUNC clear_username_cache(void)
  28. {
  29. clear_cache(&username);
  30. clear_cache(&groupname);
  31. }
  32. #if 0 /* more generic, but we don't need that yet */
  33. /* Returns -N-1 if not found. */
  34. /* cp->cache[N] is allocated and must be filled in this case */
  35. static int get_cached(cache_t *cp, unsigned id)
  36. {
  37. int i;
  38. for (i = 0; i < cp->size; i++)
  39. if (cp->cache[i].id == id)
  40. return i;
  41. i = cp->size++;
  42. cp->cache = xrealloc_vector(cp->cache, 2, i);
  43. cp->cache[i++].id = id;
  44. return -i;
  45. }
  46. #endif
  47. static char* get_cached(cache_t *cp, long id,
  48. char* FAST_FUNC x2x_utoa(long id))
  49. {
  50. int i;
  51. for (i = 0; i < cp->size; i++)
  52. if (cp->cache[i].id == id)
  53. return cp->cache[i].name;
  54. i = cp->size++;
  55. cp->cache = xrealloc_vector(cp->cache, 2, i);
  56. cp->cache[i].id = id;
  57. /* Never fails. Generates numeric string if name isn't found */
  58. safe_strncpy(cp->cache[i].name, x2x_utoa(id), sizeof(cp->cache[i].name));
  59. return cp->cache[i].name;
  60. }
  61. const char* FAST_FUNC get_cached_username(uid_t uid)
  62. {
  63. return get_cached(&username, uid, uid2uname_utoa);
  64. }
  65. const char* FAST_FUNC get_cached_groupname(gid_t gid)
  66. {
  67. return get_cached(&groupname, gid, gid2group_utoa);
  68. }
  69. #define PROCPS_BUFSIZE 1024
  70. static int read_to_buf(const char *filename, void *buf)
  71. {
  72. int fd;
  73. /* open_read_close() would do two reads, checking for EOF.
  74. * When you have 10000 /proc/$NUM/stat to read, it isn't desirable */
  75. ssize_t ret = -1;
  76. fd = open(filename, O_RDONLY);
  77. if (fd >= 0) {
  78. ret = read(fd, buf, PROCPS_BUFSIZE-1);
  79. close(fd);
  80. }
  81. ((char *)buf)[ret > 0 ? ret : 0] = '\0';
  82. return ret;
  83. }
  84. static procps_status_t* FAST_FUNC alloc_procps_scan(void)
  85. {
  86. unsigned n = getpagesize();
  87. procps_status_t* sp = xzalloc(sizeof(procps_status_t));
  88. sp->dir = xopendir("/proc");
  89. while (1) {
  90. n >>= 1;
  91. if (!n) break;
  92. sp->shift_pages_to_bytes++;
  93. }
  94. sp->shift_pages_to_kb = sp->shift_pages_to_bytes - 10;
  95. return sp;
  96. }
  97. void FAST_FUNC free_procps_scan(procps_status_t* sp)
  98. {
  99. closedir(sp->dir);
  100. #if ENABLE_FEATURE_SHOW_THREADS
  101. if (sp->task_dir)
  102. closedir(sp->task_dir);
  103. #endif
  104. free(sp->argv0);
  105. free(sp->exe);
  106. IF_SELINUX(free(sp->context);)
  107. free(sp);
  108. }
  109. #if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP
  110. static unsigned long fast_strtoul_16(char **endptr)
  111. {
  112. unsigned char c;
  113. char *str = *endptr;
  114. unsigned long n = 0;
  115. while ((c = *str++) != ' ') {
  116. c = ((c|0x20) - '0');
  117. if (c > 9)
  118. // c = c + '0' - 'a' + 10:
  119. c = c - ('a' - '0' - 10);
  120. n = n*16 + c;
  121. }
  122. *endptr = str; /* We skip trailing space! */
  123. return n;
  124. }
  125. #endif
  126. #if ENABLE_FEATURE_FAST_TOP || ENABLE_FEATURE_TOPMEM || ENABLE_PMAP
  127. /* We cut a lot of corners here for speed */
  128. static unsigned long fast_strtoul_10(char **endptr)
  129. {
  130. char c;
  131. char *str = *endptr;
  132. unsigned long n = *str - '0';
  133. while ((c = *++str) != ' ')
  134. n = n*10 + (c - '0');
  135. *endptr = str + 1; /* We skip trailing space! */
  136. return n;
  137. }
  138. # if ENABLE_FEATURE_FAST_TOP
  139. static long fast_strtol_10(char **endptr)
  140. {
  141. if (**endptr != '-')
  142. return fast_strtoul_10(endptr);
  143. (*endptr)++;
  144. return - (long)fast_strtoul_10(endptr);
  145. }
  146. # endif
  147. static char *skip_fields(char *str, int count)
  148. {
  149. do {
  150. while (*str++ != ' ')
  151. continue;
  152. /* we found a space char, str points after it */
  153. } while (--count);
  154. return str;
  155. }
  156. #endif
  157. #if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP
  158. int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
  159. void (*cb)(struct smaprec *, void *), void *data)
  160. {
  161. FILE *file;
  162. struct smaprec currec;
  163. char filename[sizeof("/proc/%u/smaps") + sizeof(int)*3];
  164. char buf[PROCPS_BUFSIZE];
  165. #if !ENABLE_PMAP
  166. void (*cb)(struct smaprec *, void *) = NULL;
  167. void *data = NULL;
  168. #endif
  169. sprintf(filename, "/proc/%u/smaps", (int)pid);
  170. file = fopen_for_read(filename);
  171. if (!file)
  172. return 1;
  173. memset(&currec, 0, sizeof(currec));
  174. while (fgets(buf, PROCPS_BUFSIZE, file)) {
  175. // Each mapping datum has this form:
  176. // f7d29000-f7d39000 rw-s ADR M:m OFS FILE
  177. // Size: nnn kB
  178. // Rss: nnn kB
  179. // .....
  180. char *tp = buf, *p;
  181. #define SCAN(S, X) \
  182. if (strncmp(tp, S, sizeof(S)-1) == 0) { \
  183. tp = skip_whitespace(tp + sizeof(S)-1); \
  184. total->X += currec.X = fast_strtoul_10(&tp); \
  185. continue; \
  186. }
  187. if (cb) {
  188. SCAN("Pss:" , smap_pss );
  189. SCAN("Swap:" , smap_swap );
  190. }
  191. SCAN("Private_Dirty:", private_dirty);
  192. SCAN("Private_Clean:", private_clean);
  193. SCAN("Shared_Dirty:" , shared_dirty );
  194. SCAN("Shared_Clean:" , shared_clean );
  195. #undef SCAN
  196. tp = strchr(buf, '-');
  197. if (tp) {
  198. // We reached next mapping - the line of this form:
  199. // f7d29000-f7d39000 rw-s ADR M:m OFS FILE
  200. if (cb) {
  201. /* If we have a previous record, there's nothing more
  202. * for it, call the callback and clear currec
  203. */
  204. if (currec.smap_size)
  205. cb(&currec, data);
  206. free(currec.smap_name);
  207. }
  208. memset(&currec, 0, sizeof(currec));
  209. *tp = ' ';
  210. tp = buf;
  211. currec.smap_start = fast_strtoul_16(&tp);
  212. currec.smap_size = (fast_strtoul_16(&tp) - currec.smap_start) >> 10;
  213. strncpy(currec.smap_mode, tp, sizeof(currec.smap_mode)-1);
  214. // skipping "rw-s ADR M:m OFS "
  215. tp = skip_whitespace(skip_fields(tp, 4));
  216. // filter out /dev/something (something != zero)
  217. if (strncmp(tp, "/dev/", 5) != 0 || strcmp(tp, "/dev/zero\n") == 0) {
  218. if (currec.smap_mode[1] == 'w') {
  219. currec.mapped_rw = currec.smap_size;
  220. total->mapped_rw += currec.smap_size;
  221. } else if (currec.smap_mode[1] == '-') {
  222. currec.mapped_ro = currec.smap_size;
  223. total->mapped_ro += currec.smap_size;
  224. }
  225. }
  226. if (strcmp(tp, "[stack]\n") == 0)
  227. total->stack += currec.smap_size;
  228. if (cb) {
  229. p = skip_non_whitespace(tp);
  230. if (p == tp) {
  231. currec.smap_name = xstrdup(" [ anon ]");
  232. } else {
  233. *p = '\0';
  234. currec.smap_name = xstrdup(tp);
  235. }
  236. }
  237. total->smap_size += currec.smap_size;
  238. }
  239. }
  240. fclose(file);
  241. if (cb) {
  242. if (currec.smap_size)
  243. cb(&currec, data);
  244. free(currec.smap_name);
  245. }
  246. return 0;
  247. }
  248. #endif
  249. void BUG_comm_size(void);
  250. procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
  251. {
  252. struct dirent *entry;
  253. char buf[PROCPS_BUFSIZE];
  254. char filename[sizeof("/proc//cmdline") + sizeof(int)*3];
  255. char *filename_tail;
  256. long tasknice;
  257. unsigned pid;
  258. int n;
  259. struct stat sb;
  260. if (!sp)
  261. sp = alloc_procps_scan();
  262. for (;;) {
  263. #if ENABLE_FEATURE_SHOW_THREADS
  264. if ((flags & PSSCAN_TASKS) && sp->task_dir) {
  265. entry = readdir(sp->task_dir);
  266. if (entry)
  267. goto got_entry;
  268. closedir(sp->task_dir);
  269. sp->task_dir = NULL;
  270. }
  271. #endif
  272. entry = readdir(sp->dir);
  273. if (entry == NULL) {
  274. free_procps_scan(sp);
  275. return NULL;
  276. }
  277. IF_FEATURE_SHOW_THREADS(got_entry:)
  278. pid = bb_strtou(entry->d_name, NULL, 10);
  279. if (errno)
  280. continue;
  281. #if ENABLE_FEATURE_SHOW_THREADS
  282. if ((flags & PSSCAN_TASKS) && !sp->task_dir) {
  283. /* We found another /proc/PID. Do not use it,
  284. * there will be /proc/PID/task/PID (same PID!),
  285. * so just go ahead and dive into /proc/PID/task. */
  286. char task_dir[sizeof("/proc/%u/task") + sizeof(int)*3];
  287. sprintf(task_dir, "/proc/%u/task", pid);
  288. sp->task_dir = xopendir(task_dir);
  289. continue;
  290. }
  291. #endif
  292. /* After this point we can:
  293. * "break": stop parsing, return the data
  294. * "continue": try next /proc/XXX
  295. */
  296. memset(&sp->vsz, 0, sizeof(*sp) - offsetof(procps_status_t, vsz));
  297. sp->pid = pid;
  298. if (!(flags & ~PSSCAN_PID))
  299. break; /* we needed only pid, we got it */
  300. #if ENABLE_SELINUX
  301. if (flags & PSSCAN_CONTEXT) {
  302. if (getpidcon(sp->pid, &sp->context) < 0)
  303. sp->context = NULL;
  304. }
  305. #endif
  306. filename_tail = filename + sprintf(filename, "/proc/%u/", pid);
  307. if (flags & PSSCAN_UIDGID) {
  308. if (stat(filename, &sb))
  309. continue; /* process probably exited */
  310. /* Effective UID/GID, not real */
  311. sp->uid = sb.st_uid;
  312. sp->gid = sb.st_gid;
  313. }
  314. if (flags & PSSCAN_STAT) {
  315. char *cp, *comm1;
  316. int tty;
  317. #if !ENABLE_FEATURE_FAST_TOP
  318. unsigned long vsz, rss;
  319. #endif
  320. /* see proc(5) for some details on this */
  321. strcpy(filename_tail, "stat");
  322. n = read_to_buf(filename, buf);
  323. if (n < 0)
  324. continue; /* process probably exited */
  325. cp = strrchr(buf, ')'); /* split into "PID (cmd" and "<rest>" */
  326. /*if (!cp || cp[1] != ' ')
  327. continue;*/
  328. cp[0] = '\0';
  329. if (sizeof(sp->comm) < 16)
  330. BUG_comm_size();
  331. comm1 = strchr(buf, '(');
  332. /*if (comm1)*/
  333. safe_strncpy(sp->comm, comm1 + 1, sizeof(sp->comm));
  334. #if !ENABLE_FEATURE_FAST_TOP
  335. n = sscanf(cp+2,
  336. "%c %u " /* state, ppid */
  337. "%u %u %d %*s " /* pgid, sid, tty, tpgid */
  338. "%*s %*s %*s %*s %*s " /* flags, min_flt, cmin_flt, maj_flt, cmaj_flt */
  339. "%lu %lu " /* utime, stime */
  340. "%*s %*s %*s " /* cutime, cstime, priority */
  341. "%ld " /* nice */
  342. "%*s %*s " /* timeout, it_real_value */
  343. "%lu " /* start_time */
  344. "%lu " /* vsize */
  345. "%lu " /* rss */
  346. # if ENABLE_FEATURE_TOP_SMP_PROCESS
  347. "%*s %*s %*s %*s %*s %*s " /*rss_rlim, start_code, end_code, start_stack, kstk_esp, kstk_eip */
  348. "%*s %*s %*s %*s " /*signal, blocked, sigignore, sigcatch */
  349. "%*s %*s %*s %*s " /*wchan, nswap, cnswap, exit_signal */
  350. "%d" /*cpu last seen on*/
  351. # endif
  352. ,
  353. sp->state, &sp->ppid,
  354. &sp->pgid, &sp->sid, &tty,
  355. &sp->utime, &sp->stime,
  356. &tasknice,
  357. &sp->start_time,
  358. &vsz,
  359. &rss
  360. # if ENABLE_FEATURE_TOP_SMP_PROCESS
  361. , &sp->last_seen_on_cpu
  362. # endif
  363. );
  364. if (n < 11)
  365. continue; /* bogus data, get next /proc/XXX */
  366. # if ENABLE_FEATURE_TOP_SMP_PROCESS
  367. if (n < 11+15)
  368. sp->last_seen_on_cpu = 0;
  369. # endif
  370. /* vsz is in bytes and we want kb */
  371. sp->vsz = vsz >> 10;
  372. /* vsz is in bytes but rss is in *PAGES*! Can you believe that? */
  373. sp->rss = rss << sp->shift_pages_to_kb;
  374. sp->tty_major = (tty >> 8) & 0xfff;
  375. sp->tty_minor = (tty & 0xff) | ((tty >> 12) & 0xfff00);
  376. #else
  377. /* This costs ~100 bytes more but makes top faster by 20%
  378. * If you run 10000 processes, this may be important for you */
  379. sp->state[0] = cp[2];
  380. cp += 4;
  381. sp->ppid = fast_strtoul_10(&cp);
  382. sp->pgid = fast_strtoul_10(&cp);
  383. sp->sid = fast_strtoul_10(&cp);
  384. tty = fast_strtoul_10(&cp);
  385. sp->tty_major = (tty >> 8) & 0xfff;
  386. sp->tty_minor = (tty & 0xff) | ((tty >> 12) & 0xfff00);
  387. cp = skip_fields(cp, 6); /* tpgid, flags, min_flt, cmin_flt, maj_flt, cmaj_flt */
  388. sp->utime = fast_strtoul_10(&cp);
  389. sp->stime = fast_strtoul_10(&cp);
  390. cp = skip_fields(cp, 3); /* cutime, cstime, priority */
  391. tasknice = fast_strtol_10(&cp);
  392. cp = skip_fields(cp, 2); /* timeout, it_real_value */
  393. sp->start_time = fast_strtoul_10(&cp);
  394. /* vsz is in bytes and we want kb */
  395. sp->vsz = fast_strtoul_10(&cp) >> 10;
  396. /* vsz is in bytes but rss is in *PAGES*! Can you believe that? */
  397. sp->rss = fast_strtoul_10(&cp) << sp->shift_pages_to_kb;
  398. # if ENABLE_FEATURE_TOP_SMP_PROCESS
  399. /* (6): rss_rlim, start_code, end_code, start_stack, kstk_esp, kstk_eip */
  400. /* (4): signal, blocked, sigignore, sigcatch */
  401. /* (4): wchan, nswap, cnswap, exit_signal */
  402. cp = skip_fields(cp, 14);
  403. //FIXME: is it safe to assume this field exists?
  404. sp->last_seen_on_cpu = fast_strtoul_10(&cp);
  405. # endif
  406. #endif /* FEATURE_FAST_TOP */
  407. #if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
  408. sp->niceness = tasknice;
  409. #endif
  410. if (sp->vsz == 0 && sp->state[0] != 'Z')
  411. sp->state[1] = 'W';
  412. else
  413. sp->state[1] = ' ';
  414. if (tasknice < 0)
  415. sp->state[2] = '<';
  416. else if (tasknice) /* > 0 */
  417. sp->state[2] = 'N';
  418. else
  419. sp->state[2] = ' ';
  420. }
  421. #if ENABLE_FEATURE_TOPMEM
  422. if (flags & PSSCAN_SMAPS)
  423. procps_read_smaps(pid, &sp->smaps, NULL, NULL);
  424. #endif /* TOPMEM */
  425. #if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS
  426. if (flags & PSSCAN_RUIDGID) {
  427. FILE *file;
  428. strcpy(filename_tail, "status");
  429. file = fopen_for_read(filename);
  430. if (file) {
  431. while (fgets(buf, sizeof(buf), file)) {
  432. char *tp;
  433. #define SCAN_TWO(str, name, statement) \
  434. if (strncmp(buf, str, sizeof(str)-1) == 0) { \
  435. tp = skip_whitespace(buf + sizeof(str)-1); \
  436. sscanf(tp, "%u", &sp->name); \
  437. statement; \
  438. }
  439. SCAN_TWO("Uid:", ruid, continue);
  440. SCAN_TWO("Gid:", rgid, break);
  441. #undef SCAN_TWO
  442. }
  443. fclose(file);
  444. }
  445. }
  446. #endif /* PS_ADDITIONAL_COLUMNS */
  447. if (flags & PSSCAN_EXE) {
  448. strcpy(filename_tail, "exe");
  449. free(sp->exe);
  450. sp->exe = xmalloc_readlink(filename);
  451. }
  452. /* Note: if /proc/PID/cmdline is empty,
  453. * code below "breaks". Therefore it must be
  454. * the last code to parse /proc/PID/xxx data
  455. * (we used to have /proc/PID/exe parsing after it
  456. * and were getting stale sp->exe).
  457. */
  458. #if 0 /* PSSCAN_CMD is not used */
  459. if (flags & (PSSCAN_CMD|PSSCAN_ARGV0)) {
  460. free(sp->argv0);
  461. sp->argv0 = NULL;
  462. free(sp->cmd);
  463. sp->cmd = NULL;
  464. strcpy(filename_tail, "cmdline");
  465. /* TODO: to get rid of size limits, read into malloc buf,
  466. * then realloc it down to real size. */
  467. n = read_to_buf(filename, buf);
  468. if (n <= 0)
  469. break;
  470. if (flags & PSSCAN_ARGV0)
  471. sp->argv0 = xstrdup(buf);
  472. if (flags & PSSCAN_CMD) {
  473. do {
  474. n--;
  475. if ((unsigned char)(buf[n]) < ' ')
  476. buf[n] = ' ';
  477. } while (n);
  478. sp->cmd = xstrdup(buf);
  479. }
  480. }
  481. #else
  482. if (flags & (PSSCAN_ARGV0|PSSCAN_ARGVN)) {
  483. free(sp->argv0);
  484. sp->argv0 = NULL;
  485. strcpy(filename_tail, "cmdline");
  486. n = read_to_buf(filename, buf);
  487. if (n <= 0)
  488. break;
  489. if (flags & PSSCAN_ARGVN) {
  490. sp->argv_len = n;
  491. sp->argv0 = xmalloc(n + 1);
  492. memcpy(sp->argv0, buf, n + 1);
  493. /* sp->argv0[n] = '\0'; - buf has it */
  494. } else {
  495. sp->argv_len = 0;
  496. sp->argv0 = xstrdup(buf);
  497. }
  498. }
  499. #endif
  500. break;
  501. } /* for (;;) */
  502. return sp;
  503. }
  504. void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm)
  505. {
  506. int sz;
  507. char filename[sizeof("/proc//cmdline") + sizeof(int)*3];
  508. sprintf(filename, "/proc/%u/cmdline", pid);
  509. sz = open_read_close(filename, buf, col - 1);
  510. if (sz > 0) {
  511. buf[sz] = '\0';
  512. while (--sz >= 0 && buf[sz] == '\0')
  513. continue;
  514. do {
  515. if ((unsigned char)(buf[sz]) < ' ')
  516. buf[sz] = ' ';
  517. } while (--sz >= 0);
  518. } else {
  519. snprintf(buf, col, "[%s]", comm);
  520. }
  521. }
  522. /* from kernel:
  523. // pid comm S ppid pgid sid tty_nr tty_pgrp flg
  524. sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \
  525. %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
  526. %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu %llu\n",
  527. task->pid,
  528. tcomm,
  529. state,
  530. ppid,
  531. pgid,
  532. sid,
  533. tty_nr,
  534. tty_pgrp,
  535. task->flags,
  536. min_flt,
  537. cmin_flt,
  538. maj_flt,
  539. cmaj_flt,
  540. cputime_to_clock_t(utime),
  541. cputime_to_clock_t(stime),
  542. cputime_to_clock_t(cutime),
  543. cputime_to_clock_t(cstime),
  544. priority,
  545. nice,
  546. num_threads,
  547. // 0,
  548. start_time,
  549. vsize,
  550. mm ? get_mm_rss(mm) : 0,
  551. rsslim,
  552. mm ? mm->start_code : 0,
  553. mm ? mm->end_code : 0,
  554. mm ? mm->start_stack : 0,
  555. esp,
  556. eip,
  557. the rest is some obsolete cruft
  558. */