Rename 32- and 64-bit Intel files from "i386" to "x86"
[deliverable/binutils-gdb.git] / gdb / i386-linux-nat.c
1 /* Native-dependent code for GNU/Linux i386.
2
3 Copyright (C) 1999-2014 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 "inferior.h"
22 #include "gdbcore.h"
23 #include "regcache.h"
24 #include "elf/common.h"
25 #include <sys/ptrace.h>
26 #include "gregset.h"
27 #include "gdb_proc_service.h"
28
29 #include "i386-linux-nat.h"
30 #include "i387-tdep.h"
31 #include "i386-tdep.h"
32 #include "i386-linux-tdep.h"
33 #include "x86-xstate.h"
34
35 #include "x86-linux-nat.h"
36
37 /* The register sets used in GNU/Linux ELF core-dumps are identical to
38 the register sets in `struct user' that is used for a.out
39 core-dumps, and is also used by `ptrace'. The corresponding types
40 are `elf_gregset_t' for the general-purpose registers (with
41 `elf_greg_t' the type of a single GP register) and `elf_fpregset_t'
42 for the floating-point registers.
43
44 Those types used to be available under the names `gregset_t' and
45 `fpregset_t' too, and this file used those names in the past. But
46 those names are now used for the register sets used in the
47 `mcontext_t' type, and have a different size and layout. */
48
49 /* Which ptrace request retrieves which registers?
50 These apply to the corresponding SET requests as well. */
51
52 #define GETREGS_SUPPLIES(regno) \
53 ((0 <= (regno) && (regno) <= 15) || (regno) == I386_LINUX_ORIG_EAX_REGNUM)
54
55 #define GETFPXREGS_SUPPLIES(regno) \
56 (I386_ST0_REGNUM <= (regno) && (regno) < I386_SSE_NUM_REGS)
57
58 #define GETXSTATEREGS_SUPPLIES(regno) \
59 (I386_ST0_REGNUM <= (regno) && (regno) < I386_AVX512_NUM_REGS)
60
61 /* Does the current host support the GETREGS request? */
62 int have_ptrace_getregs =
63 #ifdef HAVE_PTRACE_GETREGS
64 1
65 #else
66 0
67 #endif
68 ;
69
70 /* Does the current host support the GETFPXREGS request? The header
71 file may or may not define it, and even if it is defined, the
72 kernel will return EIO if it's running on a pre-SSE processor.
73
74 My instinct is to attach this to some architecture- or
75 target-specific data structure, but really, a particular GDB
76 process can only run on top of one kernel at a time. So it's okay
77 for this to be a simple variable. */
78 int have_ptrace_getfpxregs =
79 #ifdef HAVE_PTRACE_GETFPXREGS
80 -1
81 #else
82 0
83 #endif
84 ;
85 \f
86
87 /* Accessing registers through the U area, one at a time. */
88
89 /* Fetch one register. */
90
91 static void
92 fetch_register (struct regcache *regcache, int regno)
93 {
94 int tid;
95 int val;
96
97 gdb_assert (!have_ptrace_getregs);
98 if (i386_linux_gregset_reg_offset[regno] == -1)
99 {
100 regcache_raw_supply (regcache, regno, NULL);
101 return;
102 }
103
104 /* GNU/Linux LWP ID's are process ID's. */
105 tid = ptid_get_lwp (inferior_ptid);
106 if (tid == 0)
107 tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
108
109 errno = 0;
110 val = ptrace (PTRACE_PEEKUSER, tid,
111 i386_linux_gregset_reg_offset[regno], 0);
112 if (errno != 0)
113 error (_("Couldn't read register %s (#%d): %s."),
114 gdbarch_register_name (get_regcache_arch (regcache), regno),
115 regno, safe_strerror (errno));
116
117 regcache_raw_supply (regcache, regno, &val);
118 }
119
120 /* Store one register. */
121
122 static void
123 store_register (const struct regcache *regcache, int regno)
124 {
125 int tid;
126 int val;
127
128 gdb_assert (!have_ptrace_getregs);
129 if (i386_linux_gregset_reg_offset[regno] == -1)
130 return;
131
132 /* GNU/Linux LWP ID's are process ID's. */
133 tid = ptid_get_lwp (inferior_ptid);
134 if (tid == 0)
135 tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
136
137 errno = 0;
138 regcache_raw_collect (regcache, regno, &val);
139 ptrace (PTRACE_POKEUSER, tid,
140 i386_linux_gregset_reg_offset[regno], val);
141 if (errno != 0)
142 error (_("Couldn't write register %s (#%d): %s."),
143 gdbarch_register_name (get_regcache_arch (regcache), regno),
144 regno, safe_strerror (errno));
145 }
146 \f
147
148 /* Transfering the general-purpose registers between GDB, inferiors
149 and core files. */
150
151 /* Fill GDB's register array with the general-purpose register values
152 in *GREGSETP. */
153
154 void
155 supply_gregset (struct regcache *regcache, const elf_gregset_t *gregsetp)
156 {
157 const gdb_byte *regp = (const gdb_byte *) gregsetp;
158 int i;
159
160 for (i = 0; i < I386_NUM_GREGS; i++)
161 regcache_raw_supply (regcache, i,
162 regp + i386_linux_gregset_reg_offset[i]);
163
164 if (I386_LINUX_ORIG_EAX_REGNUM
165 < gdbarch_num_regs (get_regcache_arch (regcache)))
166 regcache_raw_supply (regcache, I386_LINUX_ORIG_EAX_REGNUM, regp
167 + i386_linux_gregset_reg_offset[I386_LINUX_ORIG_EAX_REGNUM]);
168 }
169
170 /* Fill register REGNO (if it is a general-purpose register) in
171 *GREGSETPS with the value in GDB's register array. If REGNO is -1,
172 do this for all registers. */
173
174 void
175 fill_gregset (const struct regcache *regcache,
176 elf_gregset_t *gregsetp, int regno)
177 {
178 gdb_byte *regp = (gdb_byte *) gregsetp;
179 int i;
180
181 for (i = 0; i < I386_NUM_GREGS; i++)
182 if (regno == -1 || regno == i)
183 regcache_raw_collect (regcache, i,
184 regp + i386_linux_gregset_reg_offset[i]);
185
186 if ((regno == -1 || regno == I386_LINUX_ORIG_EAX_REGNUM)
187 && I386_LINUX_ORIG_EAX_REGNUM
188 < gdbarch_num_regs (get_regcache_arch (regcache)))
189 regcache_raw_collect (regcache, I386_LINUX_ORIG_EAX_REGNUM, regp
190 + i386_linux_gregset_reg_offset[I386_LINUX_ORIG_EAX_REGNUM]);
191 }
192
193 #ifdef HAVE_PTRACE_GETREGS
194
195 /* Fetch all general-purpose registers from process/thread TID and
196 store their values in GDB's register array. */
197
198 static void
199 fetch_regs (struct regcache *regcache, int tid)
200 {
201 elf_gregset_t regs;
202 elf_gregset_t *regs_p = &regs;
203
204 if (ptrace (PTRACE_GETREGS, tid, 0, (int) &regs) < 0)
205 {
206 if (errno == EIO)
207 {
208 /* The kernel we're running on doesn't support the GETREGS
209 request. Reset `have_ptrace_getregs'. */
210 have_ptrace_getregs = 0;
211 return;
212 }
213
214 perror_with_name (_("Couldn't get registers"));
215 }
216
217 supply_gregset (regcache, (const elf_gregset_t *) regs_p);
218 }
219
220 /* Store all valid general-purpose registers in GDB's register array
221 into the process/thread specified by TID. */
222
223 static void
224 store_regs (const struct regcache *regcache, int tid, int regno)
225 {
226 elf_gregset_t regs;
227
228 if (ptrace (PTRACE_GETREGS, tid, 0, (int) &regs) < 0)
229 perror_with_name (_("Couldn't get registers"));
230
231 fill_gregset (regcache, &regs, regno);
232
233 if (ptrace (PTRACE_SETREGS, tid, 0, (int) &regs) < 0)
234 perror_with_name (_("Couldn't write registers"));
235 }
236
237 #else
238
239 static void fetch_regs (struct regcache *regcache, int tid) {}
240 static void store_regs (const struct regcache *regcache, int tid, int regno) {}
241
242 #endif
243 \f
244
245 /* Transfering floating-point registers between GDB, inferiors and cores. */
246
247 /* Fill GDB's register array with the floating-point register values in
248 *FPREGSETP. */
249
250 void
251 supply_fpregset (struct regcache *regcache, const elf_fpregset_t *fpregsetp)
252 {
253 i387_supply_fsave (regcache, -1, fpregsetp);
254 }
255
256 /* Fill register REGNO (if it is a floating-point register) in
257 *FPREGSETP with the value in GDB's register array. If REGNO is -1,
258 do this for all registers. */
259
260 void
261 fill_fpregset (const struct regcache *regcache,
262 elf_fpregset_t *fpregsetp, int regno)
263 {
264 i387_collect_fsave (regcache, regno, fpregsetp);
265 }
266
267 #ifdef HAVE_PTRACE_GETREGS
268
269 /* Fetch all floating-point registers from process/thread TID and store
270 thier values in GDB's register array. */
271
272 static void
273 fetch_fpregs (struct regcache *regcache, int tid)
274 {
275 elf_fpregset_t fpregs;
276
277 if (ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs) < 0)
278 perror_with_name (_("Couldn't get floating point status"));
279
280 supply_fpregset (regcache, (const elf_fpregset_t *) &fpregs);
281 }
282
283 /* Store all valid floating-point registers in GDB's register array
284 into the process/thread specified by TID. */
285
286 static void
287 store_fpregs (const struct regcache *regcache, int tid, int regno)
288 {
289 elf_fpregset_t fpregs;
290
291 if (ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs) < 0)
292 perror_with_name (_("Couldn't get floating point status"));
293
294 fill_fpregset (regcache, &fpregs, regno);
295
296 if (ptrace (PTRACE_SETFPREGS, tid, 0, (int) &fpregs) < 0)
297 perror_with_name (_("Couldn't write floating point status"));
298 }
299
300 #else
301
302 static void
303 fetch_fpregs (struct regcache *regcache, int tid)
304 {
305 }
306
307 static void
308 store_fpregs (const struct regcache *regcache, int tid, int regno)
309 {
310 }
311
312 #endif
313 \f
314
315 /* Transfering floating-point and SSE registers to and from GDB. */
316
317 /* Fetch all registers covered by the PTRACE_GETREGSET request from
318 process/thread TID and store their values in GDB's register array.
319 Return non-zero if successful, zero otherwise. */
320
321 static int
322 fetch_xstateregs (struct regcache *regcache, int tid)
323 {
324 char xstateregs[X86_XSTATE_MAX_SIZE];
325 struct iovec iov;
326
327 if (!have_ptrace_getregset)
328 return 0;
329
330 iov.iov_base = xstateregs;
331 iov.iov_len = sizeof(xstateregs);
332 if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE,
333 &iov) < 0)
334 perror_with_name (_("Couldn't read extended state status"));
335
336 i387_supply_xsave (regcache, -1, xstateregs);
337 return 1;
338 }
339
340 /* Store all valid registers in GDB's register array covered by the
341 PTRACE_SETREGSET request into the process/thread specified by TID.
342 Return non-zero if successful, zero otherwise. */
343
344 static int
345 store_xstateregs (const struct regcache *regcache, int tid, int regno)
346 {
347 char xstateregs[X86_XSTATE_MAX_SIZE];
348 struct iovec iov;
349
350 if (!have_ptrace_getregset)
351 return 0;
352
353 iov.iov_base = xstateregs;
354 iov.iov_len = sizeof(xstateregs);
355 if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE,
356 &iov) < 0)
357 perror_with_name (_("Couldn't read extended state status"));
358
359 i387_collect_xsave (regcache, regno, xstateregs, 0);
360
361 if (ptrace (PTRACE_SETREGSET, tid, (unsigned int) NT_X86_XSTATE,
362 (int) &iov) < 0)
363 perror_with_name (_("Couldn't write extended state status"));
364
365 return 1;
366 }
367
368 #ifdef HAVE_PTRACE_GETFPXREGS
369
370 /* Fetch all registers covered by the PTRACE_GETFPXREGS request from
371 process/thread TID and store their values in GDB's register array.
372 Return non-zero if successful, zero otherwise. */
373
374 static int
375 fetch_fpxregs (struct regcache *regcache, int tid)
376 {
377 elf_fpxregset_t fpxregs;
378
379 if (! have_ptrace_getfpxregs)
380 return 0;
381
382 if (ptrace (PTRACE_GETFPXREGS, tid, 0, (int) &fpxregs) < 0)
383 {
384 if (errno == EIO)
385 {
386 have_ptrace_getfpxregs = 0;
387 return 0;
388 }
389
390 perror_with_name (_("Couldn't read floating-point and SSE registers"));
391 }
392
393 i387_supply_fxsave (regcache, -1, (const elf_fpxregset_t *) &fpxregs);
394 return 1;
395 }
396
397 /* Store all valid registers in GDB's register array covered by the
398 PTRACE_SETFPXREGS request into the process/thread specified by TID.
399 Return non-zero if successful, zero otherwise. */
400
401 static int
402 store_fpxregs (const struct regcache *regcache, int tid, int regno)
403 {
404 elf_fpxregset_t fpxregs;
405
406 if (! have_ptrace_getfpxregs)
407 return 0;
408
409 if (ptrace (PTRACE_GETFPXREGS, tid, 0, &fpxregs) == -1)
410 {
411 if (errno == EIO)
412 {
413 have_ptrace_getfpxregs = 0;
414 return 0;
415 }
416
417 perror_with_name (_("Couldn't read floating-point and SSE registers"));
418 }
419
420 i387_collect_fxsave (regcache, regno, &fpxregs);
421
422 if (ptrace (PTRACE_SETFPXREGS, tid, 0, &fpxregs) == -1)
423 perror_with_name (_("Couldn't write floating-point and SSE registers"));
424
425 return 1;
426 }
427
428 #else
429
430 static int
431 fetch_fpxregs (struct regcache *regcache, int tid)
432 {
433 return 0;
434 }
435
436 static int
437 store_fpxregs (const struct regcache *regcache, int tid, int regno)
438 {
439 return 0;
440 }
441
442 #endif /* HAVE_PTRACE_GETFPXREGS */
443 \f
444
445 /* Transferring arbitrary registers between GDB and inferior. */
446
447 /* Fetch register REGNO from the child process. If REGNO is -1, do
448 this for all registers (including the floating point and SSE
449 registers). */
450
451 static void
452 i386_linux_fetch_inferior_registers (struct target_ops *ops,
453 struct regcache *regcache, int regno)
454 {
455 int tid;
456
457 /* Use the old method of peeking around in `struct user' if the
458 GETREGS request isn't available. */
459 if (!have_ptrace_getregs)
460 {
461 int i;
462
463 for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
464 if (regno == -1 || regno == i)
465 fetch_register (regcache, i);
466
467 return;
468 }
469
470 /* GNU/Linux LWP ID's are process ID's. */
471 tid = ptid_get_lwp (inferior_ptid);
472 if (tid == 0)
473 tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
474
475 /* Use the PTRACE_GETFPXREGS request whenever possible, since it
476 transfers more registers in one system call, and we'll cache the
477 results. But remember that fetch_fpxregs can fail, and return
478 zero. */
479 if (regno == -1)
480 {
481 fetch_regs (regcache, tid);
482
483 /* The call above might reset `have_ptrace_getregs'. */
484 if (!have_ptrace_getregs)
485 {
486 i386_linux_fetch_inferior_registers (ops, regcache, regno);
487 return;
488 }
489
490 if (fetch_xstateregs (regcache, tid))
491 return;
492 if (fetch_fpxregs (regcache, tid))
493 return;
494 fetch_fpregs (regcache, tid);
495 return;
496 }
497
498 if (GETREGS_SUPPLIES (regno))
499 {
500 fetch_regs (regcache, tid);
501 return;
502 }
503
504 if (GETXSTATEREGS_SUPPLIES (regno))
505 {
506 if (fetch_xstateregs (regcache, tid))
507 return;
508 }
509
510 if (GETFPXREGS_SUPPLIES (regno))
511 {
512 if (fetch_fpxregs (regcache, tid))
513 return;
514
515 /* Either our processor or our kernel doesn't support the SSE
516 registers, so read the FP registers in the traditional way,
517 and fill the SSE registers with dummy values. It would be
518 more graceful to handle differences in the register set using
519 gdbarch. Until then, this will at least make things work
520 plausibly. */
521 fetch_fpregs (regcache, tid);
522 return;
523 }
524
525 internal_error (__FILE__, __LINE__,
526 _("Got request for bad register number %d."), regno);
527 }
528
529 /* Store register REGNO back into the child process. If REGNO is -1,
530 do this for all registers (including the floating point and SSE
531 registers). */
532 static void
533 i386_linux_store_inferior_registers (struct target_ops *ops,
534 struct regcache *regcache, int regno)
535 {
536 int tid;
537
538 /* Use the old method of poking around in `struct user' if the
539 SETREGS request isn't available. */
540 if (!have_ptrace_getregs)
541 {
542 int i;
543
544 for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
545 if (regno == -1 || regno == i)
546 store_register (regcache, i);
547
548 return;
549 }
550
551 /* GNU/Linux LWP ID's are process ID's. */
552 tid = ptid_get_lwp (inferior_ptid);
553 if (tid == 0)
554 tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
555
556 /* Use the PTRACE_SETFPXREGS requests whenever possible, since it
557 transfers more registers in one system call. But remember that
558 store_fpxregs can fail, and return zero. */
559 if (regno == -1)
560 {
561 store_regs (regcache, tid, regno);
562 if (store_xstateregs (regcache, tid, regno))
563 return;
564 if (store_fpxregs (regcache, tid, regno))
565 return;
566 store_fpregs (regcache, tid, regno);
567 return;
568 }
569
570 if (GETREGS_SUPPLIES (regno))
571 {
572 store_regs (regcache, tid, regno);
573 return;
574 }
575
576 if (GETXSTATEREGS_SUPPLIES (regno))
577 {
578 if (store_xstateregs (regcache, tid, regno))
579 return;
580 }
581
582 if (GETFPXREGS_SUPPLIES (regno))
583 {
584 if (store_fpxregs (regcache, tid, regno))
585 return;
586
587 /* Either our processor or our kernel doesn't support the SSE
588 registers, so just write the FP registers in the traditional
589 way. */
590 store_fpregs (regcache, tid, regno);
591 return;
592 }
593
594 internal_error (__FILE__, __LINE__,
595 _("Got request to store bad register number %d."), regno);
596 }
597 \f
598
599 /* Called by libthread_db. Returns a pointer to the thread local
600 storage (or its descriptor). */
601
602 ps_err_e
603 ps_get_thread_area (const struct ps_prochandle *ph,
604 lwpid_t lwpid, int idx, void **base)
605 {
606 unsigned int base_addr;
607 ps_err_e result;
608
609 result = x86_linux_get_thread_area (lwpid, (void *) idx, &base_addr);
610
611 if (result == PS_OK)
612 *(int *) base = base_addr;
613
614 return result;
615 }
616 \f
617
618 /* The instruction for a GNU/Linux system call is:
619 int $0x80
620 or 0xcd 0x80. */
621
622 static const unsigned char linux_syscall[] = { 0xcd, 0x80 };
623
624 #define LINUX_SYSCALL_LEN (sizeof linux_syscall)
625
626 /* The system call number is stored in the %eax register. */
627 #define LINUX_SYSCALL_REGNUM I386_EAX_REGNUM
628
629 /* We are specifically interested in the sigreturn and rt_sigreturn
630 system calls. */
631
632 #ifndef SYS_sigreturn
633 #define SYS_sigreturn 0x77
634 #endif
635 #ifndef SYS_rt_sigreturn
636 #define SYS_rt_sigreturn 0xad
637 #endif
638
639 /* Offset to saved processor flags, from <asm/sigcontext.h>. */
640 #define LINUX_SIGCONTEXT_EFLAGS_OFFSET (64)
641
642 /* Resume execution of the inferior process.
643 If STEP is nonzero, single-step it.
644 If SIGNAL is nonzero, give it that signal. */
645
646 static void
647 i386_linux_resume (struct target_ops *ops,
648 ptid_t ptid, int step, enum gdb_signal signal)
649 {
650 int pid = ptid_get_pid (ptid);
651
652 int request;
653
654 if (catch_syscall_enabled () > 0)
655 request = PTRACE_SYSCALL;
656 else
657 request = PTRACE_CONT;
658
659 if (step)
660 {
661 struct regcache *regcache = get_thread_regcache (pid_to_ptid (pid));
662 struct gdbarch *gdbarch = get_regcache_arch (regcache);
663 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
664 ULONGEST pc;
665 gdb_byte buf[LINUX_SYSCALL_LEN];
666
667 request = PTRACE_SINGLESTEP;
668
669 regcache_cooked_read_unsigned (regcache,
670 gdbarch_pc_regnum (gdbarch), &pc);
671
672 /* Returning from a signal trampoline is done by calling a
673 special system call (sigreturn or rt_sigreturn, see
674 i386-linux-tdep.c for more information). This system call
675 restores the registers that were saved when the signal was
676 raised, including %eflags. That means that single-stepping
677 won't work. Instead, we'll have to modify the signal context
678 that's about to be restored, and set the trace flag there. */
679
680 /* First check if PC is at a system call. */
681 if (target_read_memory (pc, buf, LINUX_SYSCALL_LEN) == 0
682 && memcmp (buf, linux_syscall, LINUX_SYSCALL_LEN) == 0)
683 {
684 ULONGEST syscall;
685 regcache_cooked_read_unsigned (regcache,
686 LINUX_SYSCALL_REGNUM, &syscall);
687
688 /* Then check the system call number. */
689 if (syscall == SYS_sigreturn || syscall == SYS_rt_sigreturn)
690 {
691 ULONGEST sp, addr;
692 unsigned long int eflags;
693
694 regcache_cooked_read_unsigned (regcache, I386_ESP_REGNUM, &sp);
695 if (syscall == SYS_rt_sigreturn)
696 addr = read_memory_unsigned_integer (sp + 8, 4, byte_order)
697 + 20;
698 else
699 addr = sp;
700
701 /* Set the trace flag in the context that's about to be
702 restored. */
703 addr += LINUX_SIGCONTEXT_EFLAGS_OFFSET;
704 read_memory (addr, (gdb_byte *) &eflags, 4);
705 eflags |= 0x0100;
706 write_memory (addr, (gdb_byte *) &eflags, 4);
707 }
708 }
709 }
710
711 if (ptrace (request, pid, 0, gdb_signal_to_host (signal)) == -1)
712 perror_with_name (("ptrace"));
713 }
714 \f
715
716 /* -Wmissing-prototypes */
717 extern initialize_file_ftype _initialize_i386_linux_nat;
718
719 void
720 _initialize_i386_linux_nat (void)
721 {
722 /* Create a generic x86 GNU/Linux target. */
723 struct target_ops *t = x86_linux_create_target ();
724
725 /* Override the default ptrace resume method. */
726 t->to_resume = i386_linux_resume;
727
728 /* Add our register access methods. */
729 t->to_fetch_registers = i386_linux_fetch_inferior_registers;
730 t->to_store_registers = i386_linux_store_inferior_registers;
731
732 /* Add the target. */
733 x86_linux_add_target (t);
734 }
This page took 0.084468 seconds and 5 git commands to generate.