aboutsummaryrefslogtreecommitdiff
path: root/binutils_patches/0004-Added-debug-option-to-gas-to-enable-debugging-printo.patch
blob: 7f7f81db1f200f99eb9da93363494672749b8887 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
From 85f95b1d46d4ab7bff529f9f0de5cc3263a205bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85ke=20Rehnman?= <ake_rehnman_at_gmail_com>
Date: Sun, 23 Apr 2017 21:26:53 +0200
Subject: [PATCH 4/10] Added --debug option to gas to enable debugging printout
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Åke Rehnman <ake_rehnman_at_gmail_com>
---
 gas/config/tc-stm8.c | 58 +++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 42 insertions(+), 16 deletions(-)

diff --git a/gas/config/tc-stm8.c b/gas/config/tc-stm8.c
index 84e667278e..1fa4503ce2 100644
--- a/gas/config/tc-stm8.c
+++ b/gas/config/tc-stm8.c
@@ -54,6 +54,7 @@ const char line_separator_chars[] = "{";
 
 int md_short_jump_size = 3;
 int md_long_jump_size = 4;
+int stm8_debug = 0;
 
 /* The target specific pseudo-ops which we support.  */
 /* example:
@@ -95,17 +96,38 @@ md_show_usage (FILE *stream)
   fprintf (stream, _("\
   STM8 options:\n\
   "));
+  fprintf (stream, _("\
+  --debug               turn on debug messages\n"));
 }
 
+enum options
+{
+  OPTION_DEBUG = OPTION_MD_BASE + 1,
+};
+
 const char *md_shortopts = "";
 
 struct option md_longopts[] =
   {
+  	{ "debug",     no_argument, NULL, OPTION_DEBUG     },
     {NULL, no_argument, NULL, 0}
   };
 
 size_t md_longopts_size = sizeof (md_longopts);
 
+int
+md_parse_option (int c, const char *arg __attribute__((unused)))
+{
+  switch (c)
+    {
+    case OPTION_DEBUG:
+      stm8_debug = 1;
+      return 1;
+    }
+  return 0;
+}
+
+
 void
 md_begin (void)
 {
@@ -228,7 +250,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT segment ATTRIBUTE_UNUSED)
   long val = * (long *) valP;
   char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
 
-  print_fixup(fixP);
+	if (stm8_debug)
+  	print_fixup(fixP);
 
   switch (fixP->fx_r_type)
     {
@@ -329,7 +352,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
 {
   arelent *reloc;
 
-  print_fixup(fixp);
+	if (stm8_debug)
+  	print_fixup(fixp);
 
   reloc = XNEW (arelent);
   reloc->sym_ptr_ptr = XNEW (asymbol *);
@@ -359,12 +383,6 @@ md_section_align (segT seg, valueT size)
 	return (size + mask) & ~mask;
 }
 
-int
-md_parse_option (int c __attribute__((unused)), const char *arg __attribute__((unused)))
-{
-	return 1;
-}
-
 symbolS *
 md_undefined_symbol (char *name)
 {
@@ -529,7 +547,8 @@ int read_arg_ptr(char *str, expressionS *exps)
 		}
 		
 		expression(exps);
-		print_expr(exps);
+		if (stm8_debug)
+			print_expr(exps);
 		
 		/* restore c */
 		if (p)
@@ -565,7 +584,8 @@ char* toupperstr(char *str);
 
 char* toupperstr(char *str)
 {
-	for(int i = 0; str[i]; i++){
+	int i;
+	for(i = 0; str[i]; i++){
   	str[i] = toupper(str[i]);
 	}
 	return str;
@@ -591,7 +611,8 @@ int read_arg(char *str, expressionS *exps)
 		exps->X_md = OP_IMM;
 		input_line_pointer = str;
 		expression(exps);
-		print_expr(exps);
+		if (stm8_debug)
+			print_expr(exps);
 		return 1;
 	}
 	
@@ -654,7 +675,8 @@ int read_arg(char *str, expressionS *exps)
 		str=strtok(str,",");
 		input_line_pointer=str;
 		expression(exps);
-		print_expr(exps);
+		if (stm8_debug)
+			print_expr(exps);
 		exps->X_md=OP_OFF_X;
 		return 1;
 	}
@@ -680,7 +702,8 @@ int read_arg(char *str, expressionS *exps)
 		str=strtok(str,",");
 		input_line_pointer=str;
 		expression(exps);
-		print_expr(exps);
+		if (stm8_debug)
+			print_expr(exps);
 		exps->X_md=OP_OFF_X;
 		return 1;
 	}
@@ -691,7 +714,8 @@ int read_arg(char *str, expressionS *exps)
 		str=strtok(str,",");
 		input_line_pointer=str;
 		expression(exps);
-		print_expr(exps);
+		if (stm8_debug)
+			print_expr(exps);
 		exps->X_md=OP_OFF_SP;
 		return 1;
 	}
@@ -705,7 +729,8 @@ int read_arg(char *str, expressionS *exps)
 		exps->X_md = OP_SHORTMEM;
 		input_line_pointer = str;
 		expression(exps);
-		print_expr(exps);
+		if (stm8_debug)
+			print_expr(exps);
 		*p = c;
 		input_line_pointer += 6;
 		return 1;
@@ -713,7 +738,8 @@ int read_arg(char *str, expressionS *exps)
 
 	input_line_pointer = str;
 	expression(exps);
-	print_expr(exps);
+	if (stm8_debug)
+		print_expr(exps);
 
 	if (exps->X_op == O_register)
 	{
-- 
2.12.2