strace.ast 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. TranslationUnit[0:0->150:0]
  2. VariableDeclaration[0:0->2:0]
  3. NamedType[0:0->0:9]
  4. [static] int
  5. g_pid
  6. UnaryExpression[0:19->0:20]
  7. -
  8. NumericLiteral[0:20->0:20]
  9. 1
  10. FunctionDeclaration[2:0->10:0]
  11. [static]
  12. NamedType[2:7->2:10]
  13. void
  14. handle_sigint
  15. (
  16. Parameter[2:26->2:28]
  17. NamedType[2:26->2:28]
  18. int
  19. )
  20. FunctionDefinition[3:0->10:0]
  21. {
  22. IfStatement[4:4->5:14]
  23. Predicate:
  24. BinaryExpression[4:8->4:18]
  25. Name[4:8->4:12]
  26. g_pid
  27. ==
  28. UnaryExpression[4:17->4:18]
  29. -
  30. NumericLiteral[4:18->4:18]
  31. 1
  32. Then:
  33. ReturnStatement[5:8->5:14]
  34. IfStatement[7:4->10:0]
  35. Predicate:
  36. BinaryExpression[7:8->7:43]
  37. FunctionCall[7:8->7:39]
  38. Name[7:8->7:13]
  39. ptrace
  40. Name[7:15->7:23]
  41. PT_DETACH
  42. Name[7:26->7:30]
  43. g_pid
  44. NumericLiteral[7:33->7:33]
  45. 0
  46. NumericLiteral[7:36->7:36]
  47. 0
  48. ==
  49. UnaryExpression[7:42->7:43]
  50. -
  51. NumericLiteral[7:43->7:43]
  52. 1
  53. Then:
  54. BlockStatement[7:46->10:0]
  55. FunctionCall[8:8->8:24]
  56. Name[8:8->8:13]
  57. perror
  58. StringLiteral[8:15->8:22]
  59. "detach"
  60. }
  61. FunctionDeclaration[12:0->150:0]
  62. NamedType[12:0->12:2]
  63. int
  64. main
  65. (
  66. Parameter[12:9->12:16]
  67. argc
  68. NamedType[12:9->12:11]
  69. int
  70. Parameter[12:19->12:29]
  71. argv
  72. Pointer[12:19->12:24]
  73. Pointer[12:19->12:24]
  74. NamedType[12:19->12:23]
  75. char
  76. )
  77. FunctionDefinition[13:0->150:0]
  78. {
  79. IfStatement[14:4->19:4]
  80. Predicate:
  81. BinaryExpression[14:8->14:74]
  82. FunctionCall[14:8->14:72]
  83. Name[14:8->14:13]
  84. pledge
  85. StringLiteral[14:15->14:60]
  86. "stdio wpath cpath proc exec ptrace sigaction"
  87. NullPointerLiteral[14:63->14:69]
  88. <
  89. NumericLiteral[14:74->14:74]
  90. 0
  91. Then:
  92. BlockStatement[14:77->19:4]
  93. FunctionCall[15:8->15:24]
  94. Name[15:8->15:13]
  95. perror
  96. StringLiteral[15:15->15:22]
  97. "pledge"
  98. ReturnStatement[16:8->16:16]
  99. NumericLiteral[16:15->16:15]
  100. 1
  101. VariableDeclaration[19:4->19:34]
  102. NamedType[19:4->19:22]
  103. Vector<[const] char*>
  104. child_argv
  105. VariableDeclaration[21:4->21:41]
  106. Pointer[21:4->21:14]
  107. NamedType[21:4->21:14]
  108. [const] char
  109. output_filename
  110. NullPointerLiteral[21:34->21:40]
  111. VariableDeclaration[22:4->22:59]
  112. NamedType[22:4->22:7]
  113. auto
  114. trace_file_or_error
  115. FunctionCall[22:31->22:59]
  116. Name[22:31->22:56]
  117. Core::File::standard_error
  118. IfStatement[23:4->27:4]
  119. Predicate:
  120. FunctionCall[23:8->23:38]
  121. MemberExpression[23:8->23:36]
  122. Name[23:8->23:26]
  123. trace_file_or_error
  124. Identifier[23:28->23:35]
  125. is_error
  126. Then:
  127. BlockStatement[23:40->27:4]
  128. FunctionCall[24:8->24:79]
  129. Name[24:8->24:12]
  130. outln
  131. Name[24:14->24:19]
  132. stderr
  133. StringLiteral[24:22->24:48]
  134. "Failed to open stderr: {}"
  135. FunctionCall[24:51->24:78]
  136. MemberExpression[24:51->24:76]
  137. Name[24:51->24:69]
  138. trace_file_or_error
  139. Identifier[24:71->24:75]
  140. error
  141. ReturnStatement[25:8->25:16]
  142. NumericLiteral[25:15->25:15]
  143. 1
  144. VariableDeclaration[27:4->27:57]
  145. NamedType[27:4->27:7]
  146. auto
  147. trace_file
  148. FunctionCall[27:22->27:57]
  149. MemberExpression[27:22->27:55]
  150. Name[27:22->27:40]
  151. trace_file_or_error
  152. Identifier[27:42->27:54]
  153. release_value
  154. VariableDeclaration[29:4->29:27]
  155. NamedType[29:4->29:19]
  156. Core::ArgsParser
  157. parser
  158. FunctionCall[30:4->31:47]
  159. MemberExpression[30:4->30:27]
  160. Name[30:4->30:9]
  161. parser
  162. Identifier[30:11->30:26]
  163. set_general_help
  164. StringLiteral[31:8->31:45]
  165. "Trace all syscalls and their result."
  166. FunctionCall[32:4->32:70]
  167. MemberExpression[32:4->32:21]
  168. Name[32:4->32:9]
  169. parser
  170. Identifier[32:11->32:20]
  171. add_option
  172. Name[32:22->32:26]
  173. g_pid
  174. StringLiteral[32:29->32:49]
  175. "Trace the given PID"
  176. StringLiteral[32:52->32:56]
  177. "pid"
  178. StringLiteral[32:59->32:61]
  179. 'p'
  180. StringLiteral[32:64->32:68]
  181. "pid"
  182. FunctionCall[33:4->33:94]
  183. MemberExpression[33:4->33:21]
  184. Name[33:4->33:9]
  185. parser
  186. Identifier[33:11->33:20]
  187. add_option
  188. Name[33:22->33:36]
  189. output_filename
  190. StringLiteral[33:39->33:67]
  191. "Filename to write output to"
  192. StringLiteral[33:70->33:77]
  193. "output"
  194. StringLiteral[33:80->33:82]
  195. 'o'
  196. StringLiteral[33:85->33:92]
  197. "output"
  198. FunctionCall[34:4->34:111]
  199. MemberExpression[34:4->34:34]
  200. Name[34:4->34:9]
  201. parser
  202. Identifier[34:11->34:33]
  203. add_positional_argument
  204. Name[34:35->34:44]
  205. child_argv
  206. StringLiteral[34:47->34:65]
  207. "Arguments to exec"
  208. StringLiteral[34:68->34:77]
  209. "argument"
  210. Name[34:80->34:109]
  211. Core::ArgsParser::Required::No
  212. FunctionCall[36:4->36:28]
  213. MemberExpression[36:4->36:16]
  214. Name[36:4->36:9]
  215. parser
  216. Identifier[36:11->36:15]
  217. parse
  218. Name[36:17->36:20]
  219. argc
  220. Name[36:23->36:26]
  221. argv
  222. IfStatement[38:4->47:4]
  223. Predicate:
  224. BinaryExpression[38:8->38:33]
  225. Name[38:8->38:22]
  226. output_filename
  227. !=
  228. NullPointerLiteral[38:27->38:33]
  229. Then:
  230. BlockStatement[38:36->47:4]
  231. VariableDeclaration[39:8->39:89]
  232. NamedType[39:8->39:11]
  233. auto
  234. open_result
  235. FunctionCall[39:27->39:89]
  236. Name[39:27->39:42]
  237. Core::File::open
  238. Name[39:44->39:58]
  239. output_filename
  240. Name[39:61->39:87]
  241. Core::File::OpenMode::Write
  242. IfStatement[40:8->44:8]
  243. Predicate:
  244. FunctionCall[40:12->40:34]
  245. MemberExpression[40:12->40:32]
  246. Name[40:12->40:22]
  247. open_result
  248. Identifier[40:24->40:31]
  249. is_error
  250. Then:
  251. BlockStatement[40:36->44:8]
  252. FunctionCall[41:12->41:80]
  253. Name[41:12->41:16]
  254. outln
  255. Name[41:18->41:23]
  256. stderr
  257. StringLiteral[41:26->41:57]
  258. "Failed to open output file: {}"
  259. FunctionCall[41:60->41:79]
  260. MemberExpression[41:60->41:77]
  261. Name[41:60->41:70]
  262. open_result
  263. Identifier[41:72->41:76]
  264. error
  265. ReturnStatement[42:12->42:20]
  266. NumericLiteral[42:19->42:19]
  267. 1
  268. AssignmentExpression[44:8->44:48]
  269. Name[44:8->44:17]
  270. trace_file
  271. =
  272. FunctionCall[44:21->44:48]
  273. MemberExpression[44:21->44:46]
  274. Name[44:21->44:31]
  275. open_result
  276. Identifier[44:33->44:45]
  277. release_value
  278. IfStatement[47:4->52:4]
  279. Predicate:
  280. BinaryExpression[47:8->47:62]
  281. FunctionCall[47:8->47:60]
  282. Name[47:8->47:13]
  283. pledge
  284. StringLiteral[47:15->47:48]
  285. "stdio proc exec ptrace sigaction"
  286. NullPointerLiteral[47:51->47:57]
  287. <
  288. NumericLiteral[47:62->47:62]
  289. 0
  290. Then:
  291. BlockStatement[47:65->52:4]
  292. FunctionCall[48:8->48:24]
  293. Name[48:8->48:13]
  294. perror
  295. StringLiteral[48:15->48:22]
  296. "pledge"
  297. ReturnStatement[49:8->49:16]
  298. NumericLiteral[49:15->49:15]
  299. 1
  300. VariableDeclaration[52:4->52:14]
  301. NamedType[52:4->52:6]
  302. int
  303. status
  304. IfStatement[53:4->86:4]
  305. Predicate:
  306. BinaryExpression[53:8->53:18]
  307. Name[53:8->53:12]
  308. g_pid
  309. ==
  310. UnaryExpression[53:17->53:18]
  311. -
  312. NumericLiteral[53:18->53:18]
  313. 1
  314. Then:
  315. BlockStatement[53:21->86:4]
  316. IfStatement[54:8->59:8]
  317. Predicate:
  318. FunctionCall[54:12->54:33]
  319. MemberExpression[54:12->54:31]
  320. Name[54:12->54:21]
  321. child_argv
  322. Identifier[54:23->54:30]
  323. is_empty
  324. Then:
  325. BlockStatement[54:35->59:8]
  326. FunctionCall[55:12->55:78]
  327. Name[55:12->55:16]
  328. outln
  329. Name[55:18->55:23]
  330. stderr
  331. StringLiteral[55:26->55:76]
  332. "strace: Expected either a pid or some arguments\n"
  333. ReturnStatement[56:12->56:20]
  334. NumericLiteral[56:19->56:19]
  335. 1
  336. FunctionCall[59:8->59:34]
  337. MemberExpression[59:8->59:25]
  338. Name[59:8->59:17]
  339. child_argv
  340. Identifier[59:19->59:24]
  341. append
  342. NullPointerLiteral[59:26->59:32]
  343. VariableDeclaration[60:8->60:24]
  344. NamedType[60:8->60:10]
  345. int
  346. pid
  347. FunctionCall[60:18->60:24]
  348. Name[60:18->60:21]
  349. fork
  350. IfStatement[61:8->66:8]
  351. Predicate:
  352. BinaryExpression[61:12->61:18]
  353. Name[61:12->61:14]
  354. pid
  355. <
  356. NumericLiteral[61:18->61:18]
  357. 0
  358. Then:
  359. BlockStatement[61:21->66:8]
  360. FunctionCall[62:12->62:26]
  361. Name[62:12->62:17]
  362. perror
  363. StringLiteral[62:19->62:24]
  364. "fork"
  365. ReturnStatement[63:12->63:20]
  366. NumericLiteral[63:19->63:19]
  367. 1
  368. IfStatement[66:8->79:8]
  369. Predicate:
  370. UnaryExpression[66:12->66:15]
  371. !
  372. Name[66:13->66:15]
  373. pid
  374. Then:
  375. BlockStatement[66:18->79:8]
  376. IfStatement[67:12->71:12]
  377. Predicate:
  378. BinaryExpression[67:16->67:49]
  379. FunctionCall[67:16->67:45]
  380. Name[67:16->67:21]
  381. ptrace
  382. Name[67:23->67:33]
  383. PT_TRACE_ME
  384. NumericLiteral[67:36->67:36]
  385. 0
  386. NumericLiteral[67:39->67:39]
  387. 0
  388. NumericLiteral[67:42->67:42]
  389. 0
  390. ==
  391. UnaryExpression[67:48->67:49]
  392. -
  393. NumericLiteral[67:49->67:49]
  394. 1
  395. Then:
  396. BlockStatement[67:52->71:12]
  397. FunctionCall[68:16->68:33]
  398. Name[68:16->68:21]
  399. perror
  400. StringLiteral[68:23->68:31]
  401. "traceme"
  402. ReturnStatement[69:16->69:24]
  403. NumericLiteral[69:23->69:23]
  404. 1
  405. VariableDeclaration[71:12->71:86]
  406. NamedType[71:12->71:14]
  407. int
  408. rc
  409. FunctionCall[71:21->71:86]
  410. Name[71:21->71:26]
  411. execvp
  412. FunctionCall[71:28->71:46]
  413. MemberExpression[71:28->71:44]
  414. Name[71:28->71:37]
  415. child_argv
  416. Identifier[71:39->71:43]
  417. first
  418. CppCastExpression[71:48->71:85]
  419. const_cast
  420. <
  421. Pointer[71:59->71:64]
  422. Pointer[71:59->71:64]
  423. NamedType[71:59->71:63]
  424. char
  425. >
  426. FunctionCall[71:67->71:84]
  427. MemberExpression[71:67->71:82]
  428. Name[71:67->71:76]
  429. child_argv
  430. Identifier[71:78->71:81]
  431. data
  432. IfStatement[72:12->76:12]
  433. Predicate:
  434. BinaryExpression[72:16->72:21]
  435. Name[72:16->72:17]
  436. rc
  437. <
  438. NumericLiteral[72:21->72:21]
  439. 0
  440. Then:
  441. BlockStatement[72:24->76:12]
  442. FunctionCall[73:16->73:32]
  443. Name[73:16->73:21]
  444. perror
  445. StringLiteral[73:23->73:30]
  446. "execvp"
  447. FunctionCall[74:16->74:23]
  448. Name[74:16->74:19]
  449. exit
  450. NumericLiteral[74:21->74:21]
  451. 1
  452. FunctionCall[76:12->76:32]
  453. Name[76:12->76:29]
  454. VERIFY_NOT_REACHED
  455. AssignmentExpression[79:8->79:18]
  456. Name[79:8->79:12]
  457. g_pid
  458. =
  459. Name[79:16->79:18]
  460. pid
  461. IfStatement[80:8->84:4]
  462. Predicate:
  463. BinaryExpression[80:12->80:83]
  464. FunctionCall[80:12->80:54]
  465. Name[80:12->80:18]
  466. waitpid
  467. Name[80:20->80:22]
  468. pid
  469. UnaryExpression[80:25->80:31]
  470. &
  471. Name[80:26->80:31]
  472. status
  473. BinaryExpression[80:34->80:51]
  474. Name[80:34->80:41]
  475. WSTOPPED
  476. |
  477. Name[80:45->80:51]
  478. WEXITED
  479. !=
  480. BinaryExpression[80:57->80:83]
  481. Name[80:57->80:59]
  482. pid
  483. ||
  484. UnaryExpression[80:64->80:83]
  485. !
  486. FunctionCall[80:65->80:83]
  487. Name[80:65->80:74]
  488. WIFSTOPPED
  489. Name[80:76->80:81]
  490. status
  491. Then:
  492. BlockStatement[80:85->84:4]
  493. FunctionCall[81:12->81:29]
  494. Name[81:12->81:17]
  495. perror
  496. StringLiteral[81:19->81:27]
  497. "waitpid"
  498. ReturnStatement[82:12->82:20]
  499. NumericLiteral[82:19->82:19]
  500. 1
  501. VariableDeclaration[86:4->86:23]
  502. NamedType[86:4->86:19]
  503. sigaction
  504. sa
  505. FunctionCall[87:4->87:44]
  506. Name[87:4->87:9]
  507. memset
  508. UnaryExpression[87:11->87:13]
  509. &
  510. Name[87:12->87:13]
  511. sa
  512. NumericLiteral[87:16->87:16]
  513. 0
  514. SizeofExpression[87:19->87:43]
  515. NamedType[87:26->87:41]
  516. sigaction
  517. AssignmentExpression[88:4->88:32]
  518. MemberExpression[88:4->88:18]
  519. Name[88:4->88:5]
  520. sa
  521. Identifier[88:7->88:16]
  522. sa_handler
  523. =
  524. Name[88:20->88:32]
  525. handle_sigint
  526. FunctionCall[89:4->89:35]
  527. Name[89:4->89:12]
  528. sigaction
  529. Name[89:14->89:19]
  530. SIGINT
  531. UnaryExpression[89:22->89:24]
  532. &
  533. Name[89:23->89:24]
  534. sa
  535. NullPointerLiteral[89:27->89:33]
  536. IfStatement[91:4->95:4]
  537. Predicate:
  538. BinaryExpression[91:8->91:43]
  539. FunctionCall[91:8->91:39]
  540. Name[91:8->91:13]
  541. ptrace
  542. Name[91:15->91:23]
  543. PT_ATTACH
  544. Name[91:26->91:30]
  545. g_pid
  546. NumericLiteral[91:33->91:33]
  547. 0
  548. NumericLiteral[91:36->91:36]
  549. 0
  550. ==
  551. UnaryExpression[91:42->91:43]
  552. -
  553. NumericLiteral[91:43->91:43]
  554. 1
  555. Then:
  556. BlockStatement[91:46->95:4]
  557. FunctionCall[92:8->92:24]
  558. Name[92:8->92:13]
  559. perror
  560. StringLiteral[92:15->92:22]
  561. "attach"
  562. ReturnStatement[93:8->93:16]
  563. NumericLiteral[93:15->93:15]
  564. 1
  565. IfStatement[95:4->100:4]
  566. Predicate:
  567. BinaryExpression[95:8->95:83]
  568. FunctionCall[95:8->95:52]
  569. Name[95:8->95:14]
  570. waitpid
  571. Name[95:16->95:20]
  572. g_pid
  573. UnaryExpression[95:23->95:29]
  574. &
  575. Name[95:24->95:29]
  576. status
  577. BinaryExpression[95:32->95:49]
  578. Name[95:32->95:39]
  579. WSTOPPED
  580. |
  581. Name[95:43->95:49]
  582. WEXITED
  583. !=
  584. BinaryExpression[95:55->95:83]
  585. Name[95:55->95:59]
  586. g_pid
  587. ||
  588. UnaryExpression[95:64->95:83]
  589. !
  590. FunctionCall[95:65->95:83]
  591. Name[95:65->95:74]
  592. WIFSTOPPED
  593. Name[95:76->95:81]
  594. status
  595. Then:
  596. BlockStatement[95:85->100:4]
  597. FunctionCall[96:8->96:25]
  598. Name[96:8->96:13]
  599. perror
  600. StringLiteral[96:15->96:23]
  601. "waitpid"
  602. ReturnStatement[97:8->97:16]
  603. NumericLiteral[97:15->97:15]
  604. 1
  605. ForStatement[100:4->149:4]
  606. BlockStatement[100:13->149:4]
  607. IfStatement[101:8->105:8]
  608. Predicate:
  609. BinaryExpression[101:12->101:48]
  610. FunctionCall[101:12->101:44]
  611. Name[101:12->101:17]
  612. ptrace
  613. Name[101:19->101:28]
  614. PT_SYSCALL
  615. Name[101:31->101:35]
  616. g_pid
  617. NumericLiteral[101:38->101:38]
  618. 0
  619. NumericLiteral[101:41->101:41]
  620. 0
  621. ==
  622. UnaryExpression[101:47->101:48]
  623. -
  624. NumericLiteral[101:48->101:48]
  625. 1
  626. Then:
  627. BlockStatement[101:51->105:8]
  628. FunctionCall[102:12->102:29]
  629. Name[102:12->102:17]
  630. perror
  631. StringLiteral[102:19->102:27]
  632. "syscall"
  633. ReturnStatement[103:12->103:20]
  634. NumericLiteral[103:19->103:19]
  635. 1
  636. IfStatement[105:8->109:8]
  637. Predicate:
  638. BinaryExpression[105:12->105:87]
  639. FunctionCall[105:12->105:56]
  640. Name[105:12->105:18]
  641. waitpid
  642. Name[105:20->105:24]
  643. g_pid
  644. UnaryExpression[105:27->105:33]
  645. &
  646. Name[105:28->105:33]
  647. status
  648. BinaryExpression[105:36->105:53]
  649. Name[105:36->105:43]
  650. WSTOPPED
  651. |
  652. Name[105:47->105:53]
  653. WEXITED
  654. !=
  655. BinaryExpression[105:59->105:87]
  656. Name[105:59->105:63]
  657. g_pid
  658. ||
  659. UnaryExpression[105:68->105:87]
  660. !
  661. FunctionCall[105:69->105:87]
  662. Name[105:69->105:78]
  663. WIFSTOPPED
  664. Name[105:80->105:85]
  665. status
  666. Then:
  667. BlockStatement[105:89->109:8]
  668. FunctionCall[106:12->106:30]
  669. Name[106:12->106:17]
  670. perror
  671. StringLiteral[106:19->106:28]
  672. "wait_pid"
  673. ReturnStatement[107:12->107:20]
  674. NumericLiteral[107:19->107:19]
  675. 1
  676. VariableDeclaration[109:8->109:33]
  677. NamedType[109:8->109:22]
  678. PtraceRegisters
  679. regs
  680. BracedInitList[109:31->109:33]
  681. IfStatement[110:8->114:8]
  682. Predicate:
  683. BinaryExpression[110:12->110:52]
  684. FunctionCall[110:12->110:48]
  685. Name[110:12->110:17]
  686. ptrace
  687. Name[110:19->110:28]
  688. PT_GETREGS
  689. Name[110:31->110:35]
  690. g_pid
  691. UnaryExpression[110:38->110:42]
  692. &
  693. Name[110:39->110:42]
  694. regs
  695. NumericLiteral[110:45->110:45]
  696. 0
  697. ==
  698. UnaryExpression[110:51->110:52]
  699. -
  700. NumericLiteral[110:52->110:52]
  701. 1
  702. Then:
  703. BlockStatement[110:55->114:8]
  704. FunctionCall[111:12->111:29]
  705. Name[111:12->111:17]
  706. perror
  707. StringLiteral[111:19->111:27]
  708. "getregs"
  709. ReturnStatement[112:12->112:20]
  710. NumericLiteral[112:19->112:19]
  711. 1
  712. VariableDeclaration[114:8->114:36]
  713. NamedType[114:8->114:10]
  714. u32
  715. syscall_index
  716. MemberExpression[114:28->114:36]
  717. Name[114:28->114:31]
  718. regs
  719. Identifier[114:33->114:35]
  720. eax
  721. VariableDeclaration[115:8->115:27]
  722. NamedType[115:8->115:10]
  723. u32
  724. arg1
  725. MemberExpression[115:19->115:27]
  726. Name[115:19->115:22]
  727. regs
  728. Identifier[115:24->115:26]
  729. edx
  730. VariableDeclaration[116:8->116:27]
  731. NamedType[116:8->116:10]
  732. u32
  733. arg2
  734. MemberExpression[116:19->116:27]
  735. Name[116:19->116:22]
  736. regs
  737. Identifier[116:24->116:26]
  738. ecx
  739. VariableDeclaration[117:8->117:27]
  740. NamedType[117:8->117:10]
  741. u32
  742. arg3
  743. MemberExpression[117:19->117:27]
  744. Name[117:19->117:22]
  745. regs
  746. Identifier[117:24->117:26]
  747. ebx
  748. IfStatement[119:8->123:8]
  749. Predicate:
  750. BinaryExpression[119:12->119:48]
  751. FunctionCall[119:12->119:44]
  752. Name[119:12->119:17]
  753. ptrace
  754. Name[119:19->119:28]
  755. PT_SYSCALL
  756. Name[119:31->119:35]
  757. g_pid
  758. NumericLiteral[119:38->119:38]
  759. 0
  760. NumericLiteral[119:41->119:41]
  761. 0
  762. ==
  763. UnaryExpression[119:47->119:48]
  764. -
  765. NumericLiteral[119:48->119:48]
  766. 1
  767. Then:
  768. BlockStatement[119:51->123:8]
  769. FunctionCall[120:12->120:29]
  770. Name[120:12->120:17]
  771. perror
  772. StringLiteral[120:19->120:27]
  773. "syscall"
  774. ReturnStatement[121:12->121:20]
  775. NumericLiteral[121:19->121:19]
  776. 1
  777. IfStatement[123:8->128:8]
  778. Predicate:
  779. BinaryExpression[123:12->123:87]
  780. FunctionCall[123:12->123:56]
  781. Name[123:12->123:18]
  782. waitpid
  783. Name[123:20->123:24]
  784. g_pid
  785. UnaryExpression[123:27->123:33]
  786. &
  787. Name[123:28->123:33]
  788. status
  789. BinaryExpression[123:36->123:53]
  790. Name[123:36->123:43]
  791. WSTOPPED
  792. |
  793. Name[123:47->123:53]
  794. WEXITED
  795. !=
  796. BinaryExpression[123:59->123:87]
  797. Name[123:59->123:63]
  798. g_pid
  799. ||
  800. UnaryExpression[123:68->123:87]
  801. !
  802. FunctionCall[123:69->123:87]
  803. Name[123:69->123:78]
  804. WIFSTOPPED
  805. Name[123:80->123:85]
  806. status
  807. Then:
  808. BlockStatement[123:89->128:8]
  809. FunctionCall[124:12->124:30]
  810. Name[124:12->124:17]
  811. perror
  812. StringLiteral[124:19->124:28]
  813. "wait_pid"
  814. ReturnStatement[125:12->125:20]
  815. NumericLiteral[125:19->125:19]
  816. 1
  817. IfStatement[128:8->133:8]
  818. Predicate:
  819. BinaryExpression[128:12->128:52]
  820. FunctionCall[128:12->128:48]
  821. Name[128:12->128:17]
  822. ptrace
  823. Name[128:19->128:28]
  824. PT_GETREGS
  825. Name[128:31->128:35]
  826. g_pid
  827. UnaryExpression[128:38->128:42]
  828. &
  829. Name[128:39->128:42]
  830. regs
  831. NumericLiteral[128:45->128:45]
  832. 0
  833. ==
  834. UnaryExpression[128:51->128:52]
  835. -
  836. NumericLiteral[128:52->128:52]
  837. 1
  838. Then:
  839. BlockStatement[128:55->133:8]
  840. FunctionCall[129:12->129:29]
  841. Name[129:12->129:17]
  842. perror
  843. StringLiteral[129:19->129:27]
  844. "getregs"
  845. ReturnStatement[130:12->130:20]
  846. NumericLiteral[130:19->130:19]
  847. 1
  848. VariableDeclaration[133:8->133:26]
  849. NamedType[133:8->133:10]
  850. u32
  851. res
  852. MemberExpression[133:18->133:26]
  853. Name[133:18->133:21]
  854. regs
  855. Identifier[133:23->133:25]
  856. eax
  857. VariableDeclaration[135:8->140:16]
  858. NamedType[135:8->135:11]
  859. auto
  860. string
  861. FunctionCall[135:22->140:16]
  862. Name[135:22->135:38]
  863. String::formatted
  864. StringLiteral[135:40->135:77]
  865. "{}({:#08x}, {:#08x}, {:#08x})\t={}\n"
  866. FunctionCall[136:12->136:64]
  867. Name[136:12->136:29]
  868. Syscall::to_string
  869. CStyleCastExpression[136:31->136:63]
  870. NamedType[136:32->136:48]
  871. Syscall::Function
  872. Name[136:50->136:62]
  873. syscall_index
  874. Name[137:12->137:15]
  875. arg1
  876. Name[138:12->138:15]
  877. arg2
  878. Name[139:12->139:15]
  879. arg3
  880. Name[140:12->140:14]
  881. res
  882. VariableDeclaration[142:8->142:53]
  883. NamedType[142:8->142:11]
  884. auto
  885. result
  886. BinaryExpression[142:22->142:53]
  887. Name[142:22->142:31]
  888. trace_file
  889. ->
  890. FunctionCall[142:34->142:53]
  891. Name[142:34->142:44]
  892. write_value
  893. Name[142:46->142:51]
  894. string
  895. IfStatement[143:8->147:4]
  896. Predicate:
  897. FunctionCall[143:12->143:29]
  898. MemberExpression[143:12->143:27]
  899. Name[143:12->143:17]
  900. result
  901. Identifier[143:19->143:26]
  902. is_error
  903. Then:
  904. BlockStatement[143:31->147:4]
  905. FunctionCall[144:12->144:48]
  906. Name[144:12->144:17]
  907. warnln
  908. StringLiteral[144:19->144:29]
  909. "write: {}"
  910. BinaryExpression[144:32->144:47]
  911. Name[144:32->144:37]
  912. result
  913. ->
  914. FunctionCall[144:40->144:47]
  915. Name[144:40->144:44]
  916. error
  917. ReturnStatement[145:12->145:20]
  918. NumericLiteral[145:19->145:19]
  919. 1
  920. ReturnStatement[149:4->149:12]
  921. NumericLiteral[149:11->149:11]
  922. 0
  923. }