[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decladebug

Title:Digital Ladebug debugger
Moderator:TLE::LUCIA
Created:Fri Feb 28 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:969
Total number of notes:3959

912.0. "Troubles printing addresses as structs" by CXXC::MJHANS (Matthew Hanselman, DEC C/C++) Mon Apr 07 1997 12:32

    Using ladebug 4.0-33 and DEC C++ V5.5:
    
    You cannot typecast an address to a struct and print it out -- it
    causes ladebug to seg fault.
    
    I would have assumed you could do this.
    
    In this example, get the address of "s", and print the address
    typecasted as "S":
    
    ----------------------------------
    struct S {
      int a;
      float b;
    } s;
    
    main()
    {
      return 0;
    }
    ----------------------------------
    
    Welcome to the Ladebug Debugger Version 4.0-33
    ------------------ 
    object file name: a.out 
    Reading symbolic information ...done
    (ladebug) stop in main
    [#1: stop in int main(void) ]
    (ladebug) r
    [1] stopped at [int main(void):8 0x120002120]
          8   return 0;
    (ladebug) p &s
    0x1400001d0
    (ladebug) p (S) 0x1400001d0
    
    Ladebug Debugger Version 4.0-33 caught signal "Segmentation fault"
    (11).
    This is an unexpected condition and may indicate the presence of a
    defect.
    If you wish to report this, please include the stack trace that
    follows.
    Diagnostic stack trace ...
    0x124c0cf8
    0x124c0e20
    0x124cbb4c
    0x123f5724
    0x123f5988
    0x123137e8
    0x12222a04
    0x12226f50
    0x12216b5c
    0x12213c0c
    end of diagnostic stack trace.
    Fatal error: Segmentation fault
    
    
    							- Matt
T.RTitleUserPersonal
Name
DateLines
912.1TLE::SHAMIMMon Apr 07 1997 14:0846
By doing

>> (ladebug) p (S) 0x1400001d0

you are asking a long value to be casted as a struct. From this command,
ladebug can't tell that 0x1400001d0 is an address.

p *(S*)0x1400001d0

would work better.


Also, I can't reproduce the segfault with any version of the debugger from
v30-v34.

Here is what I get with V4.0-35 (the current build one)

Welcome to the Ladebug Debugger Version 4.0-35
------------------ 
object file name: note912 
Reading symbolic information ...done
(ladebug) bp main;r
[#1: stop in int main(void) ]
[1] stopped at [main:8 0x120001110]
      8       return 0;
(ladebug) p s
struct S {
  a = 0; 
  b = 0; 
}
(ladebug) p &s
0x140000160
(ladebug) p (S)0x140000160
Unable to cast long to struct { ... }
Error: no value for (S)5368709472
(ladebug) p *(S*)0x140000160
struct S {
  a = 0; 
  b = 0; 
}
(ladebug) 


thanks
shamim
912.2Win some, lose someCXXC::MJHANSMatthew Hanselman, DEC C/C++Mon Apr 07 1997 14:168
    I keyed the base note using C++; I just tried it with C, and with C,
    ladebug will indeed complain about casting a long.  So there is a bug
    in that ladebug should be issuing a warning, not seg faulting, under
    C++.
    
    I'll use the syntax you suggested to do my work -- thanks.
    
    								- Matt
912.3TLE::SHAMIMWed Apr 09 1997 15:356
OK, I reproduced it with C++ and have fixed the problem.

The fix will be available in V4.0-36.

shamim