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 6617617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:43:31+00:00 2026-05-25T20:43:31+00:00

Below is the problem statement. At the bottom is my actual question if you

  • 0

Below is the problem statement. At the bottom is my actual question if you end up just skimming the problem statement.

edit

I forgot to mention: I’m linking with --no-strip-discarded --discard-none. One of the object files (pre-link) gets matched by grep when I search for the type in question, but I’m not finding that string after dumping info from the object file with nm, objdump, and readelf.


I’m looking at some C code that uses an idiom along the lines of:

// somecode.h
typedef struct {
  // ...
  volatile unsigned char *member1;
} Type1_t;

typedef struct {
  unsigned int member1:16;
  unsigned int member2:32;
  unsigned int member3:16;
} Type2_t;

// somecode.c
// ...

void someFunction( Type1_t *type1Ptr ) {
  // ...
  doSomething( ((Type2_t*)type1Ptr->member1)->accessType2Member );
}

Please ignore any objections you might have to the coding style, that isn’t my question.

In this case, no instance of Type2_t is ever instantiated, so as best I can tell the compiler determined it wasn’t necessary to emit debugging information about the type.

I’m attempting to monitor the behavior of code using this casted data to track down a problem, but the best I’ve managed to do is get gdb to print the array in question as an array of bytes. I can set a watch on the array with:

watch {char[12]}type1Ptr->member1

… but in addition to not actually displaying member1, member2, & member3, the pretty-printer for char arrays prints it out as a sequence of the form \000\032\021… etc (a note on this: I’m in solaris, and gdb 7.2 in Solaris has issues with libiconv, which gdb uses for code page translations. I’m stuck with ISO-8859-1 for now. I’m unsure if that’s why it doesn’t just print it as a sequence of hex characters), so I end up either having to print the contents with display or some other mechanism, then interpret the contents in my head.


What I’m looking for:

  • Is there a way to make gcc emit all debug symbols, even if the type in question only shows up when doing a cast?
    • … or if the type isn’t used at all in actual code
  • Can I just include a header in gdb somehow so the type is defined?
  • This one is probably far fetched, but: does gdb have any facility for doing more complex casts than just casting to currently defined types? As an example, is there a way to do something like the following

(gdb) print {struct { unsigned int:16 member1; unsigned int:32 member2;
          unsigned int:16 member3;} }( type1Ptr->member1 )
  • 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-05-25T20:43:32+00:00Added an answer on May 25, 2026 at 8:43 pm

    It looks like this question/answer takes care of the 2nd question, and sort of alleviates the need for #3.

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

Sidebar

Related Questions

I have a problem with the SQL statement detailed below. The query returns the
I have a problem when trying to execute this update statement (below) using C#
The problem below is ralated to my previous question Converting static link library to
Here is my current question: I'm guessing that my problem (described below) is being
The if statement below has a problem in it somewhere and I can not
I have the below Problem Statement PS: Given a string str and a Non-Empty
Below is the Problem Statement: PS: Given a string and a non-empty substring sub,
Im stuck with the below problem. Problem Statement: Given a non-negative int n, return
Below is the code snippet with comments which describes the problem statement. We have
I have a design and object structuring related question. Here is the problem statement:

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.