2019-08-07 14:37:16 +00:00
|
|
|
---
|
|
|
|
layout: default
|
|
|
|
title: Debugging
|
|
|
|
parent: Advanced topics
|
|
|
|
nav_order: 4
|
2019-08-22 18:33:39 +00:00
|
|
|
permalink: /advanced-topics/debugging/
|
2019-08-07 14:37:16 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Debugging issues
|
2019-09-05 20:21:13 +00:00
|
|
|
{: .no_toc}
|
2019-08-07 14:37:16 +00:00
|
|
|
|
|
|
|
- TOC
|
|
|
|
{:toc}
|
|
|
|
---
|
|
|
|
|
|
|
|
## Debugging build scripts
|
2016-10-04 18:54:45 +00:00
|
|
|
|
|
|
|
While developing your build script, it may be useful to run bash within the
|
|
|
|
container:
|
|
|
|
|
|
|
|
```bash
|
2016-11-29 19:02:02 +00:00
|
|
|
$ python infra/helper.py shell $PROJECT_NAME # runs /bin/bash within container
|
2019-09-05 20:21:13 +00:00
|
|
|
$ compile # runs compilation manually
|
2016-10-04 18:54:45 +00:00
|
|
|
```
|
|
|
|
|
2019-08-07 14:37:16 +00:00
|
|
|
## Debugging fuzzers with GDB
|
2016-10-04 18:57:14 +00:00
|
|
|
|
2019-09-05 20:21:13 +00:00
|
|
|
If you wish to debug a fuzz target with gdb, you can use the base-runner-debug
|
2018-07-16 04:04:41 +00:00
|
|
|
image:
|
2016-10-04 18:57:14 +00:00
|
|
|
|
|
|
|
```bash
|
2019-09-05 20:21:13 +00:00
|
|
|
# Copy input testcase into host output directory so it can be accessed
|
2018-07-16 04:04:41 +00:00
|
|
|
# within the Docker image.
|
|
|
|
$ cp /path/to/testcase build/out/$PROJECT_NAME
|
|
|
|
|
2019-09-05 20:21:13 +00:00
|
|
|
# Run the Docker image containing GDB.
|
2018-07-16 04:04:41 +00:00
|
|
|
$ python infra/helper.py shell base-runner-debug
|
|
|
|
$ gdb --args /out/$PROJECT_NAME/$FUZZ_TARGET_NAME /out/$PROJECT_NAME/testcase
|
2016-10-04 18:57:14 +00:00
|
|
|
```
|
2018-07-16 04:04:41 +00:00
|
|
|
|
2019-09-05 20:21:13 +00:00
|
|
|
**Note:** The `base-runner-debug` image does not have access to your sources, so
|
2018-07-16 04:04:41 +00:00
|
|
|
you will not be able to do source code level debugging. We recommend integrating
|
2019-08-07 14:37:16 +00:00
|
|
|
your fuzz target upstream as part of
|
|
|
|
[ideal integration]({{ site.baseurl }}/advanced-topics/ideal-integration/)
|
2018-07-16 04:04:41 +00:00
|
|
|
for debugging purposes.
|