File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed
Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,6 @@ Frequently Asked Questions
99
1010* **What do the colors on vmprof.com mean? **: For plain CPython there is no particular meaning, we might change
1111 that in the future. For PyPy we have a color coding to show at which state the VM sampled (e.g. JIT, Warmup, ...).
12+
13+ * **My Windows profile is malformed? **: Please ensure that you open the file in binary mode. Otherwise Windows
14+ will transform `\n ` to `\r\n `.
Original file line number Diff line number Diff line change @@ -48,7 +48,13 @@ static struct profbuf_s *volatile current_codes;
4848 * is 4, but fails on win32
4949 */
5050typedef struct prof_stacktrace_s {
51+ #ifdef VMPROF_WINDOWS
52+ // if padding is 8 bytes, then on both 32bit and 64bit, the
53+ // stack field is aligned
54+ char padding [sizeof (void * ) - 1 ];
55+ #else
5156 char padding [sizeof (long ) - 1 ];
57+ #endif
5258 char marker ;
5359 long count , depth ;
5460 void * stack [];
Original file line number Diff line number Diff line change @@ -86,10 +86,8 @@ long __stdcall vmprof_mainloop(void *arg)
8686 continue ;
8787 depth = vmprof_snapshot_thread (tstate -> thread_id , tstate , stack );
8888 if (depth > 0 ) {
89- // see note in vmprof_common.h on the prof_stacktrace_s struct why
90- // there are two vmpr_write_all calls
91- vmp_write_all ((char * )stack + offsetof(prof_stacktrace_s , marker ), SIZEOF_PROF_STACKTRACE );
92- vmp_write_all ((char * )stack -> stack , depth * sizeof (void * ));
89+ vmp_write_all ((char * )stack + offsetof(prof_stacktrace_s , marker ),
90+ SIZEOF_PROF_STACKTRACE + depth * sizeof (void * ));
9391 }
9492 }
9593}
@@ -121,4 +119,5 @@ int vmprof_disable(void)
121119RPY_EXTERN
122120void vmprof_ignore_signals (int ignored )
123121{
122+ enabled = !ignored ;
124123}
Original file line number Diff line number Diff line change 1+ import sys
12import os
23from time import time
34import vmprof
@@ -48,7 +49,10 @@ def test():
4849
4950 PROFILE_FILE = 'vmprof_cpuburn.dat'
5051
51- outfd = os .open (PROFILE_FILE , os .O_RDWR | os .O_CREAT | os .O_TRUNC )
52+ flags = os .O_RDWR | os .O_CREAT | os .O_TRUNC
53+ if sys .platform == 'win32' :
54+ flags |= os .O_BINARY
55+ outfd = os .open (PROFILE_FILE , flags )
5256 vmprof .enable (outfd , period = 0.01 )
5357 test ()
5458 vmprof .disable ()
You can’t perform that action at this time.
0 commit comments