Technical Travesties and Tiny Tips | A blog by Joshua Bakita

Notes on using the -ggdb3 flag when building the Linux Kernel

Published 06.16.2020 by Joshua Bakita

If you've seen my prior post on configuring the Linux Kernel for debugging, you may have also seen my note recommending the inclusion of the -ggdb3 flag to get more thorough debug symbols. Unfortunately, this can cause your kernel modules be so large that the boot image (ramdisk) grows beyond what GRUB supports loading and will cause your boot process to hang.

To prevent this from happening, also pass the INSTALL_MOD_STRIP=1 parameter when running "make modules_install". This will strip out the debugging symbols from your kernel modules when the build system creates your ramdisk. Note that this will prevent you from debugging your installed kernel modules, but should make your system bootable again and does not effect the debuggability of core kernel components like the memory manager or scheduler.

Also note that using the -ggdb3 option will cause your kernel build directories to consume an enormous amount of space (81GiB right now on my system). To prevent a full build from taking upwards of a day, you'll want to consider buying a fast SSD (I've had good luck with the Sabrent Rocket 1TB NVMe SSD so far).

How to configure the Linux Kernel for debugging with kgdb

Published 04.07.2020 by Joshua Bakita

To make kgdb or the QEMU debugger work with the Linux kernel, there are a number of critical, undocumented configuration changes that must be made for breakpoints to work. I keep having to figure out these changes every time a build a new copy of the kernel for debugging, and so I'm documenting them here as much for my own reference as for yours. To fix your configuration, run "make menuconfig" from the top-level linux kernel directory and toggle the following settings (you can use the '/' key to search for these in the menu-based configuration system):

  • Enable CONFIG_KGDB (if you haven't yet) so that you can attach to the kernel with gdb (Note that you do not need this if you only intend to debug through a virtual machine's debugger (eg. QEMU with the -S option))
  • Enable CONFIG_DEBUG_INFO to get symbols for GDB and for backtraces in kernel faults
  • Disable CONFIG_DEBUG_RODATA to allow gdb to set software breakpoints (Note that this has been renamed to CONFIG_KERNEL_STRICT_RWX in recent kernels)
  • Disable CONFIG_RANDOMIZE_BASE to prevent the kernel from being moved to a random location on boot (randomization is good for security, but makes your symbols meaningless when debugging)
  • If you get "ld: kernel image bigger than KERNEL_IMAGE_SIZE" on x86_64 after enabling the previous option, change "#ifdef CONFIG_RANDOMIZE_BASE" at the bottom of arch/x86/include/asm/page_64_types.h to "#if 1"
If possible, make these changes from "make menuconfig" rather than by directly editing the .config file. The menu-based configuration system will automatically resolve the config options dependencies or dependees needed for the above changes.

If you want to be able to resolve macros in GDB, also include the KCFLAGS=-ggdb3 parameter when you call make.

Happy debugging! If you need help using kgdb, be sure to look at the Linux Kernel kgdb documentation.

Why Study Abroad?

Published 08.11.2016 by Joshua Bakita

Now a little over two months into my stay in London, my once sceptical opinion of study abroad has been overwhelmed by the evidence to the contrary. I would like to address some of the reasons for my shift in my opinion, in the hope that it can better inform the decisions of others.

Cost, inefficiency, and hassle seem to top the typical list of concerns over study abroad. While the cost might be higher and the classes available less matched to one's degree, the benefits far overwhelm those costs. By taking classes outside of one's specialty, a variety of different perspectives emerge on how people view the world. That variation is only amplified by the different backgrounds of instructors on study abroad programs. In response to the financial argument, the global perspective indirectly pays off in employment later. One can take more diverse angles on problems and come up with solutions more catered to a global audience. Since innovation is primarily about solving problems (source) and economists near universally agree that innovation drives growth (OECD report), solutions applicable to the unknown or underserved needs of more people will enable higher problem solving productivity. That should ultimately lead to greater success in the corporate world.

My particular semester in London may look rather odd, a computer science major taking classes in economics, drama, and journalism while interning in the House of Commons? Why would I do that? My reasoning is that if I am going to round out my education with liberal arts classes, I may as well take them in a location that will vary my perspectives as much as possible. Through taking these classes abroad in London, I experience both a variation in topical and instructional views.

A great example of this is my international economics class. Taught by professor Rajiv Maluste, he covers all the nooks and crannies of globalisation from his extremely diverse perspective. His background includes growing up in the United States, working at Morgan Stanley's locations in Asia, Europe, and America, employment by the US Treasury Department, and studying, teaching, and consulting in London. His perspective contrasts dramatically from when I last took economics from a local academic in the US. One interesting aspect that I would not have realized without his class regards how the importance of the international market suppresses overt international conflict. One example is the US and China. While they may subtly challenge each other's strength, the relationship must remain stable on the whole. They are simply too interdependent. China depends tremendously on US markets for its manufactured goods, and the US depends on China to buy its government bonds [China buys them to keep the Renminbi competitive (source)]. Rajiv confidently teaches this because of his unusual perspective combining work at the US Treasury and experience in international capital markets. My valuable takeaway is the the present conflict in the South China Sea really has minimal bearing on the safety of investment in China.

A second example comes from my journalism class. Taught by former BBC journalist and radio broadcaster Claire Bolderson, it has been very revealing in its coverage of the modern journalistic process. I now know that public relations has far more influence over the media than it used to and that budget cuts in many newsrooms can result in journalism which rarely adds or verifies. The journalism in those outlets just rehashes the newswire, borrows from other outlets, and prints press releases. Local coverage is now largely fed by tips and other open sources (like social media). Claire's background in the balanced newsrooms of BBC seem to allow her to see all of this much more clearly than most academics do. If I want to stay informed accurately, I just need to carefully evaluate my sources and understand where they are coming from. Following the trending topics on Google News will rarely tell what is really important.

Having probably talked enough about the useful perspectives that one can gain from classes, I would like to talk some about interning abroad. As I touched on earlier, I am currently working as a Parliamentary Intern for James Berry MP. Once again outside of my typical field, it has shown me a tremendous amount about how the UK government culture varies from the US. They clearly operate with the people's best wishes in mind. Most of the work of my office is not captaining legislation, but acting on a constituent's behalf. The day-to-day for most of the staff involves sorting snagged visa requests, unraveling tangled benefits claims, and just generally helping our constituents interact with their government. This provides an interesting contrast with the US government. The members of the House of Representatives have much larger constituencies than those of a comparable member in the UK House of Commons. The unavoidable result is that UK representatives spend more time focusing on and championing local issues. From my point of view, this constant local hum keeps UK representatives more grounded than their US counterparts. The study abroad experience factors in by showing me what a member of the House of Commons actually spends their time on.

Another interesting thing that I have run into through my work in Parliament concerns the work culture of mainland Europe. While all my coworkers are from the UK, I regularly run into nationals from other major EU economies when attending outside briefings and events. They seem to think of work as a more slow and steady affair than many UK people do. Employees stay at companies for longer periods (OECD data) and generally work fewer hours (OECD data) for example. I imagine that the UK's decision to leave the EU was at least influenced by that cultural friction. Minimally notable in working hours, the UK is statistically far closer to the US than France or Germany (OECD data).

Hopefully my experience makes it clear why studying abroad in a cross-disciplinary manner is extremely valuable. One gains different perspectives that are simply unavailable in the classroom back home. Those perspectives might not be itemisable on one's resume, but they do enable one to understand and solve problems in a way that would be impossible otherwise. That capability can further enable innovation and accelerate success.

Welcome!

Published 04.11.2016 by Joshua Bakita

Hello and welcome to my blog! There is not too much here right now, but I hope to add more material over the coming months. Expect to hear travel advice, career learnings, and technical discoveries.