Guides › Desktop and apps
Developer tools in the Terminal
Install Store apps by typing, look inside a running program with a debugger, and see where a program spends its time.
The Terminal has three tools for people who write or test programs:
kpkginstalls, updates and removes Store apps by typing.kdbgis a debugger. It stops a program so you can look at it one step at a time.kprofis a profiler. It watches a program, or the whole PC, for a few seconds and shows where the time went. Trace Viewer shows the recording as a timeline.
Type a tool's name on its own to see its options. See Terminal for how to open the Terminal.
Whose programs you can look at
A program is yours when you started it from the same Terminal tab, or when a program you started there started it. You can debug and profile those right away. Any other program, and the whole PC, needs an administrator: a box asks Allow this change?, as with elevate. If Run as administrator in the Terminal is off in Settings > System > Advanced, the tool tells you to turn it on first.
Install apps with kpkg
kpkg uses the same Store as the Store app, with the same checks.
| Command | What it does |
|---|---|
kpkg search photo | Finds apps whose name, maker or description has "photo" |
kpkg info ID | Shows one app: maker, version, size and what it is allowed to do |
kpkg list | Lists the Store apps on this PC and their versions |
kpkg install ID | Installs an app |
kpkg remove ID | Removes an app and its data. Add --keep-data to keep its data |
kpkg update | Updates every app that has a newer version. Add IDs to update only those |
The ID is the short name shown by kpkg search, for example com.example.notes.
- Type
kpkg install IDand press Enter. kpkglists what the app is allowed to do and asks Install? Typeyand press Enter. (-yanswers yes for you.)- The Allow this change? box asks for an administrator, because Store apps are installed for everyone on the PC.
- You see the download progress, then installed.
Every package is checked against the Store's signature before anything is installed. If the check fails, nothing is installed and kpkg says why. There is no way to turn the check off. Press Ctrl+C to stop a download.
Debug a program with kdbg
Start a program under the debugger, or stop one that is already running:
kdbg run PROGRAMstarts the program stopped at its first instruction.kdbg PIDstops a running program.kdbg listshows the programs you can pick and their PIDs (process numbers).
At the (kdbg) prompt, type a command and press Enter:
| Command | What it does |
|---|---|
c | Let the program run. Ctrl+C stops it again |
s | Run one instruction. s 10 runs ten |
b NAME | Stop when the program reaches a function, for example b main or b kernel32.dll!Sleep, or an address |
bl, d 1 | List breakpoints, delete breakpoint 1 |
r | Show the registers (the processor's working values) |
set rax 5 | Change a register |
bt | Show the chain of function calls that led here (a backtrace) |
x ADDRESS 64 | Show 64 bytes of memory |
mods | List the files loaded into the program |
threads, thread ID | List threads, switch to one |
detach | Let the program go on without the debugger |
kill | End the program |
q | Quit. A program you started with kdbg run ends, one you attached to goes on |
Things to know:
- Function names come from the program's own files. Programs built without names show addresses only.
- The backtrace follows frame pointers. Programs built without them show a shorter chain.
- A program that is waiting (for a key, the network or a timer) stops only when it wakes up. Press Ctrl+C three times to give up.
- A program started with
kdbg runshares the tab with the debugger. If it reads the keyboard, start it in another tab and usekdbg PIDinstead. - There is no disassembly and no source code view yet.
Find what is slow with kprof
| Command | What it does |
|---|---|
kprof top -p PID | Watches one program for 5 seconds and lists its busiest functions |
kprof record -p PID -s 10 | Records one program for 10 seconds and saves the recording |
kprof record | Records the whole PC (needs an administrator) |
kprof record -e | Also records thread switches, system calls and page faults |
kprof record --view | Opens the recording in Trace Viewer when it is done |
kprof view FILE | Opens a recording in Trace Viewer |
Press Ctrl+C to end a recording early. Recordings are saved in Documents > Traces, and only you can open them unless you share them.
Many times each second, kprof notes what every processor is running. A function that shows up often is where the time goes. It does not record which function called which.
Read a recording in Trace Viewer
Open Trace Viewer from Start, type the path of a .ktrace file and click Open, or use kprof view.
- Each row is one processor. Each colour is one thread. Point at a stretch to see the thread and how long it ran.
- On a wide window the right side lists the busiest functions.
- Scroll the mouse wheel to move along. Hold Ctrl and scroll, or press + and -, to zoom. Press 0 to see the whole recording. The arrow keys move too.
A damaged file is refused with a message. Nothing is shown from it.
If something goes wrong
- "This needs an administrator": turn on Run as administrator in the Terminal in Settings > System > Advanced, then try again.
- "The package isn't signed by the store" or "doesn't match the store listing": the download is not the package the Store signed. Nothing was installed. Try again later.
- Only addresses in kdbg or kprof: the program's files have no function names.
- "a recording is running already": type
kprof stop, then start again.
These tools were built and tested on test files. They have not been tried on every kind of PC yet.
Still stuck? Search the help center or contact support.