]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-implptr-64bit-1of2.patch
- up to 7.3.1
[packages/gdb.git] / gdb-implptr-64bit-1of2.patch
1 http://sourceware.org/ml/gdb-patches/2011-09/msg00450.html
2 Subject: [patch 1/2] Code cleanup: Unify dwarf2_per_cu_addr_size, dwarf2_per_cu_offset_size
3
4 Hi,
5
6 this is more rather for patch 2/2, it has positive LoC change but still
7 I would find it applicable even on its own.
8
9 No functionality change intended.
10
11
12 Thanks,
13 Jan
14
15
16 gdb/
17 2011-09-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
18
19         Code cleanup.
20         * dwarf2read.c (per_cu_header_read_in): New function.
21         (dwarf2_per_cu_addr_size, dwarf2_per_cu_offset_size): Use it, with new
22         variables cu_header_local and cu_headerp.
23
24 --- a/gdb/dwarf2read.c
25 +++ b/gdb/dwarf2read.c
26 @@ -15187,26 +15187,42 @@ dwarf2_per_cu_objfile (struct dwarf2_per_cu_data *per_cu)
27    return objfile;
28  }
29  
30 +/* Return comp_unit_head for PER_CU, either already available in PER_CU->CU
31 +   (CU_HEADERP is unused in such case) or prepare a temporary copy at
32 +   CU_HEADERP first.  */
33 +
34 +static const struct comp_unit_head *
35 +per_cu_header_read_in (struct comp_unit_head *cu_headerp,
36 +                      struct dwarf2_per_cu_data *per_cu)
37 +{
38 +  struct objfile *objfile;
39 +  struct dwarf2_per_objfile *per_objfile;
40 +  gdb_byte *info_ptr;
41 +
42 +  if (per_cu->cu)
43 +    return &per_cu->cu->header;
44 +
45 +  objfile = per_cu->objfile;
46 +  per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
47 +  info_ptr = per_objfile->info.buffer + per_cu->offset;
48 +
49 +  memset (cu_headerp, 0, sizeof (*cu_headerp));
50 +  read_comp_unit_head (cu_headerp, info_ptr, objfile->obfd);
51 +
52 +  return cu_headerp;
53 +}
54 +
55  /* Return the address size given in the compilation unit header for CU.  */
56  
57  CORE_ADDR
58  dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu)
59  {
60 -  if (per_cu->cu)
61 -    return per_cu->cu->header.addr_size;
62 -  else
63 -    {
64 -      /* If the CU is not currently read in, we re-read its header.  */
65 -      struct objfile *objfile = per_cu->objfile;
66 -      struct dwarf2_per_objfile *per_objfile
67 -       = objfile_data (objfile, dwarf2_objfile_data_key);
68 -      gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset;
69 -      struct comp_unit_head cu_header;
70 +  struct comp_unit_head cu_header_local;
71 +  const struct comp_unit_head *cu_headerp;
72  
73 -      memset (&cu_header, 0, sizeof cu_header);
74 -      read_comp_unit_head (&cu_header, info_ptr, objfile->obfd);
75 -      return cu_header.addr_size;
76 -    }
77 +  cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu);
78 +
79 +  return cu_headerp->addr_size;
80  }
81  
82  /* Return the offset size given in the compilation unit header for CU.  */
83 @@ -15214,21 +15230,12 @@ dwarf2_per_cu_addr_size (struct dwarf2_per_cu_data *per_cu)
84  int
85  dwarf2_per_cu_offset_size (struct dwarf2_per_cu_data *per_cu)
86  {
87 -  if (per_cu->cu)
88 -    return per_cu->cu->header.offset_size;
89 -  else
90 -    {
91 -      /* If the CU is not currently read in, we re-read its header.  */
92 -      struct objfile *objfile = per_cu->objfile;
93 -      struct dwarf2_per_objfile *per_objfile
94 -       = objfile_data (objfile, dwarf2_objfile_data_key);
95 -      gdb_byte *info_ptr = per_objfile->info.buffer + per_cu->offset;
96 -      struct comp_unit_head cu_header;
97 +  struct comp_unit_head cu_header_local;
98 +  const struct comp_unit_head *cu_headerp;
99  
100 -      memset (&cu_header, 0, sizeof cu_header);
101 -      read_comp_unit_head (&cu_header, info_ptr, objfile->obfd);
102 -      return cu_header.offset_size;
103 -    }
104 +  cu_headerp = per_cu_header_read_in (&cu_header_local, per_cu);
105 +
106 +  return cu_headerp->offset_size;
107  }
108  
109  /* Return the text offset of the CU.  The returned offset comes from
110
This page took 0.047589 seconds and 3 git commands to generate.