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:

  • kpkg installs, updates and removes Store apps by typing.
  • kdbg is a debugger. It stops a program so you can look at it one step at a time.
  • kprof is 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.

CommandWhat it does
kpkg search photoFinds apps whose name, maker or description has "photo"
kpkg info IDShows one app: maker, version, size and what it is allowed to do
kpkg listLists the Store apps on this PC and their versions
kpkg install IDInstalls an app
kpkg remove IDRemoves an app and its data. Add --keep-data to keep its data
kpkg updateUpdates 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.

  1. Type kpkg install ID and press Enter.
  2. kpkg lists what the app is allowed to do and asks Install? Type y and press Enter. (-y answers yes for you.)
  3. The Allow this change? box asks for an administrator, because Store apps are installed for everyone on the PC.
  4. 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 PROGRAM starts the program stopped at its first instruction.
  • kdbg PID stops a running program. kdbg list shows the programs you can pick and their PIDs (process numbers).

At the (kdbg) prompt, type a command and press Enter:

CommandWhat it does
cLet the program run. Ctrl+C stops it again
sRun one instruction. s 10 runs ten
b NAMEStop when the program reaches a function, for example b main or b kernel32.dll!Sleep, or an address
bl, d 1List breakpoints, delete breakpoint 1
rShow the registers (the processor's working values)
set rax 5Change a register
btShow the chain of function calls that led here (a backtrace)
x ADDRESS 64Show 64 bytes of memory
modsList the files loaded into the program
threads, thread IDList threads, switch to one
detachLet the program go on without the debugger
killEnd the program
qQuit. 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 run shares the tab with the debugger. If it reads the keyboard, start it in another tab and use kdbg PID instead.
  • There is no disassembly and no source code view yet.

Find what is slow with kprof

CommandWhat it does
kprof top -p PIDWatches one program for 5 seconds and lists its busiest functions
kprof record -p PID -s 10Records one program for 10 seconds and saves the recording
kprof recordRecords the whole PC (needs an administrator)
kprof record -eAlso records thread switches, system calls and page faults
kprof record --viewOpens the recording in Trace Viewer when it is done
kprof view FILEOpens 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.