Sync config.sub,config.guess with upstream.
[deliverable/binutils-gdb.git] / gdb / ft32-tdep.c
1 /* Target-dependent code for FT32.
2
3 Copyright (C) 2009-2016 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "frame.h"
22 #include "frame-unwind.h"
23 #include "frame-base.h"
24 #include "symtab.h"
25 #include "gdbtypes.h"
26 #include "gdbcmd.h"
27 #include "gdbcore.h"
28 #include "value.h"
29 #include "inferior.h"
30 #include "symfile.h"
31 #include "objfiles.h"
32 #include "osabi.h"
33 #include "language.h"
34 #include "arch-utils.h"
35 #include "regcache.h"
36 #include "trad-frame.h"
37 #include "dis-asm.h"
38 #include "record.h"
39
40 #include "opcode/ft32.h"
41
42 #include "ft32-tdep.h"
43 #include "gdb/sim-ft32.h"
44 #include <algorithm>
45
46 #define RAM_BIAS 0x800000 /* Bias added to RAM addresses. */
47
48 /* Local functions. */
49
50 extern void _initialize_ft32_tdep (void);
51
52 /* Use an invalid address -1 as 'not available' marker. */
53 enum { REG_UNAVAIL = (CORE_ADDR) (-1) };
54
55 struct ft32_frame_cache
56 {
57 /* Base address of the frame */
58 CORE_ADDR base;
59 /* Function this frame belongs to */
60 CORE_ADDR pc;
61 /* Total size of this frame */
62 LONGEST framesize;
63 /* Saved registers in this frame */
64 CORE_ADDR saved_regs[FT32_NUM_REGS];
65 /* Saved SP in this frame */
66 CORE_ADDR saved_sp;
67 /* Has the new frame been LINKed. */
68 bfd_boolean established;
69 };
70
71 /* Implement the "frame_align" gdbarch method. */
72
73 static CORE_ADDR
74 ft32_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
75 {
76 /* Align to the size of an instruction (so that they can safely be
77 pushed onto the stack. */
78 return sp & ~1;
79 }
80
81
82 constexpr gdb_byte ft32_break_insn[] = { 0x02, 0x00, 0x34, 0x00 };
83
84 typedef BP_MANIPULATION (ft32_break_insn) ft32_breakpoint;
85
86 /* FT32 register names. */
87
88 static const char *const ft32_register_names[] =
89 {
90 "fp", "sp",
91 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
92 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
93 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
94 "r24", "r25", "r26", "r27", "r28", "cc",
95 "pc"
96 };
97
98 /* Implement the "register_name" gdbarch method. */
99
100 static const char *
101 ft32_register_name (struct gdbarch *gdbarch, int reg_nr)
102 {
103 if (reg_nr < 0)
104 return NULL;
105 if (reg_nr >= FT32_NUM_REGS)
106 return NULL;
107 return ft32_register_names[reg_nr];
108 }
109
110 /* Implement the "register_type" gdbarch method. */
111
112 static struct type *
113 ft32_register_type (struct gdbarch *gdbarch, int reg_nr)
114 {
115 if (reg_nr == FT32_PC_REGNUM)
116 return gdbarch_tdep (gdbarch)->pc_type;
117 else if (reg_nr == FT32_SP_REGNUM || reg_nr == FT32_FP_REGNUM)
118 return builtin_type (gdbarch)->builtin_data_ptr;
119 else
120 return builtin_type (gdbarch)->builtin_int32;
121 }
122
123 /* Write into appropriate registers a function return value
124 of type TYPE, given in virtual format. */
125
126 static void
127 ft32_store_return_value (struct type *type, struct regcache *regcache,
128 const gdb_byte *valbuf)
129 {
130 struct gdbarch *gdbarch = get_regcache_arch (regcache);
131 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
132 CORE_ADDR regval;
133 int len = TYPE_LENGTH (type);
134
135 /* Things always get returned in RET1_REGNUM, RET2_REGNUM. */
136 regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order);
137 regcache_cooked_write_unsigned (regcache, FT32_R0_REGNUM, regval);
138 if (len > 4)
139 {
140 regval = extract_unsigned_integer (valbuf + 4,
141 len - 4, byte_order);
142 regcache_cooked_write_unsigned (regcache, FT32_R1_REGNUM, regval);
143 }
144 }
145
146 /* Decode the instructions within the given address range. Decide
147 when we must have reached the end of the function prologue. If a
148 frame_info pointer is provided, fill in its saved_regs etc.
149
150 Returns the address of the first instruction after the prologue. */
151
152 static CORE_ADDR
153 ft32_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
154 struct ft32_frame_cache *cache,
155 struct gdbarch *gdbarch)
156 {
157 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
158 CORE_ADDR next_addr;
159 ULONGEST inst;
160 int regnum, pushreg;
161 struct bound_minimal_symbol msymbol;
162 const int first_saved_reg = 13; /* The first saved register. */
163 /* PROLOGS are addresses of the subroutine prologs, PROLOGS[n]
164 is the address of __prolog_$rN.
165 __prolog_$rN pushes registers from 13 through n inclusive.
166 So for example CALL __prolog_$r15 is equivalent to:
167 PUSH $r13
168 PUSH $r14
169 PUSH $r15
170 Note that PROLOGS[0] through PROLOGS[12] are unused. */
171 CORE_ADDR prologs[32];
172
173 cache->saved_regs[FT32_PC_REGNUM] = 0;
174 cache->framesize = 0;
175
176 for (regnum = first_saved_reg; regnum < 32; regnum++)
177 {
178 char prolog_symbol[32];
179
180 snprintf (prolog_symbol, sizeof (prolog_symbol), "__prolog_$r%02d",
181 regnum);
182 msymbol = lookup_minimal_symbol (prolog_symbol, NULL, NULL);
183 if (msymbol.minsym)
184 prologs[regnum] = BMSYMBOL_VALUE_ADDRESS (msymbol);
185 else
186 prologs[regnum] = 0;
187 }
188
189 if (start_addr >= end_addr)
190 return end_addr;
191
192 cache->established = 0;
193 for (next_addr = start_addr; next_addr < end_addr;)
194 {
195 inst = read_memory_unsigned_integer (next_addr, 4, byte_order);
196
197 if (FT32_IS_PUSH (inst))
198 {
199 pushreg = FT32_PUSH_REG (inst);
200 cache->framesize += 4;
201 cache->saved_regs[FT32_R0_REGNUM + pushreg] = cache->framesize;
202 next_addr += 4;
203 }
204 else if (FT32_IS_CALL (inst))
205 {
206 for (regnum = first_saved_reg; regnum < 32; regnum++)
207 {
208 if ((4 * (inst & 0x3ffff)) == prologs[regnum])
209 {
210 for (pushreg = first_saved_reg; pushreg <= regnum;
211 pushreg++)
212 {
213 cache->framesize += 4;
214 cache->saved_regs[FT32_R0_REGNUM + pushreg] =
215 cache->framesize;
216 }
217 next_addr += 4;
218 }
219 }
220 break;
221 }
222 else
223 break;
224 }
225 for (regnum = FT32_R0_REGNUM; regnum < FT32_PC_REGNUM; regnum++)
226 {
227 if (cache->saved_regs[regnum] != REG_UNAVAIL)
228 cache->saved_regs[regnum] =
229 cache->framesize - cache->saved_regs[regnum];
230 }
231 cache->saved_regs[FT32_PC_REGNUM] = cache->framesize;
232
233 /* It is a LINK? */
234 if (next_addr < end_addr)
235 {
236 inst = read_memory_unsigned_integer (next_addr, 4, byte_order);
237 if (FT32_IS_LINK (inst))
238 {
239 cache->established = 1;
240 for (regnum = FT32_R0_REGNUM; regnum < FT32_PC_REGNUM; regnum++)
241 {
242 if (cache->saved_regs[regnum] != REG_UNAVAIL)
243 cache->saved_regs[regnum] += 4;
244 }
245 cache->saved_regs[FT32_PC_REGNUM] = cache->framesize + 4;
246 cache->saved_regs[FT32_FP_REGNUM] = 0;
247 cache->framesize += FT32_LINK_SIZE (inst);
248 next_addr += 4;
249 }
250 }
251
252 return next_addr;
253 }
254
255 /* Find the end of function prologue. */
256
257 static CORE_ADDR
258 ft32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
259 {
260 CORE_ADDR func_addr = 0, func_end = 0;
261 const char *func_name;
262
263 /* See if we can determine the end of the prologue via the symbol table.
264 If so, then return either PC, or the PC after the prologue, whichever
265 is greater. */
266 if (find_pc_partial_function (pc, &func_name, &func_addr, &func_end))
267 {
268 CORE_ADDR post_prologue_pc
269 = skip_prologue_using_sal (gdbarch, func_addr);
270 if (post_prologue_pc != 0)
271 return std::max (pc, post_prologue_pc);
272 else
273 {
274 /* Can't determine prologue from the symbol table, need to examine
275 instructions. */
276 struct symtab_and_line sal;
277 struct symbol *sym;
278 struct ft32_frame_cache cache;
279 CORE_ADDR plg_end;
280
281 memset (&cache, 0, sizeof cache);
282
283 plg_end = ft32_analyze_prologue (func_addr,
284 func_end, &cache, gdbarch);
285 /* Found a function. */
286 sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
287 /* Don't use line number debug info for assembly source files. */
288 if ((sym != NULL) && SYMBOL_LANGUAGE (sym) != language_asm)
289 {
290 sal = find_pc_line (func_addr, 0);
291 if (sal.end && sal.end < func_end)
292 {
293 /* Found a line number, use it as end of prologue. */
294 return sal.end;
295 }
296 }
297 /* No useable line symbol. Use result of prologue parsing method. */
298 return plg_end;
299 }
300 }
301
302 /* No function symbol -- just return the PC. */
303 return pc;
304 }
305
306 /* Implementation of `pointer_to_address' gdbarch method.
307
308 On FT32 address space zero is RAM, address space 1 is flash.
309 RAM appears at address RAM_BIAS, flash at address 0. */
310
311 static CORE_ADDR
312 ft32_pointer_to_address (struct gdbarch *gdbarch,
313 struct type *type, const gdb_byte *buf)
314 {
315 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
316 CORE_ADDR addr
317 = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
318
319 if (TYPE_ADDRESS_CLASS_1 (type))
320 return addr;
321 else
322 return addr | RAM_BIAS;
323 }
324
325 /* Implementation of `address_class_type_flags' gdbarch method.
326
327 This method maps DW_AT_address_class attributes to a
328 type_instance_flag_value. */
329
330 static int
331 ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class)
332 {
333 /* The value 1 of the DW_AT_address_class attribute corresponds to the
334 __flash__ qualifier, meaning pointer to data in FT32 program memory.
335 */
336 if (dwarf2_addr_class == 1)
337 return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
338 return 0;
339 }
340
341 /* Implementation of `address_class_type_flags_to_name' gdbarch method.
342
343 Convert a type_instance_flag_value to an address space qualifier. */
344
345 static const char*
346 ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
347 {
348 if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
349 return "flash";
350 else
351 return NULL;
352 }
353
354 /* Implementation of `address_class_name_to_type_flags' gdbarch method.
355
356 Convert an address space qualifier to a type_instance_flag_value. */
357
358 static int
359 ft32_address_class_name_to_type_flags (struct gdbarch *gdbarch,
360 const char* name,
361 int *type_flags_ptr)
362 {
363 if (strcmp (name, "flash") == 0)
364 {
365 *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
366 return 1;
367 }
368 else
369 return 0;
370 }
371
372
373 /* Implement the "read_pc" gdbarch method. */
374
375 static CORE_ADDR
376 ft32_read_pc (struct regcache *regcache)
377 {
378 ULONGEST pc;
379
380 regcache_cooked_read_unsigned (regcache, FT32_PC_REGNUM, &pc);
381 return pc;
382 }
383
384 /* Implement the "write_pc" gdbarch method. */
385
386 static void
387 ft32_write_pc (struct regcache *regcache, CORE_ADDR val)
388 {
389 regcache_cooked_write_unsigned (regcache, FT32_PC_REGNUM, val);
390 }
391
392 /* Implement the "unwind_sp" gdbarch method. */
393
394 static CORE_ADDR
395 ft32_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
396 {
397 return frame_unwind_register_unsigned (next_frame, FT32_SP_REGNUM);
398 }
399
400 /* Given a return value in `regbuf' with a type `valtype',
401 extract and copy its value into `valbuf'. */
402
403 static void
404 ft32_extract_return_value (struct type *type, struct regcache *regcache,
405 gdb_byte *dst)
406 {
407 struct gdbarch *gdbarch = get_regcache_arch (regcache);
408 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
409 bfd_byte *valbuf = dst;
410 int len = TYPE_LENGTH (type);
411 ULONGEST tmp;
412
413 /* By using store_unsigned_integer we avoid having to do
414 anything special for small big-endian values. */
415 regcache_cooked_read_unsigned (regcache, FT32_R0_REGNUM, &tmp);
416 store_unsigned_integer (valbuf, (len > 4 ? len - 4 : len), byte_order, tmp);
417
418 /* Ignore return values more than 8 bytes in size because the ft32
419 returns anything more than 8 bytes in the stack. */
420 if (len > 4)
421 {
422 regcache_cooked_read_unsigned (regcache, FT32_R1_REGNUM, &tmp);
423 store_unsigned_integer (valbuf + len - 4, 4, byte_order, tmp);
424 }
425 }
426
427 /* Implement the "return_value" gdbarch method. */
428
429 static enum return_value_convention
430 ft32_return_value (struct gdbarch *gdbarch, struct value *function,
431 struct type *valtype, struct regcache *regcache,
432 gdb_byte *readbuf, const gdb_byte *writebuf)
433 {
434 if (TYPE_LENGTH (valtype) > 8)
435 return RETURN_VALUE_STRUCT_CONVENTION;
436 else
437 {
438 if (readbuf != NULL)
439 ft32_extract_return_value (valtype, regcache, readbuf);
440 if (writebuf != NULL)
441 ft32_store_return_value (valtype, regcache, writebuf);
442 return RETURN_VALUE_REGISTER_CONVENTION;
443 }
444 }
445
446 /* Allocate and initialize a ft32_frame_cache object. */
447
448 static struct ft32_frame_cache *
449 ft32_alloc_frame_cache (void)
450 {
451 struct ft32_frame_cache *cache;
452 int i;
453
454 cache = FRAME_OBSTACK_ZALLOC (struct ft32_frame_cache);
455
456 for (i = 0; i < FT32_NUM_REGS; ++i)
457 cache->saved_regs[i] = REG_UNAVAIL;
458
459 return cache;
460 }
461
462 /* Populate a ft32_frame_cache object for this_frame. */
463
464 static struct ft32_frame_cache *
465 ft32_frame_cache (struct frame_info *this_frame, void **this_cache)
466 {
467 struct ft32_frame_cache *cache;
468 CORE_ADDR current_pc;
469 int i;
470
471 if (*this_cache)
472 return (struct ft32_frame_cache *) *this_cache;
473
474 cache = ft32_alloc_frame_cache ();
475 *this_cache = cache;
476
477 cache->base = get_frame_register_unsigned (this_frame, FT32_FP_REGNUM);
478 if (cache->base == 0)
479 return cache;
480
481 cache->pc = get_frame_func (this_frame);
482 current_pc = get_frame_pc (this_frame);
483 if (cache->pc)
484 {
485 struct gdbarch *gdbarch = get_frame_arch (this_frame);
486
487 ft32_analyze_prologue (cache->pc, current_pc, cache, gdbarch);
488 if (!cache->established)
489 cache->base = get_frame_register_unsigned (this_frame, FT32_SP_REGNUM);
490 }
491
492 cache->saved_sp = cache->base - 4;
493
494 for (i = 0; i < FT32_NUM_REGS; ++i)
495 if (cache->saved_regs[i] != REG_UNAVAIL)
496 cache->saved_regs[i] = cache->base + cache->saved_regs[i];
497
498 return cache;
499 }
500
501 /* Implement the "unwind_pc" gdbarch method. */
502
503 static CORE_ADDR
504 ft32_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
505 {
506 return frame_unwind_register_unsigned (next_frame, FT32_PC_REGNUM);
507 }
508
509 /* Given a GDB frame, determine the address of the calling function's
510 frame. This will be used to create a new GDB frame struct. */
511
512 static void
513 ft32_frame_this_id (struct frame_info *this_frame,
514 void **this_prologue_cache, struct frame_id *this_id)
515 {
516 struct ft32_frame_cache *cache = ft32_frame_cache (this_frame,
517 this_prologue_cache);
518
519 /* This marks the outermost frame. */
520 if (cache->base == 0)
521 return;
522
523 *this_id = frame_id_build (cache->saved_sp, cache->pc);
524 }
525
526 /* Get the value of register regnum in the previous stack frame. */
527
528 static struct value *
529 ft32_frame_prev_register (struct frame_info *this_frame,
530 void **this_prologue_cache, int regnum)
531 {
532 struct ft32_frame_cache *cache = ft32_frame_cache (this_frame,
533 this_prologue_cache);
534
535 gdb_assert (regnum >= 0);
536
537 if (regnum == FT32_SP_REGNUM && cache->saved_sp)
538 return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
539
540 if (regnum < FT32_NUM_REGS && cache->saved_regs[regnum] != REG_UNAVAIL)
541 return frame_unwind_got_memory (this_frame, regnum,
542 RAM_BIAS | cache->saved_regs[regnum]);
543
544 return frame_unwind_got_register (this_frame, regnum, regnum);
545 }
546
547 static const struct frame_unwind ft32_frame_unwind =
548 {
549 NORMAL_FRAME,
550 default_frame_unwind_stop_reason,
551 ft32_frame_this_id,
552 ft32_frame_prev_register,
553 NULL,
554 default_frame_sniffer
555 };
556
557 /* Return the base address of this_frame. */
558
559 static CORE_ADDR
560 ft32_frame_base_address (struct frame_info *this_frame, void **this_cache)
561 {
562 struct ft32_frame_cache *cache = ft32_frame_cache (this_frame,
563 this_cache);
564
565 return cache->base;
566 }
567
568 static const struct frame_base ft32_frame_base =
569 {
570 &ft32_frame_unwind,
571 ft32_frame_base_address,
572 ft32_frame_base_address,
573 ft32_frame_base_address
574 };
575
576 static struct frame_id
577 ft32_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
578 {
579 CORE_ADDR sp = get_frame_register_unsigned (this_frame, FT32_SP_REGNUM);
580
581 return frame_id_build (sp, get_frame_pc (this_frame));
582 }
583
584 /* Allocate and initialize the ft32 gdbarch object. */
585
586 static struct gdbarch *
587 ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
588 {
589 struct gdbarch *gdbarch;
590 struct gdbarch_tdep *tdep;
591 struct type *void_type;
592 struct type *func_void_type;
593
594 /* If there is already a candidate, use it. */
595 arches = gdbarch_list_lookup_by_info (arches, &info);
596 if (arches != NULL)
597 return arches->gdbarch;
598
599 /* Allocate space for the new architecture. */
600 tdep = XNEW (struct gdbarch_tdep);
601 gdbarch = gdbarch_alloc (&info, tdep);
602
603 /* Create a type for PC. We can't use builtin types here, as they may not
604 be defined. */
605 void_type = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
606 func_void_type = make_function_type (void_type, NULL);
607 tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
608 func_void_type);
609 TYPE_INSTANCE_FLAGS (tdep->pc_type) |= TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
610
611 set_gdbarch_read_pc (gdbarch, ft32_read_pc);
612 set_gdbarch_write_pc (gdbarch, ft32_write_pc);
613 set_gdbarch_unwind_sp (gdbarch, ft32_unwind_sp);
614
615 set_gdbarch_num_regs (gdbarch, FT32_NUM_REGS);
616 set_gdbarch_sp_regnum (gdbarch, FT32_SP_REGNUM);
617 set_gdbarch_pc_regnum (gdbarch, FT32_PC_REGNUM);
618 set_gdbarch_register_name (gdbarch, ft32_register_name);
619 set_gdbarch_register_type (gdbarch, ft32_register_type);
620
621 set_gdbarch_return_value (gdbarch, ft32_return_value);
622
623 set_gdbarch_pointer_to_address (gdbarch, ft32_pointer_to_address);
624
625 set_gdbarch_skip_prologue (gdbarch, ft32_skip_prologue);
626 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
627 set_gdbarch_breakpoint_kind_from_pc (gdbarch, ft32_breakpoint::kind_from_pc);
628 set_gdbarch_sw_breakpoint_from_kind (gdbarch, ft32_breakpoint::bp_from_kind);
629 set_gdbarch_frame_align (gdbarch, ft32_frame_align);
630
631 frame_base_set_default (gdbarch, &ft32_frame_base);
632
633 /* Methods for saving / extracting a dummy frame's ID. The ID's
634 stack address must match the SP value returned by
635 PUSH_DUMMY_CALL, and saved by generic_save_dummy_frame_tos. */
636 set_gdbarch_dummy_id (gdbarch, ft32_dummy_id);
637
638 set_gdbarch_unwind_pc (gdbarch, ft32_unwind_pc);
639
640 set_gdbarch_print_insn (gdbarch, print_insn_ft32);
641
642 /* Hook in ABI-specific overrides, if they have been registered. */
643 gdbarch_init_osabi (info, gdbarch);
644
645 /* Hook in the default unwinders. */
646 frame_unwind_append_unwinder (gdbarch, &ft32_frame_unwind);
647
648 /* Support simple overlay manager. */
649 set_gdbarch_overlay_update (gdbarch, simple_overlay_update);
650
651 set_gdbarch_address_class_type_flags (gdbarch, ft32_address_class_type_flags);
652 set_gdbarch_address_class_name_to_type_flags
653 (gdbarch, ft32_address_class_name_to_type_flags);
654 set_gdbarch_address_class_type_flags_to_name
655 (gdbarch, ft32_address_class_type_flags_to_name);
656
657 return gdbarch;
658 }
659
660 /* Register this machine's init routine. */
661
662 void
663 _initialize_ft32_tdep (void)
664 {
665 register_gdbarch_init (bfd_arch_ft32, ft32_gdbarch_init);
666 }
This page took 0.053774 seconds and 4 git commands to generate.