Skip to content

Commit

Permalink
add faq entry, fix windows parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
planrich committed Feb 15, 2017
1 parent 7bc1627 commit 0f4bd60
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ Frequently Asked Questions

* **What do the colors on vmprof.com mean?**: For plain CPython there is no particular meaning, we might change
that in the future. For PyPy we have a color coding to show at which state the VM sampled (e.g. JIT, Warmup, ...).

* **My Windows profile is malformed?**: Please ensure that you open the file in binary mode. Otherwise Windows
will transform `\n` to `\r\n`.
6 changes: 6 additions & 0 deletions src/vmprof_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ static struct profbuf_s *volatile current_codes;
* is 4, but fails on win32
*/
typedef struct prof_stacktrace_s {
#ifdef VMPROF_WINDOWS
// if padding is 8 bytes, then on both 32bit and 64bit, the
// stack field is aligned
char padding[sizeof(void*) - 1];
#else
char padding[sizeof(long) - 1];
#endif
char marker;
long count, depth;
void *stack[];
Expand Down
7 changes: 3 additions & 4 deletions src/vmprof_main_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ long __stdcall vmprof_mainloop(void *arg)
continue;
depth = vmprof_snapshot_thread(tstate->thread_id, tstate, stack);
if (depth > 0) {
// see note in vmprof_common.h on the prof_stacktrace_s struct why
// there are two vmpr_write_all calls
vmp_write_all((char*)stack + offsetof(prof_stacktrace_s, marker), SIZEOF_PROF_STACKTRACE);
vmp_write_all((char*)stack->stack, depth * sizeof(void*));
vmp_write_all((char*)stack + offsetof(prof_stacktrace_s, marker),
SIZEOF_PROF_STACKTRACE + depth * sizeof(void*));
}
}
}
Expand Down Expand Up @@ -121,4 +119,5 @@ int vmprof_disable(void)
RPY_EXTERN
void vmprof_ignore_signals(int ignored)
{
enabled = !ignored;
}
6 changes: 5 additions & 1 deletion vmprof/test/cpuburn.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import os
from time import time
import vmprof
Expand Down Expand Up @@ -48,7 +49,10 @@ def test():

PROFILE_FILE = 'vmprof_cpuburn.dat'

outfd = os.open(PROFILE_FILE, os.O_RDWR | os.O_CREAT | os.O_TRUNC)
flags = os.O_RDWR | os.O_CREAT | os.O_TRUNC
if sys.platform == 'win32':
flags |= os.O_BINARY
outfd = os.open(PROFILE_FILE, flags)
vmprof.enable(outfd, period=0.01)
test()
vmprof.disable()
Expand Down

0 comments on commit 0f4bd60

Please sign in to comment.