File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -386,6 +386,25 @@ Test cases can also have a `[out]` section, which specifies the
386386expected contents of stdout the test case should produce. New test
387387cases 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
391410If you experience a segfault, it's recommended to use a debugger that supports
You can’t perform that action at this time.
0 commit comments