- Start in C Perspective
- Build Automatically Off
- cd /scratch/python
- File Open Projects for /scratch/python/Python-3.4.2
Configuring scanner is often the first issue that people run into on larger projects that were not run in Eclipse. If the scanner is wrong, your code is filled with codan and other errors, making it very difficult to use your project.
- Show Project Settings: C/C++ General -> Preprocessor Include Paths...
- Observe Root of project and Include exist under Build Output Parser
- Show configuration of Build Output Parser
- Observe how it can be configured per project, file, etc
- Show GCC Built-ins and how it is picked up.
- Show ARM Hello project has different settings
- Show how stdio.h that is opened is different for each project
- For ARM, open ARM_Hello.c and Ctrl-Click on stdio
- For Python, open Python.h and Ctrl-Click on stdio
- Zoom in on tabs to show they are different
- Same thing is done for symbols
- Can be done manually, or even provide your own provider
Codan, short for C/C++ Code Analysis, provides the static analysis of the code. It is highly configurable and additional analysis can be added.
Unfortunately, Codan sometimes has false positives, and sometimes it is not easy to work around such false positives.
Fortunately Neon now has fine grained (per line) control of Codan. Here is an example:
- Open ceval.c Goto Line 2570
- Show how there is a warning about the semi-colon
- Add
/* @suppress("Suspicious semicolon") */
to make it go away - Show how the naming is in Window | Preferences | C/C++ | Code Analysis | Customize Selected
- Show how the name can be looked up as sometimes the error/warning text is not exactly what is in the @suppress.
Show various code navigation features:
- Include Browser (Ctrl-3 -> Views: Include Browser, then drag in Python.h)
- C/C++ Index View (caution: Expanding some items can be a little slow on the UI side)
- C/C++ Search, show searching for fileio_write, everything in workspace
- Call Hierarchy,
- fileio_write callers with fields on and off
- fileio_write callees with fields on and off
- right-click on PyArg_ParseTuple and focus, changing to callers and callees
- The search and hierarchy are even more valuable in C++ code where simply doing "grep" searches brings up lots of false positives
- Demo by showing call hierarchy of overloaded in HelloCPP.cpp
- Macro expansions
- fileio.c: find Py_XDECREF on line 202
- Right-click: Explore Macro Expansion
- Step through the 10 steps of expansion
- and many more
Step Into Selection
- Run to python.c:47 with Run to Line
- Show traditional step into steps into
locale
and then_PyMem_RawStrdup
- Restart debug and Run to python.c:47 again
- Then right-click
_PyMem_RawStrdup
and do Step Into Selection
Show Disassembly
- Steps nicely fade the older the instruction gets
- Hover over registers (NEW)
Open Memory Browser
- Show details of
pbuf.buf
, it shows the text value - Add a tab for
&pbuf
which is a local variable - Show that the memory view shows all the local variable details (NEW)
- Set expression to
$sp
(Stack pointer) - Show how stack is growing by click on different stack frames
Interact At Console
- do
print("Hello ECF")
- add breakpoint at fileio.c:809
- do print again
- Show we are stopped
- Scroll in Variables to pbuf->buf, Show it is a void * and not useful as is
- Lets look at it as a string, cast it to char * instead
- Show how it says Hello ECF
- Right-click on it and say Watch so that it can be saved for easy access next time
- Resume and do another print to show
- Now trace it, print the stdout everything that is printed without having to stop
- Add dprintf breakpoint at line 809 instead with this expression:
"write: fd=%d len=%d chars=%s", self->fd, len, pbuf.buf
- do a few simple print
- debug short program to see tracing write to the file
PyDev simultaneous Debug
-
Show how "Python-3.4.2 short.py" launch config is using Python-3.4.2 locally built
-
Set breakpoints at short.py:1 and :4 (in loop)
-
Run it once
-
Debug it
-
Attach GDB to Python while PyDev is stopped
-
Add breakpoint (remove trace) for fileio.c:809
-
Press continue and see how we jump back between Python and C