bbdbg: Debug a target environment generated by bitbake

bbdbg does the legwork to give you a gdb instance tailored for a target
environment generated from a local bitbake build tree. This saves
the time otherwise spent by building and installing an SDK for the same.

Documentation:

```
3 15:52:42 andrew@mistburn:~/src/openbmc/openbmc-tools/bbdbg (bbdbg) $ ./bbdbg
./bbdbg: 26: 1: parameter not set
NAME
        bbdbg - debug applications in a target environment built by bitbake

SYNOPSIS
        bbdbg PATH FILE CORE PACKAGES

DESCRIPTION
        PATH is the path to the root of a bitbake build directory
        FILE is the absolute path to the binary of interest in the target environment
        CORE is an optional core file generated by FILE. Pass '-' for no core file
        PACKAGES will be used to populate a temporary rootfs for debugging FILE

EXAMPLE
        bbdbg ~/src/openbmc/openbmc/build/p10bmc \
                /usr/bin/nvmesensor - \
                dbus-sensors dbus-sensors-dbg
```

Example use:

```
3 15:50:40 andrew@mistburn:~/src/openbmc/openbmc-tools/bbdbg (bbdbg) $ ./bbdbg ~/src/openbmc/openbmc/build/p10bmc /usr/bin/nvmesensor obmcdump_3_1641877435/core.nvmesensor.0.db0e4de236a6448e9005e85a0dffb348.1554.1641877432000000 dbus-sensors dbus-sensors-dbg
+ bbdbg_opkg update
+ LD_LIBRARY_PATH=/home/andrew/src/openbmc/openbmc/build/p10bmc/tmp/sysroots-components/x86_64/libsolv-native/usr/lib /home/andrew/src/openbmc/openbmc/build/p10bmc/tmp/sysroots-components/x86_64/opkg-native/usr/bin/opkg -V0 -f /home/andrew/src/openbmc/openbmc/build/p10bmc/tmp/work/p10bmc-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/opkg.conf -o /tmp/bbdbg.375 update
+ bbdbg_opkg install dbus-sensors dbus-sensors-dbg
+ LD_LIBRARY_PATH=/home/andrew/src/openbmc/openbmc/build/p10bmc/tmp/sysroots-components/x86_64/libsolv-native/usr/lib /home/andrew/src/openbmc/openbmc/build/p10bmc/tmp/sysroots-components/x86_64/opkg-native/usr/bin/opkg -V0 -f /home/andrew/src/openbmc/openbmc/build/p10bmc/tmp/work/p10bmc-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/opkg.conf -o /tmp/bbdbg.375 install dbus-sensors dbus-sensors-dbg
+ [ - = obmcdump_3_1641877435/core.nvmesensor.0.db0e4de236a6448e9005e85a0dffb348.1554.1641877432000000 ]
+ echo obmcdump_3_1641877435/core.nvmesensor.0.db0e4de236a6448e9005e85a0dffb348.1554.1641877432000000
+ gdb-multiarch -q -iex set solib-absolute-prefix /tmp/bbdbg.375 -iex add-auto-load-safe-path /tmp/bbdbg.375 /tmp/bbdbg.375/usr/bin/nvmesensor obmcdump_3_1641877435/core.nvmesensor.0.db0e4de236a6448e9005e85a0dffb348.1554.1641877432000000
Reading symbols from /tmp/bbdbg.375/usr/bin/nvmesensor...
Reading symbols from /tmp/bbdbg.375/usr/bin/.debug/nvmesensor...
[New LWP 1554]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/bin/nvmesensor'.
Program terminated with signal SIGSEGV, Segmentation fault.
 #0  0x76b88f50 in epoll_wait (epfd=<optimised out>, events=0x7edf1478, maxevents=128, timeout=-1) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30
30      ../sysdeps/unix/sysv/linux/epoll_wait.c: No such file or directory.
(gdb) bt
 #0  0x76b88f50 in epoll_wait (epfd=<optimised out>, events=0x7edf1478, maxevents=128, timeout=-1) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30
 #1  0x0044adf4 in boost::asio::detail::epoll_reactor::run (ops=..., usec=<optimised out>, this=<optimised out>) at /usr/include/boost/asio/detail/impl/epoll_reactor.ipp:501
 #2  boost::asio::detail::scheduler::do_run_one (ec=..., this_thread=..., lock=<synthetic pointer>..., this=0x17b1ea8) at /usr/include/boost/asio/detail/impl/scheduler.ipp:470
 #3  boost::asio::detail::scheduler::run (ec=..., this=0x17b1ea8) at /usr/include/boost/asio/detail/impl/scheduler.ipp:204
 #4  boost::asio::io_context::run (this=0x7edf1234, this=0x7edf1234) at /usr/include/boost/asio/impl/io_context.ipp:63
 #5  main () at ../../../../../../workspace/sources/dbus-sensors/src/NVMeSensorMain.cpp:274
(gdb) quit
+ set +x
3 15:51:10 andrew@mistburn:~/src/openbmc/openbmc-tools/bbdbg (bbdbg) $
```

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I82f5872742253351c7ac8d25b479ac8194e07afd
1 file changed
tree: 9d57f566145dddc97b039b5191b6ad93a7b0abf6
  1. adcapp/
  2. altitude/
  3. autojson/
  4. bbdbg/
  5. bi2cp/
  6. cla-signers/
  7. dbus-pcap/
  8. dbus-vis/
  9. dbusView/
  10. ddconvnotrunc/
  11. expectedJsonChecker/
  12. format-yaml/
  13. maintainers/
  14. netboot/
  15. openbmc-autobump/
  16. openbmc-events/
  17. openbmctool/
  18. overlay/
  19. pldm/
  20. prepare-emmc-qemu/
  21. pretty-journal/
  22. pwmtachtool/
  23. reboot/
  24. reboot-ping-pong/
  25. rootfs_size/
  26. sensor_yaml_config/
  27. tracing/
  28. upload_and_update/
  29. witherspoon-debug/
  30. LICENSE
  31. MAINTAINERS
  32. README.md
README.md

The OpenBMC Tools Collection

The goal of this repository is to collect the two-minute hacks you write to automate interactions with OpenBMC systems.

It's highly likely the scripts don't meet your needs - they could be undocumented, dysfunctional or utterly broken. Please help us improve!

Repository Rules

  • Always inspect what you will be executing
  • Some hacking on your part is to be expected

If you're still with us

Then this repository aims to be the default destination for your otherwise un-homed scripts. As such we are setting the bar for submission pretty low, and we aim to make the process as easy as possible.

Sending patches

Please use gerrit for all patches to this repository:

Do note that you will need to be party to the OpenBMC CLA before your contributions can be accepted. See Gerrit Setup and CLA for more information.

What we will do once we have your patches

So long as your patches look sane with a cursory glance you can expect them to be applied. We may push back in the event that similar tools already exist or there are egregious issues.

What you must have in your patches

We don't ask for much, but you need to give us at least a Signed-off-by, use SPDX markers in your source files and put your work under an Apache 2.0 compatible license.

How you consume the repository

There's no standard way to install the scripts housed here, and adding parts of the repository to your PATH might be a bit of a dice-roll. We may also move or remove scripts from time to time as part of housekeeping. It's probably best to copy things out if you need stability.