bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

help with gdb bug evaluating enumerated types


From: Vuong Tran
Subject: help with gdb bug evaluating enumerated types
Date: Wed, 04 Apr 2001 14:32:19 -0700

Attached is a sample program illustrating gdb cannot
understand the enumerated type when the most significant
bit is set, resulting in a 'negative' value for the enumeration.
>From what I know, the enumerated types work perfectly
during execution time and it's only when we're examining
these variables in gdb that gdb gives us an error message.
Included below is the captured output of gdb...

Copyright 1996 Free Software Foundation, Inc...
(gdb) b main
Breakpoint 1 at 0x10794: file tst6.c, line 24.
(gdb) run
Starting program: /users/spike/test/a.out
warning: Unable to find dynamic linker breakpoint function.
warning: GDB will be unable to debug shared library initializers
warning: and track explicitly loaded dynamic code.

Breakpoint 1, main (argc=1, argv=0xeffff8b4) at tst6.c:24
24              MyValidEnums tmp = MY_ENUM_4;
(gdb) n
25              MyInvalidEnums tmp2 = MY_VAL_1;
(gdb) n
27              printf("Hello World\n");
(gdb) print tmp
$1 = MY_ENUM_4
(gdb) print tmp2
$2 = <error type>
(gdb)

Regards

Vuong Tran
Mgr, SW Development
Andiamo Systems, Inc.
#include <stdio.h>

#define MY_VALID_BASE   0xff00
#define MY_BASE 0x80000000

typedef enum _MyValidEnums {
  MY_ENUM_0 = MY_VALID_BASE,
  MY_ENUM_1 = MY_VALID_BASE | 2,
  MY_ENUM_2 = MY_VALID_BASE | 0x10,
  MY_ENUM_3 = MY_VALID_BASE | 0x20,
  MY_ENUM_4,
} MyValidEnums;

typedef enum _MyInvalidEnums {
  MY_VAL_0 = MY_BASE,
  MY_VAL_1,
  MY_VAL_2,
} MyInvalidEnums;

int main(int argc, char *argv[])
{
        int i;
        MyValidEnums tmp = MY_ENUM_4;
        MyInvalidEnums tmp2 = MY_VAL_1;

        printf("Hello World\n");
        printf("tmp: %x, tmp2: %x\n", tmp, tmp2);

        return(0);
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]