<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/kernel-debugging-with-qemu-an-overview-of-tools-available-ykpr4h596" -->

---
title: Kernel debugging with QEMU: An overview of tools available
description: An overview of kernel debugging tools available when running Linux in QEMU. Covers enabling and using kmemleak for memory leak detection, setting up SSH...
canonical: https://daily.dev/posts/kernel-debugging-with-qemu-an-overview-of-tools-available-ykpr4h596
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Kernel debugging with QEMU: An overview of tools available | daily.dev
og:description: An overview of kernel debugging tools available when running Linux in QEMU. Covers enabling and using kmemleak for memory leak detection, setting up SSH...
og:url: https://daily.dev/posts/kernel-debugging-with-qemu-an-overview-of-tools-available-ykpr4h596
og:image: https://api.daily.dev/og/posts/ykpr4H596.png
og:image:alt: Kernel debugging with QEMU: An overview of tools available
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Kernel debugging with QEMU: An overview of tools available

**[Collabora Blog](https://daily.dev/sources/collabora)** · 4 min read · 0 upvotes · 0 comments

## Summary

An overview of kernel debugging tools available when running Linux in QEMU. Covers enabling and using kmemleak for memory leak detection, setting up SSH networking in QEMU guests, bridging USB devices, attaching GDB to a running kernel via the -s flag and vmlinux symbols, and enabling dynamic_debug and ftrace for tracing. Practical command-line examples are provided for each tool, along with tips on avoiding pitfalls like shared disk images and multiple simultaneous GDB sessions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.collabora.com/news-and-blog/blog/2017/03/13/kernel-debugging-with-qemu-overview-tools-available>

## Questions this post answers

### How do I attach GDB to a Linux kernel running in QEMU?

Start QEMU with the -s flag, which creates a TCP socket on port 1234 for GDB to connect to. Then run `gdb vmlinux` on the host (vmlinux is the uncompressed kernel binary with symbols included) and connect with `target remote localhost:1234`. From there you can set breakpoints, inspect backtraces, and use standard GDB commands. Only one QEMU instance at a time can use -s.

_Kernel developers debugging QEMU setups share notes and discoveries on daily.dev._

### How do I enable and use kmemleak to detect memory leaks in the Linux kernel?

Enable kmemleak under Memory Debugging in the kernel config, setting 'Maximum kmemleak early log entries' high enough (e.g. 2000) to prevent it from disabling itself at boot. After booting, trigger a manual scan with `echo scan >> /sys/kernel/debug/kmemleak` and read results with `cat /sys/kernel/debug/kmemleak`. Wait several tenths of seconds and run multiple scans to confirm no leaks are present.

_Linux systems engineers tracking down memory leaks find relevant kernel debugging discussions on daily.dev._

## Similar posts on daily.dev

- [Build and Debug QEMU in Docker](https://daily.dev/posts/build-and-debug-qemu-in-docker-l9yzdyyqk) · MCU on Eclipse · 0 upvotes · 0 comments
- [Linux VM without VM software - User Mode Linux](https://daily.dev/posts/linux-vm-without-vm-software---user-mode-linux-pcdpcizhy) · Hacker News · 2 upvotes · 0 comments
- [Building Your Own Operating System From Scratch \(A Practical Getting-Started Guide\)](https://daily.dev/posts/building-your-own-operating-system-from-scratch-a-practical-getting-started-guide--bcelcqpq7) · Medium · 0 upvotes · 0 comments

---

Tags: [#linux](https://daily.dev/tags/linux)

[View this post on daily.dev](https://daily.dev/posts/kernel-debugging-with-qemu-an-overview-of-tools-available-ykpr4h596)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Kernel debugging with QEMU: An overview of tools available","url":"https://daily.dev/posts/kernel-debugging-with-qemu-an-overview-of-tools-available-ykpr4h596","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/kernel-debugging-with-qemu-an-overview-of-tools-available-ykpr4h596"},"datePublished":"2026-08-11T08:55:38.210Z","dateModified":"2026-08-11T09:41:22.235Z","description":"An overview of kernel debugging tools available when running Linux in QEMU. Covers enabling and using kmemleak for memory leak detection, setting up SSH...","image":"https://media.daily.dev/image/upload/s--HRgLpUt6--/f_auto/v1722860399/public/Placeholder%2003","thumbnailUrl":"https://media.daily.dev/image/upload/s--HRgLpUt6--/f_auto/v1722860399/public/Placeholder%2003","isAccessibleForFree":true,"articleSection":"Collabora Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Collabora Blog","logo":"https://media.daily.dev/image/upload/s--ZGZ0FjqS--/f_auto,q_auto/v1786438306/logos/collabora?_a=BAMAMicg0","url":"https://daily.dev/sources/collabora"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/kernel-debugging-with-qemu-an-overview-of-tools-available-ykpr4h596","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"linux","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Collabora Blog","item":"https://daily.dev/sources/collabora"},{"@type":"ListItem","position":3,"name":"Kernel debugging with QEMU: An overview of tools available"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/kernel-debugging-with-qemu-an-overview-of-tools-available-ykpr4h596#faq","mainEntity":[{"@type":"Question","name":"How do I attach GDB to a Linux kernel running in QEMU?","acceptedAnswer":{"@type":"Answer","text":"Start QEMU with the -s flag, which creates a TCP socket on port 1234 for GDB to connect to. Then run `gdb vmlinux` on the host (vmlinux is the uncompressed kernel binary with symbols included) and connect with `target remote localhost:1234`. From there you can set breakpoints, inspect backtraces, and use standard GDB commands. Only one QEMU instance at a time can use -s. Kernel developers debugging QEMU setups share notes and discoveries on daily.dev."}},{"@type":"Question","name":"How do I enable and use kmemleak to detect memory leaks in the Linux kernel?","acceptedAnswer":{"@type":"Answer","text":"Enable kmemleak under Memory Debugging in the kernel config, setting 'Maximum kmemleak early log entries' high enough (e.g. 2000) to prevent it from disabling itself at boot. After booting, trigger a manual scan with `echo scan >> /sys/kernel/debug/kmemleak` and read results with `cat /sys/kernel/debug/kmemleak`. Wait several tenths of seconds and run multiple scans to confirm no leaks are present. Linux systems engineers tracking down memory leaks find relevant kernel debugging discussions on daily.dev."}}]}
```

