summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorCameron Youell <cameronyouell@gmail.com>2023-03-27 00:37:51 +0000
committerAndrew Kaster <andrewdkaster@gmail.com>2023-04-09 20:58:54 -0600
commit03008ec4e0250d7ad8f2ed8db828536347c59738 (patch)
treea81e6d80446b21b58732817b56ecf72fe23bf53f /Userland
parent1c54c8a01cc64489faa007c502ab96f11482ee17 (diff)
downloadserenity-03008ec4e0250d7ad8f2ed8db828536347c59738.zip
Tests: Use `FileSystem` instead of `DeprecatedFile`
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCpp/Tests/parser/strace.ast936
-rw-r--r--Userland/Libraries/LibCpp/Tests/parser/strace.cpp16
2 files changed, 501 insertions, 451 deletions
diff --git a/Userland/Libraries/LibCpp/Tests/parser/strace.ast b/Userland/Libraries/LibCpp/Tests/parser/strace.ast
index 91c7265c86..2d36ac0ba7 100644
--- a/Userland/Libraries/LibCpp/Tests/parser/strace.ast
+++ b/Userland/Libraries/LibCpp/Tests/parser/strace.ast
@@ -1,4 +1,4 @@
-TranslationUnit[0:0->144:0]
+TranslationUnit[0:0->150:0]
VariableDeclaration[0:0->2:0]
NamedType[0:0->0:9]
[static] int
@@ -58,7 +58,7 @@ TranslationUnit[0:0->144:0]
StringLiteral[8:15->8:22]
"detach"
}
- FunctionDeclaration[12:0->144:0]
+ FunctionDeclaration[12:0->150:0]
NamedType[12:0->12:2]
int
main
@@ -74,7 +74,7 @@ TranslationUnit[0:0->144:0]
NamedType[12:19->12:23]
char
)
- FunctionDefinition[13:0->144:0]
+ FunctionDefinition[13:0->150:0]
{
IfStatement[14:4->19:4]
Predicate:
@@ -108,772 +108,816 @@ TranslationUnit[0:0->144:0]
[const] char
output_filename
NullPointerLiteral[21:34->21:40]
- VariableDeclaration[22:4->22:60]
+ VariableDeclaration[22:4->22:59]
NamedType[22:4->22:7]
auto
+ trace_file_or_error
+ FunctionCall[22:31->22:59]
+ Name[22:31->22:56]
+ Core::File::standard_error
+ IfStatement[23:4->27:4]
+ Predicate:
+ FunctionCall[23:8->23:38]
+ MemberExpression[23:8->23:36]
+ Name[23:8->23:26]
+ trace_file_or_error
+ Identifier[23:28->23:35]
+ is_error
+ Then:
+ BlockStatement[23:40->27:4]
+ FunctionCall[24:8->24:79]
+ Name[24:8->24:12]
+ outln
+ Name[24:14->24:19]
+ stderr
+ StringLiteral[24:22->24:48]
+ "Failed to open stderr: {}"
+ FunctionCall[24:51->24:78]
+ MemberExpression[24:51->24:76]
+ Name[24:51->24:69]
+ trace_file_or_error
+ Identifier[24:71->24:75]
+ error
+ ReturnStatement[25:8->25:16]
+ NumericLiteral[25:15->25:15]
+ 1
+ VariableDeclaration[27:4->27:57]
+ NamedType[27:4->27:7]
+ auto
trace_file
- FunctionCall[22:22->22:60]
- Name[22:22->22:57]
- Core::DeprecatedFile::standard_error
- VariableDeclaration[24:4->24:27]
- NamedType[24:4->24:19]
+ FunctionCall[27:22->27:57]
+ MemberExpression[27:22->27:55]
+ Name[27:22->27:40]
+ trace_file_or_error
+ Identifier[27:42->27:54]
+ release_value
+ VariableDeclaration[29:4->29:27]
+ NamedType[29:4->29:19]
Core::ArgsParser
parser
- FunctionCall[25:4->26:47]
- MemberExpression[25:4->25:27]
- Name[25:4->25:9]
+ FunctionCall[30:4->31:47]
+ MemberExpression[30:4->30:27]
+ Name[30:4->30:9]
parser
- Identifier[25:11->25:26]
+ Identifier[30:11->30:26]
set_general_help
- StringLiteral[26:8->26:45]
+ StringLiteral[31:8->31:45]
"Trace all syscalls and their result."
- FunctionCall[27:4->27:70]
- MemberExpression[27:4->27:21]
- Name[27:4->27:9]
+ FunctionCall[32:4->32:70]
+ MemberExpression[32:4->32:21]
+ Name[32:4->32:9]
parser
- Identifier[27:11->27:20]
+ Identifier[32:11->32:20]
add_option
- Name[27:22->27:26]
+ Name[32:22->32:26]
g_pid
- StringLiteral[27:29->27:49]
+ StringLiteral[32:29->32:49]
"Trace the given PID"
- StringLiteral[27:52->27:56]
+ StringLiteral[32:52->32:56]
"pid"
- StringLiteral[27:59->27:61]
+ StringLiteral[32:59->32:61]
'p'
- StringLiteral[27:64->27:68]
+ StringLiteral[32:64->32:68]
"pid"
- FunctionCall[28:4->28:94]
- MemberExpression[28:4->28:21]
- Name[28:4->28:9]
+ FunctionCall[33:4->33:94]
+ MemberExpression[33:4->33:21]
+ Name[33:4->33:9]
parser
- Identifier[28:11->28:20]
+ Identifier[33:11->33:20]
add_option
- Name[28:22->28:36]
+ Name[33:22->33:36]
output_filename
- StringLiteral[28:39->28:67]
+ StringLiteral[33:39->33:67]
"Filename to write output to"
- StringLiteral[28:70->28:77]
+ StringLiteral[33:70->33:77]
"output"
- StringLiteral[28:80->28:82]
+ StringLiteral[33:80->33:82]
'o'
- StringLiteral[28:85->28:92]
+ StringLiteral[33:85->33:92]
"output"
- FunctionCall[29:4->29:111]
- MemberExpression[29:4->29:34]
- Name[29:4->29:9]
+ FunctionCall[34:4->34:111]
+ MemberExpression[34:4->34:34]
+ Name[34:4->34:9]
parser
- Identifier[29:11->29:33]
+ Identifier[34:11->34:33]
add_positional_argument
- Name[29:35->29:44]
+ Name[34:35->34:44]
child_argv
- StringLiteral[29:47->29:65]
+ StringLiteral[34:47->34:65]
"Arguments to exec"
- StringLiteral[29:68->29:77]
+ StringLiteral[34:68->34:77]
"argument"
- Name[29:80->29:109]
+ Name[34:80->34:109]
Core::ArgsParser::Required::No
- FunctionCall[31:4->31:28]
- MemberExpression[31:4->31:16]
- Name[31:4->31:9]
+ FunctionCall[36:4->36:28]
+ MemberExpression[36:4->36:16]
+ Name[36:4->36:9]
parser
- Identifier[31:11->31:15]
+ Identifier[36:11->36:15]
parse
- Name[31:17->31:20]
+ Name[36:17->36:20]
argc
- Name[31:23->31:26]
+ Name[36:23->36:26]
argv
- IfStatement[33:4->42:4]
+ IfStatement[38:4->47:4]
Predicate:
- BinaryExpression[33:8->33:33]
- Name[33:8->33:22]
+ BinaryExpression[38:8->38:33]
+ Name[38:8->38:22]
output_filename
!=
- NullPointerLiteral[33:27->33:33]
+ NullPointerLiteral[38:27->38:33]
Then:
- BlockStatement[33:36->42:4]
- VariableDeclaration[34:8->34:97]
- NamedType[34:8->34:11]
+ BlockStatement[38:36->47:4]
+ VariableDeclaration[39:8->39:89]
+ NamedType[39:8->39:11]
auto
open_result
- FunctionCall[34:27->34:97]
- Name[34:27->34:52]
- Core::DeprecatedFile::open
- Name[34:54->34:68]
+ FunctionCall[39:27->39:89]
+ Name[39:27->39:42]
+ Core::File::open
+ Name[39:44->39:58]
output_filename
- Name[34:71->34:95]
- Core::OpenMode::WriteOnly
- IfStatement[35:8->39:8]
+ Name[39:61->39:87]
+ Core::File::OpenMode::Write
+ IfStatement[40:8->44:8]
Predicate:
- FunctionCall[35:12->35:34]
- MemberExpression[35:12->35:32]
- Name[35:12->35:22]
+ FunctionCall[40:12->40:34]
+ MemberExpression[40:12->40:32]
+ Name[40:12->40:22]
open_result
- Identifier[35:24->35:31]
+ Identifier[40:24->40:31]
is_error
Then:
- BlockStatement[35:36->39:8]
- FunctionCall[36:12->36:80]
- Name[36:12->36:16]
+ BlockStatement[40:36->44:8]
+ FunctionCall[41:12->41:80]
+ Name[41:12->41:16]
outln
- Name[36:18->36:23]
+ Name[41:18->41:23]
stderr
- StringLiteral[36:26->36:57]
+ StringLiteral[41:26->41:57]
"Failed to open output file: {}"
- FunctionCall[36:60->36:79]
- MemberExpression[36:60->36:77]
- Name[36:60->36:70]
+ FunctionCall[41:60->41:79]
+ MemberExpression[41:60->41:77]
+ Name[41:60->41:70]
open_result
- Identifier[36:72->36:76]
+ Identifier[41:72->41:76]
error
- ReturnStatement[37:12->37:20]
- NumericLiteral[37:19->37:19]
+ ReturnStatement[42:12->42:20]
+ NumericLiteral[42:19->42:19]
1
- AssignmentExpression[39:8->39:40]
- Name[39:8->39:17]
+ AssignmentExpression[44:8->44:48]
+ Name[44:8->44:17]
trace_file
=
- FunctionCall[39:21->39:40]
- MemberExpression[39:21->39:38]
- Name[39:21->39:31]
+ FunctionCall[44:21->44:48]
+ MemberExpression[44:21->44:46]
+ Name[44:21->44:31]
open_result
- Identifier[39:33->39:37]
- value
- IfStatement[42:4->47:4]
+ Identifier[44:33->44:45]
+ release_value
+ IfStatement[47:4->52:4]
Predicate:
- BinaryExpression[42:8->42:62]
- FunctionCall[42:8->42:60]
- Name[42:8->42:13]
+ BinaryExpression[47:8->47:62]
+ FunctionCall[47:8->47:60]
+ Name[47:8->47:13]
pledge
- StringLiteral[42:15->42:48]
+ StringLiteral[47:15->47:48]
"stdio proc exec ptrace sigaction"
- NullPointerLiteral[42:51->42:57]
+ NullPointerLiteral[47:51->47:57]
<
- NumericLiteral[42:62->42:62]
+ NumericLiteral[47:62->47:62]
0
Then:
- BlockStatement[42:65->47:4]
- FunctionCall[43:8->43:24]
- Name[43:8->43:13]
+ BlockStatement[47:65->52:4]
+ FunctionCall[48:8->48:24]
+ Name[48:8->48:13]
perror
- StringLiteral[43:15->43:22]
+ StringLiteral[48:15->48:22]
"pledge"
- ReturnStatement[44:8->44:16]
- NumericLiteral[44:15->44:15]
+ ReturnStatement[49:8->49:16]
+ NumericLiteral[49:15->49:15]
1
- VariableDeclaration[47:4->47:14]
- NamedType[47:4->47:6]
+ VariableDeclaration[52:4->52:14]
+ NamedType[52:4->52:6]
int
status
- IfStatement[48:4->81:4]
+ IfStatement[53:4->86:4]
Predicate:
- BinaryExpression[48:8->48:18]
- Name[48:8->48:12]
+ BinaryExpression[53:8->53:18]
+ Name[53:8->53:12]
g_pid
==
- UnaryExpression[48:17->48:18]
+ UnaryExpression[53:17->53:18]
-
- NumericLiteral[48:18->48:18]
+ NumericLiteral[53:18->53:18]
1
Then:
- BlockStatement[48:21->81:4]
- IfStatement[49:8->54:8]
+ BlockStatement[53:21->86:4]
+ IfStatement[54:8->59:8]
Predicate:
- FunctionCall[49:12->49:33]
- MemberExpression[49:12->49:31]
- Name[49:12->49:21]
+ FunctionCall[54:12->54:33]
+ MemberExpression[54:12->54:31]
+ Name[54:12->54:21]
child_argv
- Identifier[49:23->49:30]
+ Identifier[54:23->54:30]
is_empty
Then:
- BlockStatement[49:35->54:8]
- FunctionCall[50:12->50:78]
- Name[50:12->50:16]
+ BlockStatement[54:35->59:8]
+ FunctionCall[55:12->55:78]
+ Name[55:12->55:16]
outln
- Name[50:18->50:23]
+ Name[55:18->55:23]
stderr
- StringLiteral[50:26->50:76]
+ StringLiteral[55:26->55:76]
"strace: Expected either a pid or some arguments\n"
- ReturnStatement[51:12->51:20]
- NumericLiteral[51:19->51:19]
+ ReturnStatement[56:12->56:20]
+ NumericLiteral[56:19->56:19]
1
- FunctionCall[54:8->54:34]
- MemberExpression[54:8->54:25]
- Name[54:8->54:17]
+ FunctionCall[59:8->59:34]
+ MemberExpression[59:8->59:25]
+ Name[59:8->59:17]
child_argv
- Identifier[54:19->54:24]
+ Identifier[59:19->59:24]
append
- NullPointerLiteral[54:26->54:32]
- VariableDeclaration[55:8->55:24]
- NamedType[55:8->55:10]
+ NullPointerLiteral[59:26->59:32]
+ VariableDeclaration[60:8->60:24]
+ NamedType[60:8->60:10]
int
pid
- FunctionCall[55:18->55:24]
- Name[55:18->55:21]
+ FunctionCall[60:18->60:24]
+ Name[60:18->60:21]
fork
- IfStatement[56:8->61:8]
+ IfStatement[61:8->66:8]
Predicate:
- BinaryExpression[56:12->56:18]
- Name[56:12->56:14]
+ BinaryExpression[61:12->61:18]
+ Name[61:12->61:14]
pid
<
- NumericLiteral[56:18->56:18]
+ NumericLiteral[61:18->61:18]
0
Then:
- BlockStatement[56:21->61:8]
- FunctionCall[57:12->57:26]
- Name[57:12->57:17]
+ BlockStatement[61:21->66:8]
+ FunctionCall[62:12->62:26]
+ Name[62:12->62:17]
perror
- StringLiteral[57:19->57:24]
+ StringLiteral[62:19->62:24]
"fork"
- ReturnStatement[58:12->58:20]
- NumericLiteral[58:19->58:19]
+ ReturnStatement[63:12->63:20]
+ NumericLiteral[63:19->63:19]
1
- IfStatement[61:8->74:8]
+ IfStatement[66:8->79:8]
Predicate:
- UnaryExpression[61:12->61:15]
+ UnaryExpression[66:12->66:15]
!
- Name[61:13->61:15]
+ Name[66:13->66:15]
pid
Then:
- BlockStatement[61:18->74:8]
- IfStatement[62:12->66:12]
+ BlockStatement[66:18->79:8]
+ IfStatement[67:12->71:12]
Predicate:
- BinaryExpression[62:16->62:49]
- FunctionCall[62:16->62:45]
- Name[62:16->62:21]
+ BinaryExpression[67:16->67:49]
+ FunctionCall[67:16->67:45]
+ Name[67:16->67:21]
ptrace
- Name[62:23->62:33]
+ Name[67:23->67:33]
PT_TRACE_ME
- NumericLiteral[62:36->62:36]
+ NumericLiteral[67:36->67:36]
0
- NumericLiteral[62:39->62:39]
+ NumericLiteral[67:39->67:39]
0
- NumericLiteral[62:42->62:42]
+ NumericLiteral[67:42->67:42]
0
==
- UnaryExpression[62:48->62:49]
+ UnaryExpression[67:48->67:49]
-
- NumericLiteral[62:49->62:49]
+ NumericLiteral[67:49->67:49]
1
Then:
- BlockStatement[62:52->66:12]
- FunctionCall[63:16->63:33]
- Name[63:16->63:21]
+ BlockStatement[67:52->71:12]
+ FunctionCall[68:16->68:33]
+ Name[68:16->68:21]
perror
- StringLiteral[63:23->63:31]
+ StringLiteral[68:23->68:31]
"traceme"
- ReturnStatement[64:16->64:24]
- NumericLiteral[64:23->64:23]
+ ReturnStatement[69:16->69:24]
+ NumericLiteral[69:23->69:23]
1
- VariableDeclaration[66:12->66:86]
- NamedType[66:12->66:14]
+ VariableDeclaration[71:12->71:86]
+ NamedType[71:12->71:14]
int
rc
- FunctionCall[66:21->66:86]
- Name[66:21->66:26]
+ FunctionCall[71:21->71:86]
+ Name[71:21->71:26]
execvp
- FunctionCall[66:28->66:46]
- MemberExpression[66:28->66:44]
- Name[66:28->66:37]
+ FunctionCall[71:28->71:46]
+ MemberExpression[71:28->71:44]
+ Name[71:28->71:37]
child_argv
- Identifier[66:39->66:43]
+ Identifier[71:39->71:43]
first
- CppCastExpression[66:48->66:85]
+ CppCastExpression[71:48->71:85]
const_cast
<
- Pointer[66:59->66:64]
- Pointer[66:59->66:64]
- NamedType[66:59->66:63]
+ Pointer[71:59->71:64]
+ Pointer[71:59->71:64]
+ NamedType[71:59->71:63]
char
>
- FunctionCall[66:67->66:84]
- MemberExpression[66:67->66:82]
- Name[66:67->66:76]
+ FunctionCall[71:67->71:84]
+ MemberExpression[71:67->71:82]
+ Name[71:67->71:76]
child_argv
- Identifier[66:78->66:81]
+ Identifier[71:78->71:81]
data
- IfStatement[67:12->71:12]
+ IfStatement[72:12->76:12]
Predicate:
- BinaryExpression[67:16->67:21]
- Name[67:16->67:17]
+ BinaryExpression[72:16->72:21]
+ Name[72:16->72:17]
rc
<
- NumericLiteral[67:21->67:21]
+ NumericLiteral[72:21->72:21]
0
Then:
- BlockStatement[67:24->71:12]
- FunctionCall[68:16->68:32]
- Name[68:16->68:21]
+ BlockStatement[72:24->76:12]
+ FunctionCall[73:16->73:32]
+ Name[73:16->73:21]
perror
- StringLiteral[68:23->68:30]
+ StringLiteral[73:23->73:30]
"execvp"
- FunctionCall[69:16->69:23]
- Name[69:16->69:19]
+ FunctionCall[74:16->74:23]
+ Name[74:16->74:19]
exit
- NumericLiteral[69:21->69:21]
+ NumericLiteral[74:21->74:21]
1
- FunctionCall[71:12->71:32]
- Name[71:12->71:29]
+ FunctionCall[76:12->76:32]
+ Name[76:12->76:29]
VERIFY_NOT_REACHED
- AssignmentExpression[74:8->74:18]
- Name[74:8->74:12]
+ AssignmentExpression[79:8->79:18]
+ Name[79:8->79:12]
g_pid
=
- Name[74:16->74:18]
+ Name[79:16->79:18]
pid
- IfStatement[75:8->79:4]
+ IfStatement[80:8->84:4]
Predicate:
- BinaryExpression[75:12->75:83]
- FunctionCall[75:12->75:54]
- Name[75:12->75:18]
+ BinaryExpression[80:12->80:83]
+ FunctionCall[80:12->80:54]
+ Name[80:12->80:18]
waitpid
- Name[75:20->75:22]
+ Name[80:20->80:22]
pid
- UnaryExpression[75:25->75:31]
+ UnaryExpression[80:25->80:31]
&
- Name[75:26->75:31]
+ Name[80:26->80:31]
status
- BinaryExpression[75:34->75:51]
- Name[75:34->75:41]
+ BinaryExpression[80:34->80:51]
+ Name[80:34->80:41]
WSTOPPED
|
- Name[75:45->75:51]
+ Name[80:45->80:51]
WEXITED
!=
- BinaryExpression[75:57->75:83]
- Name[75:57->75:59]
+ BinaryExpression[80:57->80:83]
+ Name[80:57->80:59]
pid
||
- UnaryExpression[75:64->75:83]
+ UnaryExpression[80:64->80:83]
!
- FunctionCall[75:65->75:83]
- Name[75:65->75:74]
+ FunctionCall[80:65->80:83]
+ Name[80:65->80:74]
WIFSTOPPED
- Name[75:76->75:81]
+ Name[80:76->80:81]
status
Then:
- BlockStatement[75:85->79:4]
- FunctionCall[76:12->76:29]
- Name[76:12->76:17]
+ BlockStatement[80:85->84:4]
+ FunctionCall[81:12->81:29]
+ Name[81:12->81:17]
perror
- StringLiteral[76:19->76:27]
+ StringLiteral[81:19->81:27]
"waitpid"
- ReturnStatement[77:12->77:20]
- NumericLiteral[77:19->77:19]
+ ReturnStatement[82:12->82:20]
+ NumericLiteral[82:19->82:19]
1
- VariableDeclaration[81:4->81:23]
- NamedType[81:4->81:19]
+ VariableDeclaration[86:4->86:23]
+ NamedType[86:4->86:19]
sigaction
sa
- FunctionCall[82:4->82:44]
- Name[82:4->82:9]
+ FunctionCall[87:4->87:44]
+ Name[87:4->87:9]
memset
- UnaryExpression[82:11->82:13]
+ UnaryExpression[87:11->87:13]
&
- Name[82:12->82:13]
+ Name[87:12->87:13]
sa
- NumericLiteral[82:16->82:16]
+ NumericLiteral[87:16->87:16]
0
- SizeofExpression[82:19->82:43]
- NamedType[82:26->82:41]
+ SizeofExpression[87:19->87:43]
+ NamedType[87:26->87:41]
sigaction
- AssignmentExpression[83:4->83:32]
- MemberExpression[83:4->83:18]
- Name[83:4->83:5]
+ AssignmentExpression[88:4->88:32]
+ MemberExpression[88:4->88:18]
+ Name[88:4->88:5]
sa
- Identifier[83:7->83:16]
+ Identifier[88:7->88:16]
sa_handler
=
- Name[83:20->83:32]
+ Name[88:20->88:32]
handle_sigint
- FunctionCall[84:4->84:35]
- Name[84:4->84:12]
+ FunctionCall[89:4->89:35]
+ Name[89:4->89:12]
sigaction
- Name[84:14->84:19]
+ Name[89:14->89:19]
SIGINT
- UnaryExpression[84:22->84:24]
+ UnaryExpression[89:22->89:24]
&
- Name[84:23->84:24]
+ Name[89:23->89:24]
sa
- NullPointerLiteral[84:27->84:33]
- IfStatement[86:4->90:4]
+ NullPointerLiteral[89:27->89:33]
+ IfStatement[91:4->95:4]
Predicate:
- BinaryExpression[86:8->86:43]
- FunctionCall[86:8->86:39]
- Name[86:8->86:13]
+ BinaryExpression[91:8->91:43]
+ FunctionCall[91:8->91:39]
+ Name[91:8->91:13]
ptrace
- Name[86:15->86:23]
+ Name[91:15->91:23]
PT_ATTACH
- Name[86:26->86:30]
+ Name[91:26->91:30]
g_pid
- NumericLiteral[86:33->86:33]
+ NumericLiteral[91:33->91:33]
0
- NumericLiteral[86:36->86:36]
+ NumericLiteral[91:36->91:36]
0
==
- UnaryExpression[86:42->86:43]
+ UnaryExpression[91:42->91:43]
-
- NumericLiteral[86:43->86:43]
+ NumericLiteral[91:43->91:43]
1
Then:
- BlockStatement[86:46->90:4]
- FunctionCall[87:8->87:24]
- Name[87:8->87:13]
+ BlockStatement[91:46->95:4]
+ FunctionCall[92:8->92:24]
+ Name[92:8->92:13]
perror
- StringLiteral[87:15->87:22]
+ StringLiteral[92:15->92:22]
"attach"
- ReturnStatement[88:8->88:16]
- NumericLiteral[88:15->88:15]
+ ReturnStatement[93:8->93:16]
+ NumericLiteral[93:15->93:15]
1
- IfStatement[90:4->95:4]
+ IfStatement[95:4->100:4]
Predicate:
- BinaryExpression[90:8->90:83]
- FunctionCall[90:8->90:52]
- Name[90:8->90:14]
+ BinaryExpression[95:8->95:83]
+ FunctionCall[95:8->95:52]
+ Name[95:8->95:14]
waitpid
- Name[90:16->90:20]
+ Name[95:16->95:20]
g_pid
- UnaryExpression[90:23->90:29]
+ UnaryExpression[95:23->95:29]
&
- Name[90:24->90:29]
+ Name[95:24->95:29]
status
- BinaryExpression[90:32->90:49]
- Name[90:32->90:39]
+ BinaryExpression[95:32->95:49]
+ Name[95:32->95:39]
WSTOPPED
|
- Name[90:43->90:49]
+ Name[95:43->95:49]
WEXITED
!=
- BinaryExpression[90:55->90:83]
- Name[90:55->90:59]
+ BinaryExpression[95:55->95:83]
+ Name[95:55->95:59]
g_pid
||
- UnaryExpression[90:64->90:83]
+ UnaryExpression[95:64->95:83]
!
- FunctionCall[90:65->90:83]
- Name[90:65->90:74]
+ FunctionCall[95:65->95:83]
+ Name[95:65->95:74]
WIFSTOPPED
- Name[90:76->90:81]
+ Name[95:76->95:81]
status
Then:
- BlockStatement[90:85->95:4]
- FunctionCall[91:8->91:25]
- Name[91:8->91:13]
+ BlockStatement[95:85->100:4]
+ FunctionCall[96:8->96:25]
+ Name[96:8->96:13]
perror
- StringLiteral[91:15->91:23]
+ StringLiteral[96:15->96:23]
"waitpid"
- ReturnStatement[92:8->92:16]
- NumericLiteral[92:15->92:15]
+ ReturnStatement[97:8->97:16]
+ NumericLiteral[97:15->97:15]
1
- ForStatement[95:4->143:4]
- BlockStatement[95:13->143:4]
- IfStatement[96:8->100:8]
+ ForStatement[100:4->149:4]
+ BlockStatement[100:13->149:4]
+ IfStatement[101:8->105:8]
Predicate:
- BinaryExpression[96:12->96:48]
- FunctionCall[96:12->96:44]
- Name[96:12->96:17]
+ BinaryExpression[101:12->101:48]
+ FunctionCall[101:12->101:44]
+ Name[101:12->101:17]
ptrace
- Name[96:19->96:28]
+ Name[101:19->101:28]
PT_SYSCALL
- Name[96:31->96:35]
+ Name[101:31->101:35]
g_pid
- NumericLiteral[96:38->96:38]
+ NumericLiteral[101:38->101:38]
0
- NumericLiteral[96:41->96:41]
+ NumericLiteral[101:41->101:41]
0
==
- UnaryExpression[96:47->96:48]
+ UnaryExpression[101:47->101:48]
-
- NumericLiteral[96:48->96:48]
+ NumericLiteral[101:48->101:48]
1
Then:
- BlockStatement[96:51->100:8]
- FunctionCall[97:12->97:29]
- Name[97:12->97:17]
+ BlockStatement[101:51->105:8]
+ FunctionCall[102:12->102:29]
+ Name[102:12->102:17]
perror
- StringLiteral[97:19->97:27]
+ StringLiteral[102:19->102:27]
"syscall"
- ReturnStatement[98:12->98:20]
- NumericLiteral[98:19->98:19]
+ ReturnStatement[103:12->103:20]
+ NumericLiteral[103:19->103:19]
1
- IfStatement[100:8->104:8]
+ IfStatement[105:8->109:8]
Predicate:
- BinaryExpression[100:12->100:87]
- FunctionCall[100:12->100:56]
- Name[100:12->100:18]
+ BinaryExpression[105:12->105:87]
+ FunctionCall[105:12->105:56]
+ Name[105:12->105:18]
waitpid
- Name[100:20->100:24]
+ Name[105:20->105:24]
g_pid
- UnaryExpression[100:27->100:33]
+ UnaryExpression[105:27->105:33]
&
- Name[100:28->100:33]
+ Name[105:28->105:33]
status
- BinaryExpression[100:36->100:53]
- Name[100:36->100:43]
+ BinaryExpression[105:36->105:53]
+ Name[105:36->105:43]
WSTOPPED
|
- Name[100:47->100:53]
+ Name[105:47->105:53]
WEXITED
!=
- BinaryExpression[100:59->100:87]
- Name[100:59->100:63]
+ BinaryExpression[105:59->105:87]
+ Name[105:59->105:63]
g_pid
||
- UnaryExpression[100:68->100:87]
+ UnaryExpression[105:68->105:87]
!
- FunctionCall[100:69->100:87]
- Name[100:69->100:78]
+ FunctionCall[105:69->105:87]
+ Name[105:69->105:78]
WIFSTOPPED
- Name[100:80->100:85]
+ Name[105:80->105:85]
status
Then:
- BlockStatement[100:89->104:8]
- FunctionCall[101:12->101:30]
- Name[101:12->101:17]
+ BlockStatement[105:89->109:8]
+ FunctionCall[106:12->106:30]
+ Name[106:12->106:17]
perror
- StringLiteral[101:19->101:28]
+ StringLiteral[106:19->106:28]
"wait_pid"
- ReturnStatement[102:12->102:20]
- NumericLiteral[102:19->102:19]
+ ReturnStatement[107:12->107:20]
+ NumericLiteral[107:19->107:19]
1
- VariableDeclaration[104:8->104:33]
- NamedType[104:8->104:22]
+ VariableDeclaration[109:8->109:33]
+ NamedType[109:8->109:22]
PtraceRegisters
regs
- BracedInitList[104:31->104:33]
- IfStatement[105:8->109:8]
+ BracedInitList[109:31->109:33]
+ IfStatement[110:8->114:8]
Predicate:
- BinaryExpression[105:12->105:52]
- FunctionCall[105:12->105:48]
- Name[105:12->105:17]
+ BinaryExpression[110:12->110:52]
+ FunctionCall[110:12->110:48]
+ Name[110:12->110:17]
ptrace
- Name[105:19->105:28]
+ Name[110:19->110:28]
PT_GETREGS
- Name[105:31->105:35]
+ Name[110:31->110:35]
g_pid
- UnaryExpression[105:38->105:42]
+ UnaryExpression[110:38->110:42]
&
- Name[105:39->105:42]
+ Name[110:39->110:42]
regs
- NumericLiteral[105:45->105:45]
+ NumericLiteral[110:45->110:45]
0
==
- UnaryExpression[105:51->105:52]
+ UnaryExpression[110:51->110:52]
-
- NumericLiteral[105:52->105:52]
+ NumericLiteral[110:52->110:52]
1
Then:
- BlockStatement[105:55->109:8]
- FunctionCall[106:12->106:29]
- Name[106:12->106:17]
+ BlockStatement[110:55->114:8]
+ FunctionCall[111:12->111:29]
+ Name[111:12->111:17]
perror
- StringLiteral[106:19->106:27]
+ StringLiteral[111:19->111:27]
"getregs"
- ReturnStatement[107:12->107:20]
- NumericLiteral[107:19->107:19]
+ ReturnStatement[112:12->112:20]
+ NumericLiteral[112:19->112:19]
1
- VariableDeclaration[109:8->109:36]
- NamedType[109:8->109:10]
+ VariableDeclaration[114:8->114:36]
+ NamedType[114:8->114:10]
u32
syscall_index
- MemberExpression[109:28->109:36]
- Name[109:28->109:31]
+ MemberExpression[114:28->114:36]
+ Name[114:28->114:31]
regs
- Identifier[109:33->109:35]
+ Identifier[114:33->114:35]
eax
- VariableDeclaration[110:8->110:27]
- NamedType[110:8->110:10]
+ VariableDeclaration[115:8->115:27]
+ NamedType[115:8->115:10]
u32
arg1
- MemberExpression[110:19->110:27]
- Name[110:19->110:22]
+ MemberExpression[115:19->115:27]
+ Name[115:19->115:22]
regs
- Identifier[110:24->110:26]
+ Identifier[115:24->115:26]
edx
- VariableDeclaration[111:8->111:27]
- NamedType[111:8->111:10]
+ VariableDeclaration[116:8->116:27]
+ NamedType[116:8->116:10]
u32
arg2
- MemberExpression[111:19->111:27]
- Name[111:19->111:22]
+ MemberExpression[116:19->116:27]
+ Name[116:19->116:22]
regs
- Identifier[111:24->111:26]
+ Identifier[116:24->116:26]
ecx
- VariableDeclaration[112:8->112:27]
- NamedType[112:8->112:10]
+ VariableDeclaration[117:8->117:27]
+ NamedType[117:8->117:10]
u32
arg3
- MemberExpression[112:19->112:27]
- Name[112:19->112:22]
+ MemberExpression[117:19->117:27]
+ Name[117:19->117:22]
regs
- Identifier[112:24->112:26]
+ Identifier[117:24->117:26]
ebx
- IfStatement[114:8->118:8]
+ IfStatement[119:8->123:8]
Predicate:
- BinaryExpression[114:12->114:48]
- FunctionCall[114:12->114:44]
- Name[114:12->114:17]
+ BinaryExpression[119:12->119:48]
+ FunctionCall[119:12->119:44]
+ Name[119:12->119:17]
ptrace
- Name[114:19->114:28]
+ Name[119:19->119:28]
PT_SYSCALL
- Name[114:31->114:35]
+ Name[119:31->119:35]
g_pid
- NumericLiteral[114:38->114:38]
+ NumericLiteral[119:38->119:38]
0
- NumericLiteral[114:41->114:41]
+ NumericLiteral[119:41->119:41]
0
==
- UnaryExpression[114:47->114:48]
+ UnaryExpression[119:47->119:48]
-
- NumericLiteral[114:48->114:48]
+ NumericLiteral[119:48->119:48]
1
Then:
- BlockStatement[114:51->118:8]
- FunctionCall[115:12->115:29]
- Name[115:12->115:17]
+ BlockStatement[119:51->123:8]
+ FunctionCall[120:12->120:29]
+ Name[120:12->120:17]
perror
- StringLiteral[115:19->115:27]
+ StringLiteral[120:19->120:27]
"syscall"
- ReturnStatement[116:12->116:20]
- NumericLiteral[116:19->116:19]
+ ReturnStatement[121:12->121:20]
+ NumericLiteral[121:19->121:19]
1
- IfStatement[118:8->123:8]
+ IfStatement[123:8->128:8]
Predicate:
- BinaryExpression[118:12->118:87]
- FunctionCall[118:12->118:56]
- Name[118:12->118:18]
+ BinaryExpression[123:12->123:87]
+ FunctionCall[123:12->123:56]
+ Name[123:12->123:18]
waitpid
- Name[118:20->118:24]
+ Name[123:20->123:24]
g_pid
- UnaryExpression[118:27->118:33]
+ UnaryExpression[123:27->123:33]
&
- Name[118:28->118:33]
+ Name[123:28->123:33]
status
- BinaryExpression[118:36->118:53]
- Name[118:36->118:43]
+ BinaryExpression[123:36->123:53]
+ Name[123:36->123:43]
WSTOPPED
|
- Name[118:47->118:53]
+ Name[123:47->123:53]
WEXITED
!=
- BinaryExpression[118:59->118:87]
- Name[118:59->118:63]
+ BinaryExpression[123:59->123:87]
+ Name[123:59->123:63]
g_pid
||
- UnaryExpression[118:68->118:87]
+ UnaryExpression[123:68->123:87]
!
- FunctionCall[118:69->118:87]
- Name[118:69->118:78]
+ FunctionCall[123:69->123:87]
+ Name[123:69->123:78]
WIFSTOPPED
- Name[118:80->118:85]
+ Name[123:80->123:85]
status
Then:
- BlockStatement[118:89->123:8]
- FunctionCall[119:12->119:30]
- Name[119:12->119:17]
+ BlockStatement[123:89->128:8]
+ FunctionCall[124:12->124:30]
+ Name[124:12->124:17]
perror
- StringLiteral[119:19->119:28]
+ StringLiteral[124:19->124:28]
"wait_pid"
- ReturnStatement[120:12->120:20]
- NumericLiteral[120:19->120:19]
+ ReturnStatement[125:12->125:20]
+ NumericLiteral[125:19->125:19]
1
- IfStatement[123:8->128:8]
+ IfStatement[128:8->133:8]
Predicate:
- BinaryExpression[123:12->123:52]
- FunctionCall[123:12->123:48]
- Name[123:12->123:17]
+ BinaryExpression[128:12->128:52]
+ FunctionCall[128:12->128:48]
+ Name[128:12->128:17]
ptrace
- Name[123:19->123:28]
+ Name[128:19->128:28]
PT_GETREGS
- Name[123:31->123:35]
+ Name[128:31->128:35]
g_pid
- UnaryExpression[123:38->123:42]
+ UnaryExpression[128:38->128:42]
&
- Name[123:39->123:42]
+ Name[128:39->128:42]
regs
- NumericLiteral[123:45->123:45]
+ NumericLiteral[128:45->128:45]
0
==
- UnaryExpression[123:51->123:52]
+ UnaryExpression[128:51->128:52]
-
- NumericLiteral[123:52->123:52]
+ NumericLiteral[128:52->128:52]
1
Then:
- BlockStatement[123:55->128:8]
- FunctionCall[124:12->124:29]
- Name[124:12->124:17]
+ BlockStatement[128:55->133:8]
+ FunctionCall[129:12->129:29]
+ Name[129:12->129:17]
perror
- StringLiteral[124:19->124:27]
+ StringLiteral[129:19->129:27]
"getregs"
- ReturnStatement[125:12->125:20]
- NumericLiteral[125:19->125:19]
+ ReturnStatement[130:12->130:20]
+ NumericLiteral[130:19->130:19]
1
- VariableDeclaration[128:8->128:26]
- NamedType[128:8->128:10]
+ VariableDeclaration[133:8->133:26]
+ NamedType[133:8->133:10]
u32
res
- MemberExpression[128:18->128:26]
- Name[128:18->128:21]
+ MemberExpression[133:18->133:26]
+ Name[133:18->133:21]
regs
- Identifier[128:23->128:25]
+ Identifier[133:23->133:25]
eax
- VariableDeclaration[130:8->135:16]
- NamedType[130:8->130:11]
+ VariableDeclaration[135:8->140:16]
+ NamedType[135:8->135:11]
auto
string
- FunctionCall[130:22->135:16]
- Name[130:22->130:38]
+ FunctionCall[135:22->140:16]
+ Name[135:22->135:38]
String::formatted
- StringLiteral[130:40->130:77]
+ StringLiteral[135:40->135:77]
"{}({:#08x}, {:#08x}, {:#08x})\t={}\n"
- FunctionCall[131:12->131:64]
- Name[131:12->131:29]
+ FunctionCall[136:12->136:64]
+ Name[136:12->136:29]
Syscall::to_string
- CStyleCastExpression[131:31->131:63]
- NamedType[131:32->131:48]
+ CStyleCastExpression[136:31->136:63]
+ NamedType[136:32->136:48]
Syscall::Function
- Name[131:50->131:62]
+ Name[136:50->136:62]
syscall_index
- Name[132:12->132:15]
+ Name[137:12->137:15]
arg1
- Name[133:12->133:15]
+ Name[138:12->138:15]
arg2
- Name[134:12->134:15]
+ Name[139:12->139:15]
arg3
- Name[135:12->135:14]
+ Name[140:12->140:14]
res
- IfStatement[137:8->141:4]
+ VariableDeclaration[142:8->142:53]
+ NamedType[142:8->142:11]
+ auto
+ result
+ BinaryExpression[142:22->142:53]
+ Name[142:22->142:31]
+ trace_file
+ ->
+ FunctionCall[142:34->142:53]
+ Name[142:34->142:44]
+ write_value
+ Name[142:46->142:51]
+ string
+ IfStatement[143:8->147:4]
Predicate:
- UnaryExpression[137:12->137:38]
- !
- BinaryExpression[137:13->137:38]
- Name[137:13->137:22]
- trace_file
- ->
- FunctionCall[137:25->137:38]
- Name[137:25->137:29]
- write
- Name[137:31->137:36]
- string
+ FunctionCall[143:12->143:29]
+ MemberExpression[143:12->143:27]
+ Name[143:12->143:17]
+ result
+ Identifier[143:19->143:26]
+ is_error
Then:
- BlockStatement[137:40->141:4]
- FunctionCall[138:12->138:59]
- Name[138:12->138:17]
+ BlockStatement[143:31->147:4]
+ FunctionCall[144:12->144:48]
+ Name[144:12->144:17]
warnln
- StringLiteral[138:19->138:29]
+ StringLiteral[144:19->144:29]
"write: {}"
- BinaryExpression[138:32->138:58]
- Name[138:32->138:41]
- trace_file
+ BinaryExpression[144:32->144:47]
+ Name[144:32->144:37]
+ result
->
- FunctionCall[138:44->138:58]
- Name[138:44->138:55]
- error_string
- ReturnStatement[139:12->139:20]
- NumericLiteral[139:19->139:19]
+ FunctionCall[144:40->144:47]
+ Name[144:40->144:44]
+ error
+ ReturnStatement[145:12->145:20]
+ NumericLiteral[145:19->145:19]
1
- ReturnStatement[143:4->143:12]
- NumericLiteral[143:11->143:11]
+ ReturnStatement[149:4->149:12]
+ NumericLiteral[149:11->149:11]
0
}
diff --git a/Userland/Libraries/LibCpp/Tests/parser/strace.cpp b/Userland/Libraries/LibCpp/Tests/parser/strace.cpp
index b7f1c2d6d1..c005e67a8a 100644
--- a/Userland/Libraries/LibCpp/Tests/parser/strace.cpp
+++ b/Userland/Libraries/LibCpp/Tests/parser/strace.cpp
@@ -20,7 +20,12 @@ int main(int argc, char** argv)
Vector<const char*> child_argv;
const char* output_filename = nullptr;
- auto trace_file = Core::DeprecatedFile::standard_error();
+ auto trace_file_or_error = Core::File::standard_error();
+ if (trace_file_or_error.is_error()) {
+ outln(stderr, "Failed to open stderr: {}", trace_file_or_error.error());
+ return 1;
+ }
+ auto trace_file = trace_file_or_error.release_value();
Core::ArgsParser parser;
parser.set_general_help(
@@ -32,12 +37,12 @@ int main(int argc, char** argv)
parser.parse(argc, argv);
if (output_filename != nullptr) {
- auto open_result = Core::DeprecatedFile::open(output_filename, Core::OpenMode::WriteOnly);
+ auto open_result = Core::File::open(output_filename, Core::File::OpenMode::Write);
if (open_result.is_error()) {
outln(stderr, "Failed to open output file: {}", open_result.error());
return 1;
}
- trace_file = open_result.value();
+ trace_file = open_result.release_value();
}
if (pledge("stdio proc exec ptrace sigaction", nullptr) < 0) {
@@ -135,8 +140,9 @@ int main(int argc, char** argv)
arg3,
res);
- if (!trace_file->write(string)) {
- warnln("write: {}", trace_file->error_string());
+ auto result = trace_file->write_value(string);
+ if (result.is_error()) {
+ warnln("write: {}", result->error());
return 1;
}
}