Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use enums to make debugging easier

When we're dealing with a field which is guaranteed to have an enum type,
then declare it as such so it shows up in debuggers.
  • Loading branch information...
commit b79f0d0cc336662d16a22e07ad429e8deb71c956 1 parent 2ba7ed7
authored
2  insns.pl
@@ -186,7 +186,7 @@
186 186
     
187 187
     print N "\n};\n\n";
188 188
     print N "/* and the corresponding opcodes */\n";
189  
-    print N "static const int ico[] = {";
  189
+    print N "static const enum opcode ico[] = {";
190 190
     $first = 1;
191 191
     foreach $i (@opcodes_cc) {
192 192
 	print N "," if ( !$first );
14  nasm.h
@@ -543,7 +543,7 @@ enum {                          /* condition code names */
543 543
  * prefixes, we must ensure the enumerations for prefixes and
544 544
  * register names do not overlap.
545 545
  */
546  
-enum {                          /* instruction prefixes */
  546
+enum prefixes {			/* instruction prefixes */
547 547
     PREFIX_ENUM_START = REG_ENUM_LIMIT,
548 548
     P_A16 = PREFIX_ENUM_START, P_A32, P_LOCK, P_O16, P_O32,
549 549
     P_REP, P_REPE, P_REPNE, P_REPNZ, P_REPZ, P_TIMES
@@ -562,7 +562,7 @@ enum {                          /* special EA flags */
562 562
     EAF_FSGS	 = 32		/* fs/gs segment override present */
563 563
 };
564 564
 
565  
-enum {                          /* values for `hinttype' */
  565
+enum eval_hint {                /* values for `hinttype' */
566 566
     EAH_NOHINT   = 0,           /* no hint at all - our discretion */
567 567
     EAH_MAKEBASE = 1,           /* try to make given reg the base */
568 568
     EAH_NOTBASE  = 2            /* try _not_ to make reg the base */
@@ -571,8 +571,10 @@ enum {                          /* values for `hinttype' */
571 571
 typedef struct {                /* operand to an instruction */
572 572
     int32_t type;               /* type of operand */
573 573
     int addr_size;              /* 0 means default; 16; 32; 64 */
574  
-    int basereg, indexreg, scale;       /* registers and scale involved */
575  
-    int hintbase, hinttype;     /* hint as to real base register */
  574
+    enum reg_enum basereg, indexreg; /* address registers */
  575
+    int scale;			/* index scale */
  576
+    int hintbase;
  577
+    enum eval_hint hinttype;    /* hint as to real base register */
576 578
     int32_t segment;            /* immediate segment, if needed */
577 579
     int64_t offset;             /* any immediate number */
578 580
     int32_t wrt;                /* segment base it's relative to */
@@ -597,7 +599,7 @@ typedef struct extop {          /* extended operand */
597 599
 
598 600
 typedef struct {                /* an instruction itself */
599 601
     char *label;              /* the label defined, or NULL */
600  
-    int prefixes[MAXPREFIX];    /* instruction prefixes, if any */
  602
+    enum prefixes prefixes[MAXPREFIX]; /* instruction prefixes, if any */
601 603
     int nprefix;                /* number of entries in above */
602 604
     int opcode;                 /* the opcode - not just the string */
603 605
     int condition;              /* the condition code, if Jcc/SETcc */
@@ -931,7 +933,7 @@ struct dfmt {
931 933
  * -----
932 934
  */
933 935
 
934  
-enum {
  936
+enum special_tokens {
935 937
     S_ABS, S_BYTE, S_DWORD, S_FAR, S_LONG, S_NEAR, S_NOSPLIT, S_QWORD, S_REL,
936 938
     S_SHORT, S_STRICT, S_TO, S_TWORD, S_WORD
937 939
 };
4  regs.pl
@@ -99,7 +99,7 @@ ($)
99 99
 } elsif ( $fmt eq 'c' ) {
100 100
     # Output regs.c
101 101
     print "/* automatically generated from $file - do not edit */\n";
102  
-    print "static const char *reg_names[] = "; $ch = '{';
  102
+    print "static const char * const reg_names[] = "; $ch = '{';
103 103
     # This one has no dummy entry for 0
104 104
     foreach $reg ( sort(keys(%regs)) ) {
105 105
 	print "$ch\n    \"${reg}\"";
@@ -128,7 +128,7 @@ ($)
128 128
     # Output regdis.c
129 129
     print "/* automatically generated from $file - do not edit */\n";
130 130
     foreach $class ( sort(keys(%disclass)) ) {
131  
-	printf "static const int rd_%-8s[] = {", $class;
  131
+	printf "static const enum reg_enum rd_%-8s[] = {", $class;
132 132
 	@foo = @{$disclass{$class}};
133 133
 	@bar = ();
134 134
 	for ( $i = 0 ; $i < scalar(@foo) ; $i++ ) {

0 notes on commit b79f0d0

Please sign in to comment.
Something went wrong with that request. Please try again.