Skip to content

Commit fd51561

Browse files
committed
Add docs
1 parent 4c04b1c commit fd51561

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

mypyc/doc/dev-intro.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,25 @@ Test cases can also have a `[out]` section, which specifies the
386386
expected contents of stdout the test case should produce. New test
387387
cases should prefer assert statements to `[out]` sections.
388388

389+
### Adding Debug Prints and Editing Generated C
390+
391+
Sometimes it's helpful to add some debug prints or other debugging helpers
392+
to the generated C code. You can run mypyc using `--skip-c-gen` to skip the C
393+
generation step, so all manual changes to C files are preserved. Here is
394+
an example of how to use the workflow:
395+
396+
* Compile some file you want to debug: `python -m mypyc foo.py`.
397+
* Add debug prints to the generated C in `build/__native.c`.
398+
* Run the same compilation command line again, but add `--skip-c-gen`:
399+
`python -m mypyc --skip-c-gen foo.py`. This will only rebuild the
400+
binaries.
401+
* Run the compiled code, including your changes: `python -c 'import foo'`.
402+
You should now see the output from the debug prints you added.
403+
404+
This can also be helpful if you want to quickly experiment with different
405+
implementation techniques, without having to first figure out how to
406+
modify mypyc to generate the desired C code.
407+
389408
### Debugging Segfaults
390409

391410
If you experience a segfault, it's recommended to use a debugger that supports

0 commit comments

Comments
 (0)