@@ -111,18 +111,104 @@ inline int64_t GetOffset(Local<Value> value) {
111
111
return IsSafeJsInt (value) ? value.As <Integer>()->Value () : -1 ;
112
112
}
113
113
114
+ static const char * get_fs_func_name_by_type (uv_fs_type req_type) {
115
+ switch (req_type) {
116
+ #define FS_TYPE_TO_NAME (type, name ) \
117
+ case UV_FS_##type: \
118
+ return name;
119
+ FS_TYPE_TO_NAME (OPEN, " open" )
120
+ FS_TYPE_TO_NAME (CLOSE, " close" )
121
+ FS_TYPE_TO_NAME (READ, " read" )
122
+ FS_TYPE_TO_NAME (WRITE, " write" )
123
+ FS_TYPE_TO_NAME (SENDFILE, " sendfile" )
124
+ FS_TYPE_TO_NAME (STAT, " stat" )
125
+ FS_TYPE_TO_NAME (LSTAT, " lstat" )
126
+ FS_TYPE_TO_NAME (FSTAT, " fstat" )
127
+ FS_TYPE_TO_NAME (FTRUNCATE, " ftruncate" )
128
+ FS_TYPE_TO_NAME (UTIME, " utime" )
129
+ FS_TYPE_TO_NAME (FUTIME, " futime" )
130
+ FS_TYPE_TO_NAME (ACCESS, " access" )
131
+ FS_TYPE_TO_NAME (CHMOD, " chmod" )
132
+ FS_TYPE_TO_NAME (FCHMOD, " fchmod" )
133
+ FS_TYPE_TO_NAME (FSYNC, " fsync" )
134
+ FS_TYPE_TO_NAME (FDATASYNC, " fdatasync" )
135
+ FS_TYPE_TO_NAME (UNLINK, " unlink" )
136
+ FS_TYPE_TO_NAME (RMDIR, " rmdir" )
137
+ FS_TYPE_TO_NAME (MKDIR, " mkdir" )
138
+ FS_TYPE_TO_NAME (MKDTEMP, " mkdtemp" )
139
+ FS_TYPE_TO_NAME (RENAME, " rename" )
140
+ FS_TYPE_TO_NAME (SCANDIR, " scandir" )
141
+ FS_TYPE_TO_NAME (LINK, " link" )
142
+ FS_TYPE_TO_NAME (SYMLINK, " symlink" )
143
+ FS_TYPE_TO_NAME (READLINK, " readlink" )
144
+ FS_TYPE_TO_NAME (CHOWN, " chown" )
145
+ FS_TYPE_TO_NAME (FCHOWN, " fchown" )
146
+ FS_TYPE_TO_NAME (REALPATH, " realpath" )
147
+ FS_TYPE_TO_NAME (COPYFILE, " copyfile" )
148
+ FS_TYPE_TO_NAME (LCHOWN, " lchown" )
149
+ FS_TYPE_TO_NAME (STATFS, " statfs" )
150
+ FS_TYPE_TO_NAME (MKSTEMP, " mkstemp" )
151
+ FS_TYPE_TO_NAME (LUTIME, " lutime" )
152
+ #undef FS_TYPE_TO_NAME
153
+ default :
154
+ return " unknow" ;
155
+ }
156
+ }
157
+
114
158
#define TRACE_NAME (name ) " fs.sync." #name
115
- #define GET_TRACE_ENABLED \
116
- (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \
117
- (TRACING_CATEGORY_NODE2(fs, sync)) != 0 )
118
- #define FS_SYNC_TRACE_BEGIN (syscall, ...) \
119
- if (GET_TRACE_ENABLED) \
120
- TRACE_EVENT_BEGIN (TRACING_CATEGORY_NODE2(fs, sync), TRACE_NAME(syscall), \
121
- ##__VA_ARGS__);
122
- #define FS_SYNC_TRACE_END (syscall, ...) \
123
- if (GET_TRACE_ENABLED) \
124
- TRACE_EVENT_END (TRACING_CATEGORY_NODE2(fs, sync), TRACE_NAME(syscall), \
125
- ##__VA_ARGS__);
159
+ #define GET_TRACE_ENABLED \
160
+ (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED ( \
161
+ TRACING_CATEGORY_NODE2 (fs, sync)) != 0)
162
+ #define FS_SYNC_TRACE_BEGIN (syscall, ...) \
163
+ if (GET_TRACE_ENABLED) \
164
+ TRACE_EVENT_BEGIN( \
165
+ TRACING_CATEGORY_NODE2 (fs, sync), TRACE_NAME(syscall), ##__VA_ARGS__);
166
+ #define FS_SYNC_TRACE_END (syscall, ...) \
167
+ if (GET_TRACE_ENABLED) \
168
+ TRACE_EVENT_END ( \
169
+ TRACING_CATEGORY_NODE2 (fs, sync), TRACE_NAME(syscall), ##__VA_ARGS__);
170
+
171
+ #define FS_ASYNC_TRACE_BEGIN0 (fs_type, id ) \
172
+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN0 (TRACING_CATEGORY_NODE2(fs, async), \
173
+ get_fs_func_name_by_type (fs_type), \
174
+ id);
175
+
176
+ #define FS_ASYNC_TRACE_END0 (fs_type, id ) \
177
+ TRACE_EVENT_NESTABLE_ASYNC_END0 (TRACING_CATEGORY_NODE2(fs, async), \
178
+ get_fs_func_name_by_type (fs_type), \
179
+ id);
180
+
181
+ #define FS_ASYNC_TRACE_BEGIN1 (fs_type, id, name, value ) \
182
+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN1 (TRACING_CATEGORY_NODE2(fs, async), \
183
+ get_fs_func_name_by_type (fs_type), \
184
+ id, \
185
+ name, \
186
+ value);
187
+
188
+ #define FS_ASYNC_TRACE_END1 (fs_type, id, name, value ) \
189
+ TRACE_EVENT_NESTABLE_ASYNC_END1 (TRACING_CATEGORY_NODE2(fs, async), \
190
+ get_fs_func_name_by_type (fs_type), \
191
+ id, \
192
+ name, \
193
+ value);
194
+
195
+ #define FS_ASYNC_TRACE_BEGIN2 (fs_type, id, name1, value1, name2, value2 ) \
196
+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN2 (TRACING_CATEGORY_NODE2(fs, async), \
197
+ get_fs_func_name_by_type (fs_type), \
198
+ id, \
199
+ name1, \
200
+ value1, \
201
+ name2, \
202
+ value2);
203
+
204
+ #define FS_ASYNC_TRACE_END2 (fs_type, id, name1, value1, name2, value2 ) \
205
+ TRACE_EVENT_NESTABLE_ASYNC_END2 (TRACING_CATEGORY_NODE2(fs, async), \
206
+ get_fs_func_name_by_type (fs_type), \
207
+ id, \
208
+ name1, \
209
+ value1, \
210
+ name2, \
211
+ value2);
126
212
127
213
// We sometimes need to convert a C++ lambda function to a raw C-style function.
128
214
// This is helpful, because ReqWrap::Dispatch() does not recognize lambda
@@ -665,15 +751,17 @@ bool FSReqAfterScope::Proceed() {
665
751
void AfterNoArgs (uv_fs_t * req) {
666
752
FSReqBase* req_wrap = FSReqBase::from_req (req);
667
753
FSReqAfterScope after (req_wrap, req);
668
-
754
+ FS_ASYNC_TRACE_END1 (
755
+ req->fs_type , req_wrap, " result" , static_cast <int >(req->result ))
669
756
if (after.Proceed ())
670
757
req_wrap->Resolve (Undefined (req_wrap->env ()->isolate ()));
671
758
}
672
759
673
760
void AfterStat (uv_fs_t * req) {
674
761
FSReqBase* req_wrap = FSReqBase::from_req (req);
675
762
FSReqAfterScope after (req_wrap, req);
676
-
763
+ FS_ASYNC_TRACE_END1 (
764
+ req->fs_type , req_wrap, " result" , static_cast <int >(req->result ))
677
765
if (after.Proceed ()) {
678
766
req_wrap->ResolveStat (&req->statbuf );
679
767
}
@@ -682,7 +770,8 @@ void AfterStat(uv_fs_t* req) {
682
770
void AfterInteger (uv_fs_t * req) {
683
771
FSReqBase* req_wrap = FSReqBase::from_req (req);
684
772
FSReqAfterScope after (req_wrap, req);
685
-
773
+ FS_ASYNC_TRACE_END1 (
774
+ req->fs_type , req_wrap, " result" , static_cast <int >(req->result ))
686
775
int result = static_cast <int >(req->result );
687
776
if (result >= 0 && req_wrap->is_plain_open ())
688
777
req_wrap->env ()->AddUnmanagedFd (result);
@@ -694,7 +783,8 @@ void AfterInteger(uv_fs_t* req) {
694
783
void AfterOpenFileHandle (uv_fs_t * req) {
695
784
FSReqBase* req_wrap = FSReqBase::from_req (req);
696
785
FSReqAfterScope after (req_wrap, req);
697
-
786
+ FS_ASYNC_TRACE_END1 (
787
+ req->fs_type , req_wrap, " result" , static_cast <int >(req->result ))
698
788
if (after.Proceed ()) {
699
789
FileHandle* fd = FileHandle::New (req_wrap->binding_data (),
700
790
static_cast <int >(req->result ));
@@ -719,6 +809,8 @@ void FromNamespacedPath(std::string* path) {
719
809
void AfterMkdirp (uv_fs_t * req) {
720
810
FSReqBase* req_wrap = FSReqBase::from_req (req);
721
811
FSReqAfterScope after (req_wrap, req);
812
+ FS_ASYNC_TRACE_END1 (
813
+ req->fs_type , req_wrap, " result" , static_cast <int >(req->result ))
722
814
if (after.Proceed ()) {
723
815
std::string first_path (req_wrap->continuation_data ()->first_path ());
724
816
if (first_path.empty ())
@@ -738,7 +830,8 @@ void AfterMkdirp(uv_fs_t* req) {
738
830
void AfterStringPath (uv_fs_t * req) {
739
831
FSReqBase* req_wrap = FSReqBase::from_req (req);
740
832
FSReqAfterScope after (req_wrap, req);
741
-
833
+ FS_ASYNC_TRACE_END1 (
834
+ req->fs_type , req_wrap, " result" , static_cast <int >(req->result ))
742
835
MaybeLocal<Value> link ;
743
836
Local<Value> error;
744
837
@@ -757,7 +850,8 @@ void AfterStringPath(uv_fs_t* req) {
757
850
void AfterStringPtr (uv_fs_t * req) {
758
851
FSReqBase* req_wrap = FSReqBase::from_req (req);
759
852
FSReqAfterScope after (req_wrap, req);
760
-
853
+ FS_ASYNC_TRACE_END1 (
854
+ req->fs_type , req_wrap, " result" , static_cast <int >(req->result ))
761
855
MaybeLocal<Value> link ;
762
856
Local<Value> error;
763
857
@@ -776,7 +870,8 @@ void AfterStringPtr(uv_fs_t* req) {
776
870
void AfterScanDir (uv_fs_t * req) {
777
871
FSReqBase* req_wrap = FSReqBase::from_req (req);
778
872
FSReqAfterScope after (req_wrap, req);
779
-
873
+ FS_ASYNC_TRACE_END1 (
874
+ req->fs_type , req_wrap, " result" , static_cast <int >(req->result ))
780
875
if (!after.Proceed ()) {
781
876
return ;
782
877
}
@@ -837,6 +932,8 @@ void Access(const FunctionCallbackInfo<Value>& args) {
837
932
838
933
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
839
934
if (req_wrap_async != nullptr ) { // access(path, mode, req)
935
+ FS_ASYNC_TRACE_BEGIN1 (
936
+ UV_FS_ACCESS, req_wrap_async, " path" , TRACE_STR_COPY (*path))
840
937
AsyncCall (env, req_wrap_async, args, " access" , UTF8, AfterNoArgs,
841
938
uv_fs_access, *path, mode);
842
939
} else { // access(path, mode, undefined, ctx)
@@ -861,6 +958,7 @@ void Close(const FunctionCallbackInfo<Value>& args) {
861
958
862
959
FSReqBase* req_wrap_async = GetReqWrap (args, 1 );
863
960
if (req_wrap_async != nullptr ) { // close(fd, req)
961
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_CLOSE, req_wrap_async)
864
962
AsyncCall (env, req_wrap_async, args, " close" , UTF8, AfterNoArgs,
865
963
uv_fs_close, fd);
866
964
} else { // close(fd, undefined, ctx)
@@ -1002,6 +1100,8 @@ static void Stat(const FunctionCallbackInfo<Value>& args) {
1002
1100
bool use_bigint = args[1 ]->IsTrue ();
1003
1101
FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
1004
1102
if (req_wrap_async != nullptr ) { // stat(path, use_bigint, req)
1103
+ FS_ASYNC_TRACE_BEGIN1 (
1104
+ UV_FS_STAT, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1005
1105
AsyncCall (env, req_wrap_async, args, " stat" , UTF8, AfterStat,
1006
1106
uv_fs_stat, *path);
1007
1107
} else { // stat(path, use_bigint, undefined, ctx)
@@ -1033,6 +1133,8 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
1033
1133
bool use_bigint = args[1 ]->IsTrue ();
1034
1134
FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
1035
1135
if (req_wrap_async != nullptr ) { // lstat(path, use_bigint, req)
1136
+ FS_ASYNC_TRACE_BEGIN1 (
1137
+ UV_FS_LSTAT, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1036
1138
AsyncCall (env, req_wrap_async, args, " lstat" , UTF8, AfterStat,
1037
1139
uv_fs_lstat, *path);
1038
1140
} else { // lstat(path, use_bigint, undefined, ctx)
@@ -1065,6 +1167,7 @@ static void FStat(const FunctionCallbackInfo<Value>& args) {
1065
1167
bool use_bigint = args[1 ]->IsTrue ();
1066
1168
FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
1067
1169
if (req_wrap_async != nullptr ) { // fstat(fd, use_bigint, req)
1170
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_FSTAT, req_wrap_async)
1068
1171
AsyncCall (env, req_wrap_async, args, " fstat" , UTF8, AfterStat,
1069
1172
uv_fs_fstat, fd);
1070
1173
} else { // fstat(fd, use_bigint, undefined, ctx)
@@ -1100,6 +1203,12 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {
1100
1203
1101
1204
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
1102
1205
if (req_wrap_async != nullptr ) { // symlink(target, path, flags, req)
1206
+ FS_ASYNC_TRACE_BEGIN2 (UV_FS_SYMLINK,
1207
+ req_wrap_async,
1208
+ " target" ,
1209
+ TRACE_STR_COPY (*target),
1210
+ " path" ,
1211
+ TRACE_STR_COPY (*path))
1103
1212
AsyncDestCall (env, req_wrap_async, args, " symlink" , *path, path.length (),
1104
1213
UTF8, AfterNoArgs, uv_fs_symlink, *target, *path, flags);
1105
1214
} else { // symlink(target, path, flags, undefinec, ctx)
@@ -1127,6 +1236,12 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
1127
1236
1128
1237
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
1129
1238
if (req_wrap_async != nullptr ) { // link(src, dest, req)
1239
+ FS_ASYNC_TRACE_BEGIN2 (UV_FS_LINK,
1240
+ req_wrap_async,
1241
+ " src" ,
1242
+ TRACE_STR_COPY (*src),
1243
+ " dest" ,
1244
+ TRACE_STR_COPY (*dest))
1130
1245
AsyncDestCall (env, req_wrap_async, args, " link" , *dest, dest.length (), UTF8,
1131
1246
AfterNoArgs, uv_fs_link, *src, *dest);
1132
1247
} else { // link(src, dest)
@@ -1153,6 +1268,8 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
1153
1268
1154
1269
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
1155
1270
if (req_wrap_async != nullptr ) { // readlink(path, encoding, req)
1271
+ FS_ASYNC_TRACE_BEGIN1 (
1272
+ UV_FS_READLINK, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1156
1273
AsyncCall (env, req_wrap_async, args, " readlink" , encoding, AfterStringPtr,
1157
1274
uv_fs_readlink, *path);
1158
1275
} else {
@@ -1196,6 +1313,12 @@ static void Rename(const FunctionCallbackInfo<Value>& args) {
1196
1313
1197
1314
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
1198
1315
if (req_wrap_async != nullptr ) {
1316
+ FS_ASYNC_TRACE_BEGIN2 (UV_FS_RENAME,
1317
+ req_wrap_async,
1318
+ " old_path" ,
1319
+ TRACE_STR_COPY (*old_path),
1320
+ " new_path" ,
1321
+ TRACE_STR_COPY (*new_path))
1199
1322
AsyncDestCall (env, req_wrap_async, args, " rename" , *new_path,
1200
1323
new_path.length (), UTF8, AfterNoArgs, uv_fs_rename,
1201
1324
*old_path, *new_path);
@@ -1223,6 +1346,7 @@ static void FTruncate(const FunctionCallbackInfo<Value>& args) {
1223
1346
1224
1347
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
1225
1348
if (req_wrap_async != nullptr ) {
1349
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_FTRUNCATE, req_wrap_async)
1226
1350
AsyncCall (env, req_wrap_async, args, " ftruncate" , UTF8, AfterNoArgs,
1227
1351
uv_fs_ftruncate, fd, len);
1228
1352
} else {
@@ -1246,6 +1370,7 @@ static void Fdatasync(const FunctionCallbackInfo<Value>& args) {
1246
1370
1247
1371
FSReqBase* req_wrap_async = GetReqWrap (args, 1 );
1248
1372
if (req_wrap_async != nullptr ) {
1373
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_FDATASYNC, req_wrap_async)
1249
1374
AsyncCall (env, req_wrap_async, args, " fdatasync" , UTF8, AfterNoArgs,
1250
1375
uv_fs_fdatasync, fd);
1251
1376
} else {
@@ -1268,6 +1393,7 @@ static void Fsync(const FunctionCallbackInfo<Value>& args) {
1268
1393
1269
1394
FSReqBase* req_wrap_async = GetReqWrap (args, 1 );
1270
1395
if (req_wrap_async != nullptr ) {
1396
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_FSYNC, req_wrap_async)
1271
1397
AsyncCall (env, req_wrap_async, args, " fsync" , UTF8, AfterNoArgs,
1272
1398
uv_fs_fsync, fd);
1273
1399
} else {
@@ -1290,6 +1416,8 @@ static void Unlink(const FunctionCallbackInfo<Value>& args) {
1290
1416
1291
1417
FSReqBase* req_wrap_async = GetReqWrap (args, 1 );
1292
1418
if (req_wrap_async != nullptr ) {
1419
+ FS_ASYNC_TRACE_BEGIN1 (
1420
+ UV_FS_UNLINK, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1293
1421
AsyncCall (env, req_wrap_async, args, " unlink" , UTF8, AfterNoArgs,
1294
1422
uv_fs_unlink, *path);
1295
1423
} else {
@@ -1312,6 +1440,8 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
1312
1440
1313
1441
FSReqBase* req_wrap_async = GetReqWrap (args, 1 ); // rmdir(path, req)
1314
1442
if (req_wrap_async != nullptr ) {
1443
+ FS_ASYNC_TRACE_BEGIN1 (
1444
+ UV_FS_RMDIR, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1315
1445
AsyncCall (env, req_wrap_async, args, " rmdir" , UTF8, AfterNoArgs,
1316
1446
uv_fs_rmdir, *path);
1317
1447
} else { // rmdir(path, undefined, ctx)
@@ -1523,6 +1653,8 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
1523
1653
1524
1654
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
1525
1655
if (req_wrap_async != nullptr ) { // mkdir(path, mode, req)
1656
+ FS_ASYNC_TRACE_BEGIN1 (
1657
+ UV_FS_UNLINK, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1526
1658
AsyncCall (env, req_wrap_async, args, " mkdir" , UTF8,
1527
1659
mkdirp ? AfterMkdirp : AfterNoArgs,
1528
1660
mkdirp ? MKDirpAsync : uv_fs_mkdir, *path, mode);
@@ -1569,6 +1701,8 @@ static void RealPath(const FunctionCallbackInfo<Value>& args) {
1569
1701
1570
1702
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
1571
1703
if (req_wrap_async != nullptr ) { // realpath(path, encoding, req)
1704
+ FS_ASYNC_TRACE_BEGIN1 (
1705
+ UV_FS_REALPATH, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1572
1706
AsyncCall (env, req_wrap_async, args, " realpath" , encoding, AfterStringPtr,
1573
1707
uv_fs_realpath, *path);
1574
1708
} else { // realpath(path, encoding, undefined, ctx)
@@ -1616,6 +1750,8 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
1616
1750
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
1617
1751
if (req_wrap_async != nullptr ) { // readdir(path, encoding, withTypes, req)
1618
1752
req_wrap_async->set_with_file_types (with_types);
1753
+ FS_ASYNC_TRACE_BEGIN1 (
1754
+ UV_FS_SCANDIR, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1619
1755
AsyncCall (env,
1620
1756
req_wrap_async,
1621
1757
args,
@@ -1707,6 +1843,8 @@ static void Open(const FunctionCallbackInfo<Value>& args) {
1707
1843
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
1708
1844
if (req_wrap_async != nullptr ) { // open(path, flags, mode, req)
1709
1845
req_wrap_async->set_is_plain_open (true );
1846
+ FS_ASYNC_TRACE_BEGIN1 (
1847
+ UV_FS_OPEN, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1710
1848
AsyncCall (env, req_wrap_async, args, " open" , UTF8, AfterInteger,
1711
1849
uv_fs_open, *path, flags, mode);
1712
1850
} else { // open(path, flags, mode, undefined, ctx)
@@ -1740,6 +1878,8 @@ static void OpenFileHandle(const FunctionCallbackInfo<Value>& args) {
1740
1878
1741
1879
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
1742
1880
if (req_wrap_async != nullptr ) { // openFileHandle(path, flags, mode, req)
1881
+ FS_ASYNC_TRACE_BEGIN1 (
1882
+ UV_FS_OPEN, req_wrap_async, " path" , TRACE_STR_COPY (*path))
1743
1883
AsyncCall (env, req_wrap_async, args, " open" , UTF8, AfterOpenFileHandle,
1744
1884
uv_fs_open, *path, flags, mode);
1745
1885
} else { // openFileHandle(path, flags, mode, undefined, ctx)
@@ -1776,6 +1916,12 @@ static void CopyFile(const FunctionCallbackInfo<Value>& args) {
1776
1916
1777
1917
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
1778
1918
if (req_wrap_async != nullptr ) { // copyFile(src, dest, flags, req)
1919
+ FS_ASYNC_TRACE_BEGIN2 (UV_FS_COPYFILE,
1920
+ req_wrap_async,
1921
+ " src" ,
1922
+ TRACE_STR_COPY (*src),
1923
+ " dest" ,
1924
+ TRACE_STR_COPY (*dest))
1779
1925
AsyncDestCall (env, req_wrap_async, args, " copyfile" ,
1780
1926
*dest, dest.length (), UTF8, AfterNoArgs,
1781
1927
uv_fs_copyfile, *src, *dest, flags);
@@ -1832,6 +1978,7 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
1832
1978
1833
1979
FSReqBase* req_wrap_async = GetReqWrap (args, 5 );
1834
1980
if (req_wrap_async != nullptr ) { // write(fd, buffer, off, len, pos, req)
1981
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_WRITE, req_wrap_async)
1835
1982
AsyncCall (env, req_wrap_async, args, " write" , UTF8, AfterInteger,
1836
1983
uv_fs_write, fd, &uvbuf, 1 , pos);
1837
1984
} else { // write(fd, buffer, off, len, pos, undefined, ctx)
@@ -1877,6 +2024,7 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
1877
2024
1878
2025
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
1879
2026
if (req_wrap_async != nullptr ) { // writeBuffers(fd, chunks, pos, req)
2027
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_WRITE, req_wrap_async)
1880
2028
AsyncCall (env, req_wrap_async, args, " write" , UTF8, AfterInteger,
1881
2029
uv_fs_write, fd, *iovs, iovs.length (), pos);
1882
2030
} else { // writeBuffers(fd, chunks, pos, undefined, ctx)
@@ -1950,6 +2098,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
1950
2098
len = StringBytes::Write (isolate, *stack_buffer, len, args[1 ], enc);
1951
2099
stack_buffer.SetLengthAndZeroTerminate (len);
1952
2100
uv_buf_t uvbuf = uv_buf_init (*stack_buffer, len);
2101
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_WRITE, req_wrap_async)
1953
2102
int err = req_wrap_async->Dispatch (uv_fs_write,
1954
2103
fd,
1955
2104
&uvbuf,
@@ -2035,6 +2184,7 @@ static void Read(const FunctionCallbackInfo<Value>& args) {
2035
2184
2036
2185
FSReqBase* req_wrap_async = GetReqWrap (args, 5 );
2037
2186
if (req_wrap_async != nullptr ) { // read(fd, buffer, offset, len, pos, req)
2187
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_READ, req_wrap_async)
2038
2188
AsyncCall (env, req_wrap_async, args, " read" , UTF8, AfterInteger,
2039
2189
uv_fs_read, fd, &uvbuf, 1 , pos);
2040
2190
} else { // read(fd, buffer, offset, len, pos, undefined, ctx)
@@ -2081,6 +2231,7 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
2081
2231
2082
2232
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2083
2233
if (req_wrap_async != nullptr ) { // readBuffers(fd, buffers, pos, req)
2234
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_READ, req_wrap_async)
2084
2235
AsyncCall (env, req_wrap_async, args, " read" , UTF8, AfterInteger,
2085
2236
uv_fs_read, fd, *iovs, iovs.length (), pos);
2086
2237
} else { // readBuffers(fd, buffers, undefined, ctx)
@@ -2112,6 +2263,8 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
2112
2263
2113
2264
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2114
2265
if (req_wrap_async != nullptr ) { // chmod(path, mode, req)
2266
+ FS_ASYNC_TRACE_BEGIN1 (
2267
+ UV_FS_CHMOD, req_wrap_async, " path" , TRACE_STR_COPY (*path))
2115
2268
AsyncCall (env, req_wrap_async, args, " chmod" , UTF8, AfterNoArgs,
2116
2269
uv_fs_chmod, *path, mode);
2117
2270
} else { // chmod(path, mode, undefined, ctx)
@@ -2142,6 +2295,7 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) {
2142
2295
2143
2296
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2144
2297
if (req_wrap_async != nullptr ) { // fchmod(fd, mode, req)
2298
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_FCHMOD, req_wrap_async)
2145
2299
AsyncCall (env, req_wrap_async, args, " fchmod" , UTF8, AfterNoArgs,
2146
2300
uv_fs_fchmod, fd, mode);
2147
2301
} else { // fchmod(fd, mode, undefined, ctx)
@@ -2175,6 +2329,8 @@ static void Chown(const FunctionCallbackInfo<Value>& args) {
2175
2329
2176
2330
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2177
2331
if (req_wrap_async != nullptr ) { // chown(path, uid, gid, req)
2332
+ FS_ASYNC_TRACE_BEGIN1 (
2333
+ UV_FS_CHOWN, req_wrap_async, " path" , TRACE_STR_COPY (*path))
2178
2334
AsyncCall (env, req_wrap_async, args, " chown" , UTF8, AfterNoArgs,
2179
2335
uv_fs_chown, *path, uid, gid);
2180
2336
} else { // chown(path, uid, gid, undefined, ctx)
@@ -2208,6 +2364,7 @@ static void FChown(const FunctionCallbackInfo<Value>& args) {
2208
2364
2209
2365
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2210
2366
if (req_wrap_async != nullptr ) { // fchown(fd, uid, gid, req)
2367
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_FCHOWN, req_wrap_async)
2211
2368
AsyncCall (env, req_wrap_async, args, " fchown" , UTF8, AfterNoArgs,
2212
2369
uv_fs_fchown, fd, uid, gid);
2213
2370
} else { // fchown(fd, uid, gid, undefined, ctx)
@@ -2238,6 +2395,8 @@ static void LChown(const FunctionCallbackInfo<Value>& args) {
2238
2395
2239
2396
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2240
2397
if (req_wrap_async != nullptr ) { // lchown(path, uid, gid, req)
2398
+ FS_ASYNC_TRACE_BEGIN1 (
2399
+ UV_FS_LCHOWN, req_wrap_async, " path" , TRACE_STR_COPY (*path))
2241
2400
AsyncCall (env, req_wrap_async, args, " lchown" , UTF8, AfterNoArgs,
2242
2401
uv_fs_lchown, *path, uid, gid);
2243
2402
} else { // lchown(path, uid, gid, undefined, ctx)
@@ -2268,6 +2427,8 @@ static void UTimes(const FunctionCallbackInfo<Value>& args) {
2268
2427
2269
2428
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2270
2429
if (req_wrap_async != nullptr ) { // utimes(path, atime, mtime, req)
2430
+ FS_ASYNC_TRACE_BEGIN1 (
2431
+ UV_FS_UTIME, req_wrap_async, " path" , TRACE_STR_COPY (*path))
2271
2432
AsyncCall (env, req_wrap_async, args, " utime" , UTF8, AfterNoArgs,
2272
2433
uv_fs_utime, *path, atime, mtime);
2273
2434
} else { // utimes(path, atime, mtime, undefined, ctx)
@@ -2297,6 +2458,7 @@ static void FUTimes(const FunctionCallbackInfo<Value>& args) {
2297
2458
2298
2459
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2299
2460
if (req_wrap_async != nullptr ) { // futimes(fd, atime, mtime, req)
2461
+ FS_ASYNC_TRACE_BEGIN0 (UV_FS_FUTIME, req_wrap_async)
2300
2462
AsyncCall (env, req_wrap_async, args, " futime" , UTF8, AfterNoArgs,
2301
2463
uv_fs_futime, fd, atime, mtime);
2302
2464
} else { // futimes(fd, atime, mtime, undefined, ctx)
@@ -2326,6 +2488,8 @@ static void LUTimes(const FunctionCallbackInfo<Value>& args) {
2326
2488
2327
2489
FSReqBase* req_wrap_async = GetReqWrap (args, 3 );
2328
2490
if (req_wrap_async != nullptr ) { // lutimes(path, atime, mtime, req)
2491
+ FS_ASYNC_TRACE_BEGIN1 (
2492
+ UV_FS_LUTIME, req_wrap_async, " path" , TRACE_STR_COPY (*path))
2329
2493
AsyncCall (env, req_wrap_async, args, " lutime" , UTF8, AfterNoArgs,
2330
2494
uv_fs_lutime, *path, atime, mtime);
2331
2495
} else { // lutimes(path, atime, mtime, undefined, ctx)
@@ -2352,6 +2516,8 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
2352
2516
2353
2517
FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2354
2518
if (req_wrap_async != nullptr ) { // mkdtemp(tmpl, encoding, req)
2519
+ FS_ASYNC_TRACE_BEGIN1 (
2520
+ UV_FS_MKDTEMP, req_wrap_async, " path" , TRACE_STR_COPY (*tmpl))
2355
2521
AsyncCall (env, req_wrap_async, args, " mkdtemp" , encoding, AfterStringPath,
2356
2522
uv_fs_mkdtemp, *tmpl);
2357
2523
} else { // mkdtemp(tmpl, encoding, undefined, ctx)
0 commit comments