Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:48:42+00:00 2026-06-12T19:48:42+00:00

I have written a pretty-printer using the GDB Python interface for a (C) struct

  • 0

I have written a pretty-printer using the GDB Python interface for a (C) struct that has a tendency to change between software releases. Since the format is fluctuating I have tried to make the printer dynamic enough to adapt and always try to print something useful instead of throwing a Python exception.

Right now there are two major formats that I need to support but there is likely to be a few more in the future. I would like to write some unit tests for the printer to avoid having to manually load coredumps from different releases to test it.

I thought that maybe I could serialize the gdb.Value from within a debugging session and load them in my unit tests but I wasn’t able to do it (pickle didn’t work with gdb.Value). The core-dumps are really large so storing them with the pretty-printer and script GDB for the tests is not an option.

How can I unit-test my pretty printer without keeping huge core-dumps around?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:48:43+00:00Added an answer on June 12, 2026 at 7:48 pm

    How can I unit-test my pretty printer without keeping huge core-dumps around?

    Keep small core dumps 🙂

    Let’s assume you have struct Foo that you have a pretty printer for, and that keeps changing between releases.

    Compile the following program:

    #include <stdlib.h>
    #include "foo.h"
    int main()
    {
       struct Foo f;
       // initialize f with some values
       abort();
    }
    

    Compile and run this program, store it and the resulting core as foo-v2 and foo-v2.core (assuming you are now on version 2 of the struct Foo). The core should be quite small.

    Now checkout foo.h that corresponds to version 1 of struct Foo from your revision control system (you do use a revision control system, right?). Rebuild and re-run the program, store it as foo-v1 and foo-v1.core.

    Now, with every release, you just have to rebuild/rerun above program, and compare output of GDB pretty printer with expected result. If it still works ok, you are done. If not, struct Foo must have changed, and you need to update your pretty printer.

    Save the new binary and core as foo-v3 and foo-v3.core, update the pretty printer, then test it against all foo-vN and foo-vN.core pairs (for the test itself, use GDB unittesting framework that comes with GDB sources).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some code that works pretty well, but I have a strange
I have written a simple server - client program with Swing interface using singleton
I have written a pretty simple Windows service in C# that starts up automatically
We have written a pretty complex web application which has following requirements: It has
I have written a pretty basic upload script that takes the file and uploads
I have written something like this pretty easily in C# ( string GetUrl(new {
I have written a code and i'm pretty much stuck. In the following code,
I'm pretty new in C#. I have Dll written on C++ by myself and
I've written an entire app pretty successfully in Django but I have this nagging
I have written a function that sorts a big scale of data. To test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.