Bug 546182 - Eclipse IDE Gives Wrong Sign Value for uint8_t User Created Data Type Register Variable
Summary: Eclipse IDE Gives Wrong Sign Value for uint8_t User Created Data Type Registe...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: Next   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: cdt-debug-inbox@eclipse.org CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-08 00:22 EDT by Saul Lopez CLA
Modified: 2020-09-04 15:26 EDT (History)
1 user (show)

See Also:


Attachments
Debug Mode Register Value Should Be Positive (11.46 KB, image/png)
2019-04-08 00:22 EDT, Saul Lopez CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Saul Lopez CLA 2019-04-08 00:22:37 EDT
Created attachment 278161 [details]
Debug Mode Register Value Should Be Positive

#include "stdio.h"
#include "string.h"
#include "stdint.h"

/* I created the following register using unsigned 8-bit type data (uint8_t): */

union{

	volatile uint8_t flagRegister;

	struct
	{
		volatile uint8_t firstFlag    : 1; // Bit 0   1
		volatile uint8_t secondFlag   : 1; // Bit 1   0
		volatile uint8_t thirdFlag    : 1; // Bit 2   1
		volatile uint8_t fourthtFlag  : 1; // Bit 3   0
		volatile uint8_t statusFlag   : 4; // Bits 4 - 7

	}bits;

}fullRegister;

In main I initialize each bit like this:

	/* Initialize register to zero values */
	fullRegister.flagRegister = 0x00;

	/* Set a few bits within the register: */ 
	fullRegister.bits.firstFlag = 1;
	fullRegister.bits.secondFlag = 0;
	fullRegister.bits.thirdFlag = 1;
	fullRegister.bits.fourthtFlag = 0;
	fullRegister.bits.statusFlag = 0xf;

	/* Print out the expected register values: */
	printf("\nThe value of the statusFlag is: %d", fullRegister.bits.statusFlag);
	printf("\nThe value of the flagRegister is: %d\n\n", fullRegister.flagRegister);
	
When I go to the debug window by passing the mouse pointer over the 'fullRegister.flagRegister' variable, 
it gives 'Decimal' as a negative eleven (-11) value.  It should be 245 since it is an unsigned 8-bit data 
type variable register.  Note that 'Default' and 'Details' right above do display the correct value of
245. 

-- Configuration Details --
Product: Eclipse IDE 4.11.0.20190314-1200 (org.eclipse.epp.package.cpp.product)Installed Features:
 org.eclipse.platform 4.11.0.v20190307-0500
Comment 1 Saul Lopez CLA 2019-04-09 19:59:11 EDT
Additional observations:

1. What is the purpose of the 'Details' and the 'Default' items.  They
   seem to be redundant/useless as the needed information is already
   given in the form of Decimal/HEX/Ocal/Binary.

2. When highlighting the flagRegister variable in the debug window for 
   example, why is there an alphanumeric 'o' to the right of the value 
   (in this case of 245, i.e., 245 'o').  This happens for other values 
   as well.  For example, for the value of 128, there is a an capital 
   epsilon that kind of looks like the euro symbol.


3. For a bit value of say 1, as in flagRegister.firstFlag = 1;
   in the debug window it shows it as 1 '\001'.  The extra '\001' appears 
   to be not needed.  For the value highlighted you only needed the value
   of interest.  In this case a value of 1 (only).

4. Within a debug window, it would be nice to have the option of being able 
   to add additional columns for the case when wanting to be able to observe 
   variables with different number systems alongside each other. Variables
   that are better served viewing in the decimal system (after a calculation) 
   and others in the HEX/binary (changing bit fields/flags) system alongside 
   each other.  However, this can only be done by being able to add addition
   columns (or having the capability of selecting the row view format).

Just a few observation and suggestions.