C++ Can not watch membervariables within classes

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
when I want to watch membervariables, which belongs to a C++ class, I got always "not in scope" in AVR Studio 4.12.
I use Winavr 3.4.6 to compile my source.
I use the *.elf file for debugging with the dwarf-2 option.
Is there a hint to do?

regards

Andre

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Could you do

avr-readelf -wi objectfile

, find the entry for a member variable that is 'out of scope' and post the information here?

Torleif

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Torleifs,
I have extracred the information from one class (here Usart0) because the whole *.elf file is very large
Here is the content:

    The section .debug_info contains:

    Compilation Unit @ 0:
    Length: 1109
    Version: 2
    Abbrev Offset: 0
    Pointer Size: 2
    <0>: Abbrev Number: 1 (DW_TAG_compile_unit)
    DW_AT_stmt_list : 0
    DW_AT_high_pc : 0x20a
    DW_AT_low_pc : 0
    DW_AT_producer : (indirect string, offset: 0xf6): GNU C++ 3.4.6
    DW_AT_language : 4 (C++)
    DW_AT_name : (indirect string, offset: 0x94): Usart0.cpp
    DW_AT_comp_dir : (indirect string, offset: 0x236): C:\Projekte\U5_Frankfurt\FGS4
    <1><21>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0x2b9): signed char
    DW_AT_byte_size : 1
    DW_AT_encoding : 6 (signed char)
    <1><28>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0xb4): unsigned char
    DW_AT_byte_size : 1
    DW_AT_encoding : 8 (unsigned char)
    <1><2f>: Abbrev Number: 3 (DW_TAG_base_type)
    DW_AT_name : int
    DW_AT_byte_size : 2
    DW_AT_encoding : 5 (signed)
    <1><36>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0x19d): unsigned int
    DW_AT_byte_size : 2
    DW_AT_encoding : 7 (unsigned)
    <1><3d>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0x28d): long int
    DW_AT_byte_size : 4
    DW_AT_encoding : 5 (signed)
    <1><44>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0xda): long unsigned int
    DW_AT_byte_size : 4
    DW_AT_encoding : 7 (unsigned)
    <1><4b>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0x1fb): long long int
    DW_AT_byte_size : 8
    DW_AT_encoding : 5 (signed)
    <1><52>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0x1c3): long long unsigned int
    DW_AT_byte_size : 8
    DW_AT_encoding : 7 (unsigned)
    <1><59>: Abbrev Number: 4 (DW_TAG_structure_type)
    DW_AT_sibling : <251>
    DW_AT_name : (indirect string, offset: 0x222): CUsart0
    DW_AT_byte_size : 1
    DW_AT_decl_file : 3
    DW_AT_decl_line : 102
    <2><65>: Abbrev Number: 4 (DW_TAG_structure_type)
    DW_AT_sibling :
    DW_AT_name : (indirect string, offset: 0x150): TU0RxFifo
    DW_AT_byte_size : 131
    DW_AT_decl_file : 3
    DW_AT_decl_line : 105
    <3><71>: Abbrev Number: 5 (DW_TAG_member)
    DW_AT_name : (indirect string, offset: 0x33): WrPtr
    DW_AT_decl_file : 3
    DW_AT_decl_line : 106
    DW_AT_type : <28>
    DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
    <3><7f>: Abbrev Number: 5 (DW_TAG_member)
    DW_AT_name : (indirect string, offset: 0x2e3): RdPtr
    DW_AT_decl_file : 3
    DW_AT_decl_line : 107
    DW_AT_type : <28>
    DW_AT_data_member_location: 2 byte block: 23 1 (DW_OP_plus_uconst: 1)
    <3><8d>: Abbrev Number: 5 (DW_TAG_member)
    DW_AT_name : (indirect string, offset: 0xae): Count
    DW_AT_decl_file : 3
    DW_AT_decl_line : 108
    DW_AT_type : <28>
    DW_AT_data_member_location: 2 byte block: 23 2 (DW_OP_plus_uconst: 2)
    <3><9b>: Abbrev Number: 5 (DW_TAG_member)
    DW_AT_name : (indirect string, offset: 0x21b): Buffer
    DW_AT_decl_file : 3
    DW_AT_decl_line : 109
    DW_AT_type : <251>
    DW_AT_data_member_location: 2 byte block: 23 3 (DW_OP_plus_uconst: 3)
    <3>: Abbrev Number: 6 (DW_TAG_subprogram)
    DW_AT_sibling :
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x2af): operator=
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2c5): _ZN7CUsart09TU0RxFifoaSERKS0_
    DW_AT_type : <26f>
    DW_AT_artificial : 1
    DW_AT_declaration : 1
    <4>: Abbrev Number: 7 (DW_TAG_formal_parameter)
    DW_AT_type : <275>
    DW_AT_artificial : 1
    <4>: Abbrev Number: 8 (DW_TAG_formal_parameter)
    DW_AT_type : <27b>
    <3>: Abbrev Number: 9 (DW_TAG_subprogram)
    DW_AT_sibling :
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x150): TU0RxFifo
    DW_AT_artificial : 1
    DW_AT_declaration : 1
    <4>: Abbrev Number: 7 (DW_TAG_formal_parameter)
    DW_AT_type : <275>
    DW_AT_artificial : 1
    <4>: Abbrev Number: 8 (DW_TAG_formal_parameter)
    DW_AT_type : <27b>
    <3>: Abbrev Number: 10 (DW_TAG_subprogram)
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x150): TU0RxFifo
    DW_AT_artificial : 1
    DW_AT_declaration : 1
    <4>: Abbrev Number: 7 (DW_TAG_formal_parameter)
    DW_AT_type : <275>
    DW_AT_artificial : 1
    <2>: Abbrev Number: 4 (DW_TAG_structure_type)
    DW_AT_sibling : <17d>
    DW_AT_name : (indirect string, offset: 0xec): TU0TxFifo
    DW_AT_byte_size : 131
    DW_AT_decl_file : 3
    DW_AT_decl_line : 111
    <3>: Abbrev Number: 5 (DW_TAG_member)
    DW_AT_name : (indirect string, offset: 0x33): WrPtr
    DW_AT_decl_file : 3
    DW_AT_decl_line : 112
    DW_AT_type : <28>
    DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
    <3><10b>: Abbrev Number: 5 (DW_TAG_member)
    DW_AT_name : (indirect string, offset: 0x2e3): RdPtr
    DW_AT_decl_file : 3
    DW_AT_decl_line : 113
    DW_AT_type : <28>
    DW_AT_data_member_location: 2 byte block: 23 1 (DW_OP_plus_uconst: 1)
    <3><119>: Abbrev Number: 5 (DW_TAG_member)
    DW_AT_name : (indirect string, offset: 0xae): Count
    DW_AT_decl_file : 3
    DW_AT_decl_line : 114
    DW_AT_type : <28>
    DW_AT_data_member_location: 2 byte block: 23 2 (DW_OP_plus_uconst: 2)
    <3><127>: Abbrev Number: 5 (DW_TAG_member)
    DW_AT_name : (indirect string, offset: 0x21b): Buffer
    DW_AT_decl_file : 3
    DW_AT_decl_line : 115
    DW_AT_type : <251>
    DW_AT_data_member_location: 2 byte block: 23 3 (DW_OP_plus_uconst: 3)
    <3><135>: Abbrev Number: 6 (DW_TAG_subprogram)
    DW_AT_sibling : <155>
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x2af): operator=
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x109): _ZN7CUsart09TU0TxFifoaSERKS0_
    DW_AT_type : <286>
    DW_AT_artificial : 1
    DW_AT_declaration : 1
    <4><149>: Abbrev Number: 7 (DW_TAG_formal_parameter)
    DW_AT_type : <28c>
    DW_AT_artificial : 1
    <4><14f>: Abbrev Number: 8 (DW_TAG_formal_parameter)
    DW_AT_type : <292>
    <3><155>: Abbrev Number: 9 (DW_TAG_subprogram)
    DW_AT_sibling : <16d>
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0xec): TU0TxFifo
    DW_AT_artificial : 1
    DW_AT_declaration : 1
    <4><161>: Abbrev Number: 7 (DW_TAG_formal_parameter)
    DW_AT_type : <28c>
    DW_AT_artificial : 1
    <4><167>: Abbrev Number: 8 (DW_TAG_formal_parameter)
    DW_AT_type : <292>
    <3><16d>: Abbrev Number: 10 (DW_TAG_subprogram)
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0xec): TU0TxFifo
    DW_AT_artificial : 1
    DW_AT_declaration : 1
    <4><175>: Abbrev Number: 7 (DW_TAG_formal_parameter)
    DW_AT_type : <28c>
    DW_AT_artificial : 1
    <2><17d>: Abbrev Number: 11 (DW_TAG_variable)
    DW_AT_name : (indirect string, offset: 0x13f): m_RxFifo
    DW_AT_decl_file : 3
    DW_AT_decl_line : 119
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x4c): _ZN7CUsart08m_RxFifoE
    DW_AT_type : <65>
    DW_AT_external : 1
    DW_AT_accessibility: 3 (private)
    DW_AT_declaration : 1
    <2><18f>: Abbrev Number: 11 (DW_TAG_variable)
    DW_AT_name : (indirect string, offset: 0x1c): m_TxFifo
    DW_AT_decl_file : 3
    DW_AT_decl_line : 120
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x7e): _ZN7CUsart08m_TxFifoE
    DW_AT_type :
    DW_AT_external : 1
    DW_AT_accessibility: 3 (private)
    DW_AT_declaration : 1
    <2><1a1>: Abbrev Number: 11 (DW_TAG_variable)
    DW_AT_name : (indirect string, offset: 0x62): m_SendBusy
    DW_AT_decl_file : 3
    DW_AT_decl_line : 121
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x184): _ZN7CUsart010m_SendBusyE
    DW_AT_type : <28>
    DW_AT_external : 1
    DW_AT_accessibility: 3 (private)
    DW_AT_declaration : 1
    <2><1b3>: Abbrev Number: 12 (DW_TAG_subprogram)
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x104): Init
    DW_AT_decl_file : 3
    DW_AT_decl_line : 125
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x12c): _ZN7CUsart04InitEv
    DW_AT_declaration : 1
    <2><1c0>: Abbrev Number: 13 (DW_TAG_subprogram)
    DW_AT_sibling : <1db>
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x0): Recv
    DW_AT_decl_file : 3
    DW_AT_decl_line : 126
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x1af): _ZN7CUsart04RecvEPc
    DW_AT_type : <28>
    DW_AT_declaration : 1
    <3><1d5>: Abbrev Number: 8 (DW_TAG_formal_parameter)
    DW_AT_type : <29d>
    <2><1db>: Abbrev Number: 13 (DW_TAG_subprogram)
    DW_AT_sibling : <1f6>
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x25): Send
    DW_AT_decl_file : 3
    DW_AT_decl_line : 127
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x39): _ZN7CUsart04SendEc
    DW_AT_type : <28>
    DW_AT_declaration : 1
    <3><1f0>: Abbrev Number: 8 (DW_TAG_formal_parameter)
    DW_AT_type : <268>
    <2><1f6>: Abbrev Number: 14 (DW_TAG_subprogram)
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x74): RecvAvail
    DW_AT_decl_file : 3
    DW_AT_decl_line : 128
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x15a): _ZN7CUsart09RecvAvailEv
    DW_AT_type : <28>
    DW_AT_declaration : 1
    <2><207>: Abbrev Number: 14 (DW_TAG_subprogram)
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0xa4): SendAvail
    DW_AT_decl_file : 3
    DW_AT_decl_line : 129
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0xc2): _ZN7CUsart09SendAvailEv
    DW_AT_type : <28>
    DW_AT_declaration : 1
    <2><218>: Abbrev Number: 14 (DW_TAG_subprogram)
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x2a): SendBusy
    DW_AT_decl_file : 3
    DW_AT_decl_line : 130
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x5): _ZN7CUsart08SendBusyEv
    DW_AT_type : <28>
    DW_AT_declaration : 1
    <2><229>: Abbrev Number: 12 (DW_TAG_subprogram)
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x172): IrqUSART0_RX_vect
    DW_AT_decl_file : 3
    DW_AT_decl_line : 131
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x254): _ZN7CUsart017IrqUSART0_RX_vectEv
    DW_AT_declaration : 1
    <2><236>: Abbrev Number: 12 (DW_TAG_subprogram)
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x29b): IrqUSART0_UDRE_vect
    DW_AT_decl_file : 3
    DW_AT_decl_line : 132
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x2e9): _ZN7CUsart019IrqUSART0_UDRE_vectEv
    DW_AT_declaration : 1
    <2><243>: Abbrev Number: 12 (DW_TAG_subprogram)
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x209): IrqUSART0_TX_vect
    DW_AT_decl_file : 3
    DW_AT_decl_line : 133
    DW_AT_MIPS_linkage_name: (indirect string, offset: 0x1da): _ZN7CUsart017IrqUSART0_TX_vectEv
    DW_AT_declaration : 1
    <1><251>: Abbrev Number: 15 (DW_TAG_array_type)
    DW_AT_sibling : <261>
    DW_AT_type : <268>
    <2><25a>: Abbrev Number: 16 (DW_TAG_subrange_type)
    DW_AT_type : <261>
    DW_AT_upper_bound : 127
    <1><261>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0x19d): unsigned int
    DW_AT_byte_size : 2
    DW_AT_encoding : 7 (unsigned)
    <1><268>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0x296): char
    DW_AT_byte_size : 1
    DW_AT_encoding : 8 (unsigned char)
    <1><26f>: Abbrev Number: 17 (DW_TAG_reference_type)
    DW_AT_byte_size : 2
    DW_AT_type : <65>
    <1><275>: Abbrev Number: 18 (DW_TAG_pointer_type)
    DW_AT_byte_size : 2
    DW_AT_type : <65>
    <1><27b>: Abbrev Number: 17 (DW_TAG_reference_type)
    DW_AT_byte_size : 2
    DW_AT_type : <281>
    <1><281>: Abbrev Number: 19 (DW_TAG_const_type)
    DW_AT_type : <65>
    <1><286>: Abbrev Number: 17 (DW_TAG_reference_type)
    DW_AT_byte_size : 2
    DW_AT_type :
    <1><28c>: Abbrev Number: 18 (DW_TAG_pointer_type)
    DW_AT_byte_size : 2
    DW_AT_type :
    <1><292>: Abbrev Number: 17 (DW_TAG_reference_type)
    DW_AT_byte_size : 2
    DW_AT_type : <298>
    <1><298>: Abbrev Number: 19 (DW_TAG_const_type)
    DW_AT_type :
    <1><29d>: Abbrev Number: 18 (DW_TAG_pointer_type)
    DW_AT_byte_size : 2
    DW_AT_type : <268>
    <1><2a3>: Abbrev Number: 20 (DW_TAG_subprogram)
    DW_AT_specification: <1b3>
    DW_AT_decl_file : 4
    DW_AT_decl_line : 34
    DW_AT_low_pc : 0
    DW_AT_high_pc : 0x8c
    DW_AT_frame_base : 0 byte block: ()
    <0><2b0>: Abbrev Number: 32 (DW_TAG_variable)
    DW_AT_name : (indirect string, offset: 0x21900193):
    DW_AT_decl_file : 147
    DW_AT_decl_line : 1
    DW_AT_type : <2ef15>
    DW_AT_lreadelf: Warning: Unable to locate entry 92 in the abbreviation table
    ocation : 0 byte block: ()
    <0><2bc>: Abbrev Number: 1 (DW_TAG_compile_unit)
    DW_AT_stmt_list : 0x275
    DW_AT_high_pc : 0x7104
    DW_AT_low_pc : 0x8c
    DW_AT_producer : (indirect string, offset: 0xec): TU0TxFifo
    DW_AT_language : 32 (Unknown: 20)
    DW_AT_name : (indirect string, offset: 0x21900193):
    DW_AT_comp_dir : (indirect string, offset: 0xef160193):
    <1><2d2>: Abbrev Number: 2 (DW_TAG_base_type)
    DW_AT_name : (indirect string, offset: 0xa00000):
    DW_AT_byte_size : 216
    DW_AT_encoding : 0 (void)
    <0><2da>: Abbrev Number: 32 (DW_TAG_variable)
    DW_AT_name : (indirect string, offset: 0xd8): v
    DW_AT_decl_file : 2
    DW_AT_decl_line : 0
    DW_AT_type : <18620100>
    DW_AT_location : 7 byte block: 3 0 0 1 68 0 0 (DW_OP_addr: 0; (Unknown location op))
    <-1><2ef>: Abbrev Number: 25 (DW_TAG_subprogram)
    DW_AT_sibling : <314>
    DW_AT_specification: <229>
    DW_AT_decl_file : 4
    DW_AT_decl_line : 75
    DW_AT_inline : 3 (declared as inline and inlined)
    <0><2fb>: Abbrev Number: 26 (DW_TAG_lexical_block)
    <1><2fc>: Abbrev Number: 27 (DW_TAG_variable)
    DW_AT_name : (indirect string, offset: 0x9f): data
    DW_AT_decl_file : 4
    DW_AT_decl_line : 76
    DW_AT_type : <28>
    <1><307>: Abbrev Number: 27 (DW_TAG_variable)
    DW_AT_name : (indirect string, offset: 0x6d): status
    DW_AT_decl_file : 4
    DW_AT_decl_line : 76
    DW_AT_type : <28>
    <-1><314>: Abbrev Number: 21 (DW_TAG_subprogram)
    DW_AT_sibling : <337>
    DW_AT_external : 1
    DW_AT_name : (indirect string, offset: 0x281): __vector_19
    DW_AT_decl_file : 4
    DW_AT_decl_line : 118
    DW_AT_low_pc : 0xec
    DW_AT_high_pc : 0x152
    DW_AT_frame_base : 0 byte block: ()
    <-1><326>: Abbrev Number: 32 (DW_TAG_variable)
    DW_AT_name : (indirect string, offset: 0x21900193):
    DW_AT_decl_file : 147
    DW_AT_decl_line : 1
    DW_AT_type : <3371c>
    DW_AT_location : 0 byte block: ()
    <-2><333>: Abbrev Number: 1 (DW_TAG_compile_unit)
    DW_AT_stmt_list : 0x13e
    DW_AT_high_pc : 0x236
    DW_AT_low_pc : 0
    DW_AT_producer : (indirect string, offset: 0x15035b04):
    DW_AT_language : 98 (Unknown: 62)
    DW_AT_name : (indirect string, offset: 0x1000003):
    DW_AT_comp_dir : (indirect string, offset: 0x22a): __vector_20
    <-1><349>: Abbrev Number: 4 (DW_TAG_structure_type)
    DW_AT_sibling : <7001527b>
    DW_AT_name : (indirect string, offset: 0x20000001):
    DW_AT_byte_size : 147
    DW_AT_decl_file : 1
    DW_AT_decl_line : 144
    <0><355>: Abbrev Number: 33 (DW_TAG_variable)
    DW_AT_specification: <621c0193>
    DW_AT_decl_file : 3
    DW_AT_decl_line : 0
    DW_AT_location : 0 byte block: ()

The Usart0 class looks like:

class CUsart0
{
private:
	// types
	struct TU0RxFifo {								// 
		unsigned char	WrPtr;						// write pointer
		unsigned char	RdPtr;						// read pointer
		unsigned char	Count;						// byte count
		char			Buffer[USART0_RxFifoSize];	// buffer
	};
	struct TU0TxFifo {								// 
		unsigned char	WrPtr;						// write pointer
		unsigned char	RdPtr;						// read pointer
		unsigned char	Count;						// byte count
		char			Buffer[USART0_TxFifoSize];	// buffer
	};
	
	// variables
	static TU0RxFifo			m_RxFifo;			// 
	static TU0TxFifo			m_TxFifo;			// 
	static unsigned char		m_SendBusy;			// transmit busy indicator

public:
	// methodes
	static void Init (void);						// 
	static unsigned char Recv (char *Data);			// 
	static unsigned char Send (char Data);			// 
	static unsigned char RecvAvail (void);			// 
	static unsigned char SendAvail (void);			// 
	static unsigned char SendBusy (void);			// 
	static void IrqUSART0_RX_vect (void);			// IRQ service
	static void IrqUSART0_UDRE_vect (void);			// IRQ service
	static void IrqUSART0_TX_vect (void);			// IRQ service
};

regards

Andre

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I looked into the parser component of AVR Studio, and DW_AT_member_location is not supported. This means that until proper c++ support is added here, you will not be able to look at class member variables.

As a poor workaround, you could use the memory view to look at the location where you expect the member variables to be located. (Some offset from the start of an object's address)

Sorry,
Torleif

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

Make a pointer to the class

Assign the pointer after the instance of CUsart0 is created.

CUsart0 *p_usart0;

CUsart0 usart0;

p_usart0 = &usart0;

Watch the pointer in Studio and expand it.

This has worked for me.

If you reload the program you may need to collapse and expand the pointer again.

Erik

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unfortunatele the pointer solution does not work, because even the pointer is allways out of scope.
It seems that only a few local variables can be watched within AVR Studio when using the C++ Compiler instead of the C Compiler

regards

Andre

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Andre_Bln wrote:
It seems that only a few local variables can be watched within AVR Studio when using the C++ Compiler instead of the C Compiler
Nope, that's equally true for the C compiler as well IF you build using any optimisation other than -O0. The compiler optimises locals into registers and the debugger then can't "see" them. If that's your problem then build the entire code -O0 or else just make the locals you want to inspect "volatile" which forces them to be held in RAM

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, I did not mention that the pointer must be a global variable.

Erik

[edit spelling]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not sure but the fact that your class contains only static variables may be an issue. If you are a C++ programmer you probably realize that no matter how many instances of your class created, there is exactly one instance of the static variables. Since there are no non-static variables, the compiler "may" be optimizing your pointers completely since there is nothing to point to.

I suspect the use of static can be done away with entirely. (IMO, static is way way overused by C programmers! When in doubt, declare it static....?)

Declaring the member functions as static further enforces the fact that your instances consist of no data.

Jim

C: i = "told you so";

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I suspect the use of static can be done away with entirely. (IMO, static is way way overused by C programmers! When in doubt, declare it static....?)

I have used a mixture of static and non-static members with no debugging problems.

A variable common to all instances of a given class must be static. I have had several uses for this, and also Smalltalk has "class variables" so I'm not the only one seeing the need for static members. ;-)

Like many other things in life, "static" can be misused.

Erik

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I'm not the only one seeing the need for static members

Sorry, but I was talking about C not C++.

Static functions in C are rarely useful and in fact tend to be an annoyance; for example stepping through the disassembler and wanting to lookup the current PC in the map file. If the function is static then it's not in the map file.

Static member functions and data are very useful in C++ as long as you know all objects of that class share the exact same static variables and static member functions have no "this" pointer.

C: i = "told you so";

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
now I have found a solution at least for objects with non static members.
justt type "this" (without quotes) in the watch window and expand it.
When you has to debug more than one object (either more object instances of one class or instances of different classes) you have to collapse and re-expand the "this pointer".
Unfortunately I am still looking for a solution for classes with static members.
I hope this helps someone

regards

Andre