7
7
msgstr ""
8
8
"Project-Id-Version : Python 3.12\n "
9
9
"Report-Msgid-Bugs-To : \n "
10
- "POT-Creation-Date : 2024-08-30 18:24 +0000\n "
10
+ "POT-Creation-Date : 2024-09-10 00:04 +0000\n "
11
11
"PO-Revision-Date : 2023-08-17 22:17+0800\n "
12
12
"
Last-Translator :
Matt Wang <[email protected] >\n "
13
13
"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -94,17 +94,29 @@ msgstr ""
94
94
msgid "On a Linux machine, this can be done via::"
95
95
msgstr "在 Linux 機器上,這可以透過以下方式完成: ::"
96
96
97
+ #: ../../howto/instrumentation.rst:42
98
+ msgid "$ yum install systemtap-sdt-devel"
99
+ msgstr ""
100
+
97
101
#: ../../howto/instrumentation.rst:44
98
102
msgid "or::"
99
103
msgstr "或是: ::"
100
104
105
+ #: ../../howto/instrumentation.rst:46
106
+ msgid "$ sudo apt-get install systemtap-sdt-dev"
107
+ msgstr ""
108
+
101
109
#: ../../howto/instrumentation.rst:49
102
110
msgid ""
103
111
"CPython must then be :option:`configured with the --with-dtrace option <--"
104
112
"with-dtrace>`:"
105
113
msgstr ""
106
114
"然後 CPython 必須使用\\ :option:`配置 --with-dtrace 選項 <--with-dtrace>`:"
107
115
116
+ #: ../../howto/instrumentation.rst:52
117
+ msgid "checking for --with-dtrace... yes"
118
+ msgstr ""
119
+
108
120
#: ../../howto/instrumentation.rst:56
109
121
msgid ""
110
122
"On macOS, you can list available DTrace probes by running a Python process "
@@ -114,6 +126,28 @@ msgstr ""
114
126
"在 macOS 上,你可以透過在後台運行 Python 行程並列出 Python 發布者 (provider) "
115
127
"所提供的所有可用探針,以列出可用的 DTrace 探針: ::"
116
128
129
+ #: ../../howto/instrumentation.rst:60
130
+ msgid ""
131
+ "$ python3.6 -q &\n"
132
+ "$ sudo dtrace -l -P python$! # or: dtrace -l -m python3.6\n"
133
+ "\n"
134
+ " ID PROVIDER MODULE FUNCTION NAME\n"
135
+ "29564 python18035 python3.6 _PyEval_EvalFrameDefault "
136
+ "function-entry\n"
137
+ "29565 python18035 python3.6 dtrace_function_entry "
138
+ "function-entry\n"
139
+ "29566 python18035 python3.6 _PyEval_EvalFrameDefault "
140
+ "function-return\n"
141
+ "29567 python18035 python3.6 dtrace_function_return "
142
+ "function-return\n"
143
+ "29568 python18035 python3.6 collect gc-"
144
+ "done\n"
145
+ "29569 python18035 python3.6 collect gc-"
146
+ "start\n"
147
+ "29570 python18035 python3.6 _PyEval_EvalFrameDefault line\n"
148
+ "29571 python18035 python3.6 maybe_dtrace_line line"
149
+ msgstr ""
150
+
117
151
#: ../../howto/instrumentation.rst:73
118
152
msgid ""
119
153
"On Linux, you can verify if the SystemTap static markers are present in the "
@@ -122,6 +156,12 @@ msgstr ""
122
156
"在 Linux 上,你可以透過查看二進位建置檔案中是否包含 \" .note.stapsdt\" 部分來"
123
157
"驗證 SystemTap 靜態標記是否存在。"
124
158
159
+ #: ../../howto/instrumentation.rst:78
160
+ msgid ""
161
+ "$ readelf -S ./python | grep .note.stapsdt\n"
162
+ "[30] .note.stapsdt NOTE 0000000000000000 00308d78"
163
+ msgstr ""
164
+
125
165
#: ../../howto/instrumentation.rst:81
126
166
msgid ""
127
167
"If you've built Python as a shared library (with the :option:`--enable-"
@@ -131,10 +171,64 @@ msgstr ""
131
171
"如果你已將 Python 建置為共享函式庫(使用 :option:`--enable-shared` 配置選"
132
172
"項),則需要在共享函式庫中查找。例如: ::"
133
173
174
+ #: ../../howto/instrumentation.rst:85
175
+ msgid ""
176
+ "$ readelf -S libpython3.3dm.so.1.0 | grep .note.stapsdt\n"
177
+ "[29] .note.stapsdt NOTE 0000000000000000 00365b68"
178
+ msgstr ""
179
+
134
180
#: ../../howto/instrumentation.rst:88
135
181
msgid "Sufficiently modern readelf can print the metadata::"
136
182
msgstr "足夠現代化的 readelf 可以印出元資料 (metadata): ::"
137
183
184
+ #: ../../howto/instrumentation.rst:90
185
+ msgid ""
186
+ "$ readelf -n ./python\n"
187
+ "\n"
188
+ "Displaying notes found at file offset 0x00000254 with length 0x00000020:\n"
189
+ " Owner Data size Description\n"
190
+ " GNU 0x00000010 NT_GNU_ABI_TAG (ABI version "
191
+ "tag)\n"
192
+ " OS: Linux, ABI: 2.6.32\n"
193
+ "\n"
194
+ "Displaying notes found at file offset 0x00000274 with length 0x00000024:\n"
195
+ " Owner Data size Description\n"
196
+ " GNU 0x00000014 NT_GNU_BUILD_ID (unique build "
197
+ "ID bitstring)\n"
198
+ " Build ID: df924a2b08a7e89f6e11251d4602022977af2670\n"
199
+ "\n"
200
+ "Displaying notes found at file offset 0x002d6c30 with length 0x00000144:\n"
201
+ " Owner Data size Description\n"
202
+ " stapsdt 0x00000031 NT_STAPSDT (SystemTap probe "
203
+ "descriptors)\n"
204
+ " Provider: python\n"
205
+ " Name: gc__start\n"
206
+ " Location: 0x00000000004371c3, Base: 0x0000000000630ce2, Semaphore: "
207
+ "0x00000000008d6bf6\n"
208
+ " Arguments: -4@%ebx\n"
209
+ " stapsdt 0x00000030 NT_STAPSDT (SystemTap probe "
210
+ "descriptors)\n"
211
+ " Provider: python\n"
212
+ " Name: gc__done\n"
213
+ " Location: 0x00000000004374e1, Base: 0x0000000000630ce2, Semaphore: "
214
+ "0x00000000008d6bf8\n"
215
+ " Arguments: -8@%rax\n"
216
+ " stapsdt 0x00000045 NT_STAPSDT (SystemTap probe "
217
+ "descriptors)\n"
218
+ " Provider: python\n"
219
+ " Name: function__entry\n"
220
+ " Location: 0x000000000053db6c, Base: 0x0000000000630ce2, Semaphore: "
221
+ "0x00000000008d6be8\n"
222
+ " Arguments: 8@%rbp 8@%r12 -4@%eax\n"
223
+ " stapsdt 0x00000046 NT_STAPSDT (SystemTap probe "
224
+ "descriptors)\n"
225
+ " Provider: python\n"
226
+ " Name: function__return\n"
227
+ " Location: 0x000000000053dba8, Base: 0x0000000000630ce2, Semaphore: "
228
+ "0x00000000008d6bea\n"
229
+ " Arguments: 8@%rbp 8@%r12 -4@%eax"
230
+ msgstr ""
231
+
138
232
#: ../../howto/instrumentation.rst:125
139
233
msgid ""
140
234
"The above metadata contains information for SystemTap describing how it can "
@@ -158,14 +252,77 @@ msgstr ""
158
252
"以下範例示範 DTrace 腳本可用於顯示 Python 腳本的呼叫/回傳階層結構,僅在名為 "
159
253
"\" start\" 的函式的呼叫內進行追蹤。換句話說,引入時的函式呼叫不會被列出:"
160
254
255
+ #: ../../howto/instrumentation.rst:138
256
+ msgid ""
257
+ "self int indent;\n"
258
+ "\n"
259
+ "python$target:::function-entry\n"
260
+ "/copyinstr(arg1) == \" start\" /\n"
261
+ "{\n"
262
+ " self->trace = 1;\n"
263
+ "}\n"
264
+ "\n"
265
+ "python$target:::function-entry\n"
266
+ "/self->trace/\n"
267
+ "{\n"
268
+ " printf(\" %d\\ t%*s:\" , timestamp, 15, probename);\n"
269
+ " printf(\" %*s\" , self->indent, \"\" );\n"
270
+ " printf(\" %s:%s:%d\\ n\" , basename(copyinstr(arg0)), copyinstr(arg1), "
271
+ "arg2);\n"
272
+ " self->indent++;\n"
273
+ "}\n"
274
+ "\n"
275
+ "python$target:::function-return\n"
276
+ "/self->trace/\n"
277
+ "{\n"
278
+ " self->indent--;\n"
279
+ " printf(\" %d\\ t%*s:\" , timestamp, 15, probename);\n"
280
+ " printf(\" %*s\" , self->indent, \"\" );\n"
281
+ " printf(\" %s:%s:%d\\ n\" , basename(copyinstr(arg0)), copyinstr(arg1), "
282
+ "arg2);\n"
283
+ "}\n"
284
+ "\n"
285
+ "python$target:::function-return\n"
286
+ "/copyinstr(arg1) == \" start\" /\n"
287
+ "{\n"
288
+ " self->trace = 0;\n"
289
+ "}"
290
+ msgstr ""
291
+
161
292
#: ../../howto/instrumentation.rst:172 ../../howto/instrumentation.rst:230
162
293
msgid "It can be invoked like this::"
163
294
msgstr "可以這樣呼叫: ::"
164
295
296
+ #: ../../howto/instrumentation.rst:174
297
+ msgid "$ sudo dtrace -q -s call_stack.d -c \" python3.6 script.py\" "
298
+ msgstr ""
299
+
165
300
#: ../../howto/instrumentation.rst:176 ../../howto/instrumentation.rst:236
166
301
msgid "The output looks like this:"
167
302
msgstr "輸出如下所示:"
168
303
304
+ #: ../../howto/instrumentation.rst:178
305
+ msgid ""
306
+ "156641360502280 function-entry:call_stack.py:start:23\n"
307
+ "156641360518804 function-entry: call_stack.py:function_1:1\n"
308
+ "156641360532797 function-entry: call_stack.py:function_3:9\n"
309
+ "156641360546807 function-return: call_stack.py:function_3:10\n"
310
+ "156641360563367 function-return: call_stack.py:function_1:2\n"
311
+ "156641360578365 function-entry: call_stack.py:function_2:5\n"
312
+ "156641360591757 function-entry: call_stack.py:function_1:1\n"
313
+ "156641360605556 function-entry: call_stack.py:function_3:9\n"
314
+ "156641360617482 function-return: call_stack.py:function_3:10\n"
315
+ "156641360629814 function-return: call_stack.py:function_1:2\n"
316
+ "156641360642285 function-return: call_stack.py:function_2:6\n"
317
+ "156641360656770 function-entry: call_stack.py:function_3:9\n"
318
+ "156641360669707 function-return: call_stack.py:function_3:10\n"
319
+ "156641360687853 function-entry: call_stack.py:function_4:13\n"
320
+ "156641360700719 function-return: call_stack.py:function_4:14\n"
321
+ "156641360719640 function-entry: call_stack.py:function_5:18\n"
322
+ "156641360732567 function-return: call_stack.py:function_5:21\n"
323
+ "156641360747370 function-return:call_stack.py:start:28"
324
+ msgstr ""
325
+
169
326
#: ../../howto/instrumentation.rst:201
170
327
msgid "Static SystemTap markers"
171
328
msgstr "靜態 SystemTap 標記"
@@ -185,6 +342,44 @@ msgid ""
185
342
"hierarchy of a Python script:"
186
343
msgstr "例如,此 SystemTap 腳本可用於顯示 Python 腳本的呼叫/回傳階層結構:"
187
344
345
+ #: ../../howto/instrumentation.rst:210
346
+ msgid ""
347
+ "probe process(\" python\" ).mark(\" function__entry\" ) {\n"
348
+ " filename = user_string($arg1);\n"
349
+ " funcname = user_string($arg2);\n"
350
+ " lineno = $arg3;\n"
351
+ "\n"
352
+ " printf(\" %s => %s in %s:%d\\\\ n\" ,\n"
353
+ " thread_indent(1), funcname, filename, lineno);\n"
354
+ "}\n"
355
+ "\n"
356
+ "probe process(\" python\" ).mark(\" function__return\" ) {\n"
357
+ " filename = user_string($arg1);\n"
358
+ " funcname = user_string($arg2);\n"
359
+ " lineno = $arg3;\n"
360
+ "\n"
361
+ " printf(\" %s <= %s in %s:%d\\\\ n\" ,\n"
362
+ " thread_indent(-1), funcname, filename, lineno);\n"
363
+ "}"
364
+ msgstr ""
365
+
366
+ #: ../../howto/instrumentation.rst:232
367
+ msgid ""
368
+ "$ stap \\ \n"
369
+ " show-call-hierarchy.stp \\ \n"
370
+ " -c \" ./python test.py\" "
371
+ msgstr ""
372
+
373
+ #: ../../howto/instrumentation.rst:238
374
+ msgid ""
375
+ "11408 python(8274): => __contains__ in Lib/_abcoll.py:362\n"
376
+ "11414 python(8274): => __getitem__ in Lib/os.py:425\n"
377
+ "11418 python(8274): => encode in Lib/os.py:490\n"
378
+ "11424 python(8274): <= encode in Lib/os.py:493\n"
379
+ "11428 python(8274): <= __getitem__ in Lib/os.py:426\n"
380
+ "11433 python(8274): <= __contains__ in Lib/_abcoll.py:366"
381
+ msgstr ""
382
+
188
383
#: ../../howto/instrumentation.rst:247
189
384
msgid "where the columns are:"
190
385
msgstr "其中的行 (column) 是:"
@@ -216,10 +411,20 @@ msgstr ""
216
411
"函式庫中,並且探針的帶點路徑 (dotted path) 需要反映這一點。例如,上面範例中的"
217
412
"這一列:"
218
413
414
+ #: ../../howto/instrumentation.rst:259
415
+ msgid "probe process(\" python\" ).mark(\" function__entry\" ) {"
416
+ msgstr ""
417
+
219
418
#: ../../howto/instrumentation.rst:263
220
419
msgid "should instead read:"
221
420
msgstr "應該改為讀取:"
222
421
422
+ #: ../../howto/instrumentation.rst:265
423
+ msgid ""
424
+ "probe process(\" python\" ).library(\" libpython3.6dm.so.1.0\" )."
425
+ "mark(\" function__entry\" ) {"
426
+ msgstr ""
427
+
223
428
#: ../../howto/instrumentation.rst:269
224
429
msgid "(assuming a :ref:`debug build <debug-build>` of CPython 3.6)"
225
430
msgstr "(假設 CPython 3.6 的\\ :ref:`除錯建置版本 <debug-build>`)"
@@ -342,6 +547,29 @@ msgstr ""
342
547
msgid "Here is a tapset file, based on a non-shared build of CPython:"
343
548
msgstr "這是一個 tapset 檔案,是基於 CPython 的非共享建置版本:"
344
549
550
+ #: ../../howto/instrumentation.rst:351
551
+ msgid ""
552
+ "/*\n"
553
+ " Provide a higher-level wrapping around the function__entry and\n"
554
+ " function__return markers:\n"
555
+ " \\ */\n"
556
+ "probe python.function.entry = process(\" python\" ).mark(\" function__entry\" )\n"
557
+ "{\n"
558
+ " filename = user_string($arg1);\n"
559
+ " funcname = user_string($arg2);\n"
560
+ " lineno = $arg3;\n"
561
+ " frameptr = $arg4\n"
562
+ "}\n"
563
+ "probe python.function.return = process(\" python\" )."
564
+ "mark(\" function__return\" )\n"
565
+ "{\n"
566
+ " filename = user_string($arg1);\n"
567
+ " funcname = user_string($arg2);\n"
568
+ " lineno = $arg3;\n"
569
+ " frameptr = $arg4\n"
570
+ "}"
571
+ msgstr ""
572
+
345
573
#: ../../howto/instrumentation.rst:372
346
574
msgid ""
347
575
"If this file is installed in SystemTap's tapset directory (e.g. ``/usr/share/"
@@ -381,6 +609,21 @@ msgstr ""
381
609
"此 SystemTap 腳本使用上面的 tapset 來更清晰地實作上面給出的追蹤 Python 函式呼"
382
610
"叫階層結構的範例,而無需直接命名靜態標記:"
383
611
612
+ #: ../../howto/instrumentation.rst:395
613
+ msgid ""
614
+ "probe python.function.entry\n"
615
+ "{\n"
616
+ " printf(\" %s => %s in %s:%d\\ n\" ,\n"
617
+ " thread_indent(1), funcname, filename, lineno);\n"
618
+ "}\n"
619
+ "\n"
620
+ "probe python.function.return\n"
621
+ "{\n"
622
+ " printf(\" %s <= %s in %s:%d\\ n\" ,\n"
623
+ " thread_indent(-1), funcname, filename, lineno);\n"
624
+ "}"
625
+ msgstr ""
626
+
384
627
#: ../../howto/instrumentation.rst:410
385
628
msgid ""
386
629
"The following script uses the tapset above to provide a top-like view of all "
@@ -389,3 +632,25 @@ msgid ""
389
632
msgstr ""
390
633
"以下腳本使用上面的 tapset 來提供所有正在運行之 CPython 程式碼的近乎最高層視"
391
634
"角,顯示整個系統中每秒最常被進入的 20 個位元組碼幀 (bytecode frame):"
635
+
636
+ #: ../../howto/instrumentation.rst:414
637
+ msgid ""
638
+ "global fn_calls;\n"
639
+ "\n"
640
+ "probe python.function.entry\n"
641
+ "{\n"
642
+ " fn_calls[pid(), filename, funcname, lineno] += 1;\n"
643
+ "}\n"
644
+ "\n"
645
+ "probe timer.ms(1000) {\n"
646
+ " printf(\"\\ 033[2J\\ 033[1;1H\" ) /* clear screen \\ */\n"
647
+ " printf(\" %6s %80s %6s %30s %6s\\ n\" ,\n"
648
+ " \" PID\" , \" FILENAME\" , \" LINE\" , \" FUNCTION\" , \" CALLS\" )\n"
649
+ " foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) {\n"
650
+ " printf(\" %6d %80s %6d %30s %6d\\ n\" ,\n"
651
+ " pid, filename, lineno, funcname,\n"
652
+ " fn_calls[pid, filename, funcname, lineno]);\n"
653
+ " }\n"
654
+ " delete fn_calls;\n"
655
+ "}"
656
+ msgstr ""
0 commit comments