##// END OF EJS Templates
Fixed some issues on elf parser and generic binary file widget work in progress.
Jeandet Alexis -
r4:00ff7d3b610f default
parent child
Show More
@@ -0,0 +1,6
1 <RCC>
2 <qresource prefix="/img">
3 <file>ressources/Gnome-list-add.svg</file>
4 <file>ressources/Gnome-user-trash.svg</file>
5 </qresource>
6 </RCC>
@@ -0,0 +1,102
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!-- Created with Inkscape (http://www.inkscape.org/) -->
3 <svg
4 xmlns:dc="http://purl.org/dc/elements/1.1/"
5 xmlns:cc="http://web.resource.org/cc/"
6 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7 xmlns:svg="http://www.w3.org/2000/svg"
8 xmlns="http://www.w3.org/2000/svg"
9 xmlns:xlink="http://www.w3.org/1999/xlink"
10 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12 width="48"
13 height="48"
14 id="svg4289"
15 sodipodi:version="0.32"
16 inkscape:version="0.45"
17 version="1.0"
18 sodipodi:docbase="/home/dobey/Projects/gnome-icon-theme/scalable/actions"
19 sodipodi:docname="list-add.svg"
20 inkscape:export-filename="/home/andreas/project/gnome-icon-theme/scalable/actions/list-add.png"
21 inkscape:export-xdpi="90"
22 inkscape:export-ydpi="90"
23 inkscape:output_extension="org.inkscape.output.svg.inkscape">
24 <defs
25 id="defs4291">
26 <linearGradient
27 inkscape:collect="always"
28 id="linearGradient4622">
29 <stop
30 style="stop-color:#b4b5b3;stop-opacity:1"
31 offset="0"
32 id="stop4624" />
33 <stop
34 style="stop-color:#d8d9d7;stop-opacity:1"
35 offset="1"
36 id="stop4626" />
37 </linearGradient>
38 <linearGradient
39 inkscape:collect="always"
40 xlink:href="#linearGradient4622"
41 id="linearGradient4320"
42 gradientUnits="userSpaceOnUse"
43 gradientTransform="matrix(2.810197,0,0,2.747234,1.562312,1.675085)"
44 x1="8.6790628"
45 y1="6.7354665"
46 x2="8.7223368"
47 y2="10.858153" />
48 </defs>
49 <sodipodi:namedview
50 id="base"
51 pagecolor="#ffffff"
52 bordercolor="#666666"
53 borderopacity="1.0"
54 inkscape:pageopacity="0.0"
55 inkscape:pageshadow="2"
56 inkscape:zoom="16"
57 inkscape:cx="28.380765"
58 inkscape:cy="26.638236"
59 inkscape:current-layer="layer1"
60 showgrid="false"
61 inkscape:grid-bbox="true"
62 inkscape:document-units="px"
63 width="48px"
64 height="48px"
65 showguides="true"
66 inkscape:guide-bbox="true"
67 inkscape:window-width="1673"
68 inkscape:window-height="968"
69 inkscape:window-x="1"
70 inkscape:window-y="27" />
71 <metadata
72 id="metadata4294">
73 <rdf:RDF>
74 <cc:Work
75 rdf:about="">
76 <dc:format>image/svg+xml</dc:format>
77 <dc:type
78 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
79 </cc:Work>
80 </rdf:RDF>
81 </metadata>
82 <g
83 id="layer1"
84 inkscape:label="Layer 1"
85 inkscape:groupmode="layer">
86 <path
87 style="opacity:1;fill:url(#linearGradient4320);fill-opacity:1;stroke:#555753;stroke-width:1.00000048;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
88 d="M 8.4999995,21.548779 L 8.4999995,26.514266 L 21.542175,26.514266 L 21.542175,38.455753 L 26.527841,38.500024 L 26.499007,26.514266 L 39.499998,26.469995 L 39.499998,21.548779 L 26.478909,21.548779 L 26.482175,8.542935 L 21.498141,8.5000092 L 21.496508,21.55147 L 8.4999995,21.548779 z "
89 id="path4314"
90 sodipodi:nodetypes="ccccccccccccc" />
91 <path
92 style="opacity:0.2;fill:white;fill-opacity:1;stroke:none;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1"
93 d="M 9,22.072045 L 22.070199,22.072045 L 22.065556,9 L 26.002778,9.1688851 L 25.957932,22.156486 L 38.906989,22.072045 L 38.906989,24.048454 L 9,24.048454 L 9,22.072045 z "
94 id="path4316"
95 sodipodi:nodetypes="ccccccccc" />
96 <path
97 style="opacity:0.4;fill:none;fill-opacity:1;stroke:white;stroke-width:1.00000024;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
98 d="M 9.5000012,22.518518 L 9.5000012,25.561981 L 22.540436,25.561981 L 22.540436,37.458666 L 25.525069,37.499986 L 25.498095,25.561981 L 38.500003,25.520661 L 38.500003,22.518518 L 25.567682,22.518518 L 25.570737,9.540046 L 22.499243,9.499982 L 22.497715,22.52103 L 9.5000012,22.518518 z "
99 id="path5202"
100 sodipodi:nodetypes="ccccccccccccc" />
101 </g>
102 </svg>
@@ -0,0 +1,266
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!-- Created with Inkscape (http://www.inkscape.org/) -->
3 <svg
4 xmlns:dc="http://purl.org/dc/elements/1.1/"
5 xmlns:cc="http://web.resource.org/cc/"
6 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7 xmlns:svg="http://www.w3.org/2000/svg"
8 xmlns="http://www.w3.org/2000/svg"
9 xmlns:xlink="http://www.w3.org/1999/xlink"
10 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12 width="48"
13 height="48"
14 id="svg1"
15 sodipodi:version="0.32"
16 inkscape:version="0.45"
17 sodipodi:docbase="/home/dobey/Projects/gnome-icon-theme/scalable/places"
18 sodipodi:docname="user-trash.svg"
19 version="1.0"
20 inkscape:output_extension="org.inkscape.output.svg.inkscape">
21 <defs
22 id="defs3">
23 <linearGradient
24 id="linearGradient4524">
25 <stop
26 style="stop-color:#417ac3;stop-opacity:1;"
27 offset="0"
28 id="stop4526" />
29 <stop
30 style="stop-color:#3465a4;stop-opacity:1;"
31 offset="1"
32 id="stop4528" />
33 </linearGradient>
34 <linearGradient
35 inkscape:collect="always"
36 id="linearGradient5411">
37 <stop
38 style="stop-color:#ffffff;stop-opacity:1;"
39 offset="0"
40 id="stop5413" />
41 <stop
42 style="stop-color:#ffffff;stop-opacity:0;"
43 offset="1"
44 id="stop5415" />
45 </linearGradient>
46 <linearGradient
47 inkscape:collect="always"
48 id="linearGradient4211">
49 <stop
50 style="stop-color:#000000;stop-opacity:1;"
51 offset="0"
52 id="stop4213" />
53 <stop
54 style="stop-color:#000000;stop-opacity:0;"
55 offset="1"
56 id="stop4215" />
57 </linearGradient>
58 <linearGradient
59 id="linearGradient1877">
60 <stop
61 style="stop-color:#000000;stop-opacity:0.17964073;"
62 offset="0.0000000"
63 id="stop1878" />
64 <stop
65 style="stop-color:#000000;stop-opacity:0.0000000;"
66 offset="1.0000000"
67 id="stop1879" />
68 </linearGradient>
69 <linearGradient
70 id="linearGradient1869">
71 <stop
72 style="stop-color:#eff3f4;stop-opacity:1.0000000;"
73 offset="0.0000000"
74 id="stop1870" />
75 <stop
76 style="stop-color:#939596;stop-opacity:1.0000000;"
77 offset="1.0000000"
78 id="stop1871" />
79 </linearGradient>
80 <linearGradient
81 inkscape:collect="always"
82 xlink:href="#linearGradient1869"
83 id="linearGradient1872"
84 gradientTransform="matrix(1.436131,0,0,0.475306,-6.508085,6.805509)"
85 x1="-4.6375198"
86 y1="104.38752"
87 x2="-4.523921"
88 y2="110.61378"
89 gradientUnits="userSpaceOnUse" />
90 <linearGradient
91 inkscape:collect="always"
92 xlink:href="#linearGradient1877"
93 id="linearGradient1894"
94 gradientUnits="userSpaceOnUse"
95 gradientTransform="matrix(-0.358726,0,0,1.867845,-36.85125,41.4295)"
96 x1="-84.334358"
97 y1="9.5548248"
98 x2="-84.334358"
99 y2="12.485031" />
100 <radialGradient
101 inkscape:collect="always"
102 xlink:href="#linearGradient4211"
103 id="radialGradient4217"
104 cx="18.738329"
105 cy="41.63604"
106 fx="18.738329"
107 fy="41.63604"
108 r="21.743534"
109 gradientTransform="matrix(1,0,0,0.333333,0,27.75736)"
110 gradientUnits="userSpaceOnUse" />
111 <linearGradient
112 inkscape:collect="always"
113 xlink:href="#linearGradient5411"
114 id="linearGradient5417"
115 x1="-17.000057"
116 y1="73.479156"
117 x2="-19.345716"
118 y2="98.479156"
119 gradientUnits="userSpaceOnUse"
120 gradientTransform="matrix(1,0,0,0.979216,0,1.222246)" />
121 <linearGradient
122 inkscape:collect="always"
123 xlink:href="#linearGradient4524"
124 id="linearGradient4530"
125 x1="-33.22401"
126 y1="71.791658"
127 x2="7.1282601"
128 y2="71.791658"
129 gradientUnits="userSpaceOnUse" />
130 </defs>
131 <sodipodi:namedview
132 inkscape:document-units="px"
133 id="base"
134 pagecolor="#ffffff"
135 bordercolor="#000000"
136 borderopacity="0.11372549"
137 inkscape:pageopacity="0.0"
138 inkscape:pageshadow="2"
139 inkscape:zoom="4"
140 inkscape:cx="32.887321"
141 inkscape:cy="22.661013"
142 inkscape:current-layer="g1623"
143 inkscape:window-width="872"
144 inkscape:window-height="695"
145 inkscape:window-x="790"
146 inkscape:window-y="365"
147 fill="#204a87"
148 inkscape:showpageshadow="false"
149 showgrid="false" />
150 <metadata
151 id="metadata4">
152 <rdf:RDF>
153 <cc:Work
154 rdf:about="">
155 <dc:format>image/svg+xml</dc:format>
156 <dc:type
157 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
158 <dc:title>Trash</dc:title>
159 <dc:creator>
160 <cc:Agent>
161 <dc:title>Jakub Steiner</dc:title>
162 </cc:Agent>
163 </dc:creator>
164 <dc:date />
165 <dc:subject>
166 <rdf:Bag>
167 <rdf:li>trash</rdf:li>
168 <rdf:li>delete</rdf:li>
169 <rdf:li>wastebasket</rdf:li>
170 <rdf:li>empty</rdf:li>
171 </rdf:Bag>
172 </dc:subject>
173 <dc:description />
174 <cc:license
175 rdf:resource="http://creativecommons.org/licenses/GPL/2.0/" />
176 </cc:Work>
177 <cc:License
178 rdf:about="http://creativecommons.org/licenses/GPL/2.0/">
179 <cc:permits
180 rdf:resource="http://web.resource.org/cc/Reproduction" />
181 <cc:permits
182 rdf:resource="http://web.resource.org/cc/Distribution" />
183 <cc:requires
184 rdf:resource="http://web.resource.org/cc/Notice" />
185 <cc:permits
186 rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
187 <cc:requires
188 rdf:resource="http://web.resource.org/cc/ShareAlike" />
189 <cc:requires
190 rdf:resource="http://web.resource.org/cc/SourceCode" />
191 </cc:License>
192 </rdf:RDF>
193 </metadata>
194 <g
195 inkscape:groupmode="layer"
196 id="layer2"
197 inkscape:label="Shadow">
198 <path
199 sodipodi:type="arc"
200 style="opacity:1;color:#000000;fill:url(#radialGradient4217);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.99999982px;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"
201 id="path3336"
202 sodipodi:cx="18.738329"
203 sodipodi:cy="41.63604"
204 sodipodi:rx="21.743534"
205 sodipodi:ry="7.2478447"
206 d="M 40.481863 41.63604 A 21.743534 7.2478447 0 1 1 -3.0052052,41.63604 A 21.743534 7.2478447 0 1 1 40.481863 41.63604 z"
207 transform="translate(5.303301,-0.707107)" />
208 </g>
209 <g
210 inkscape:label="Pixmap Background"
211 inkscape:groupmode="layer"
212 id="layer1" />
213 <g
214 inkscape:label="Layer 1"
215 inkscape:groupmode="layer"
216 id="g1623"
217 transform="translate(37.06885,-41.11763)">
218 <path
219 style="fill:url(#linearGradient4530);fill-opacity:1.0;fill-rule:evenodd;stroke:#204a87;stroke-width:1.02320302;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1"
220 d="M -32.711617,57.920772 C -32.75484,57.886856 -31.013657,82.319708 -31.013161,82.327116 C -30.849819,84.76715 -29.478625,85.658942 -27.943864,85.662576 C -27.889022,85.6627 0.84900065,85.659434 1.4612656,85.656892 C 4.0458711,85.64616 4.6790717,84.093225 4.8490952,82.396482 C 4.8627317,82.363025 6.603023,57.954228 6.6166586,57.920772 C -6.4927658,57.920772 -19.602191,57.920772 -32.711617,57.920772 z "
221 id="path1751"
222 sodipodi:nodetypes="ccccccc"
223 inkscape:r_cx="true"
224 inkscape:r_cy="true" />
225 <path
226 sodipodi:nodetypes="ccccccc"
227 id="path4536"
228 d="M -31.487684,58.804659 C -31.528216,58.773117 -29.957445,81.748687 -29.957445,81.748687 C -29.80427,84.018051 -29.080923,84.602662 -27.64169,84.606042 C -27.64169,84.606042 0.3590203,84.603118 0.93317605,84.600756 C 3.3569079,84.590774 3.6381962,83.207662 3.797637,81.629598 C 3.797637,81.629598 5.379895,58.835775 5.3926819,58.804659 C -6.9007726,58.804659 -19.194228,58.804659 -31.487684,58.804659 z "
229 style="opacity:0.32967033;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient5417);stroke-width:1.02320278;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1"
230 inkscape:r_cx="true"
231 inkscape:r_cy="true" />
232 <path
233 style="fill:url(#linearGradient1872);fill-opacity:1;fill-rule:evenodd;stroke:#555555;stroke-width:1.02320313;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1"
234 d="M -29.082499,45.829563 C -30.106321,45.831929 -30.963179,45.85588 -31.429903,46.84186 C -31.511024,47.013232 -33.983709,53.968498 -34.102588,54.233742 C -35.120311,56.50448 -34.181763,59.364893 -32.216058,59.345744 C -31.84223,59.342218 6.518454,59.363478 7.1133033,59.345744 C 8.7866141,59.296726 9.0007434,55.984399 8.2803939,54.494337 C 8.2395836,54.40992 4.8963639,46.747074 4.8110968,46.611348 C 4.4167208,46.005189 3.5335502,45.739533 2.8775216,45.764414 C 2.7482894,45.769438 -28.954598,45.829269 -29.082499,45.829563 z "
235 id="path1841"
236 sodipodi:nodetypes="cssssscss"
237 inkscape:r_cx="true"
238 inkscape:r_cy="true" />
239 <path
240 style="color:#000000;fill:#204a87;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block"
241 d="M -28.904114,47.210295 C -29.869702,47.197065 -29.932579,47.157501 -30.149937,47.881742 C -30.200113,48.048927 -32.221643,54.630972 -32.300884,54.88639 C -32.570366,55.755015 -32.189294,55.984256 -31.254099,55.966598 C -30.922809,55.960343 5.359423,55.966598 5.8868702,55.966598 C 6.6356452,55.966598 6.8577579,55.705163 6.6886176,55.088159 C 6.6198886,54.837443 3.8056452,47.809751 3.7300723,47.684596 C 3.3805322,47.125649 3.4411517,47.127276 2.8306245,47.119396 C 2.7160102,47.117916 -28.790763,47.211847 -28.904114,47.210295 z "
242 id="path1864"
243 sodipodi:nodetypes="cssssscss"
244 inkscape:r_cx="true"
245 inkscape:r_cy="true" />
246 <path
247 style="color:#000000;fill:#132c52;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block"
248 d="M -29.42274,47.202148 C -29.786334,47.23159 -29.961217,47.34586 -30.113402,47.853333 C -30.163578,48.020644 -32.182887,54.597959 -32.262128,54.85357 C -32.531611,55.722851 -32.17412,55.956548 -31.238926,55.938879 C -31.222726,55.938575 -29.323942,55.939131 -29.144207,55.938879 L -29.42274,47.202148 z "
249 id="path1880"
250 sodipodi:nodetypes="cccccc"
251 inkscape:r_cx="true"
252 inkscape:r_cy="true" />
253 <path
254 style="color:#000000;fill:#729fcf;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block"
255 d="M 2.8823282,47.11678 C 3.3242332,47.120782 3.4540015,47.111397 3.7365037,47.677324 C 3.7751374,47.754718 6.55447,54.735164 6.6542609,54.990551 C 6.9936352,55.974555 6.3472779,55.953979 5.3221031,55.982521 C 5.1273467,55.982217 2.8232902,55.959675 2.5969422,55.959422 L 2.8823282,47.11678 z "
256 id="path1888"
257 sodipodi:nodetypes="cscccc"
258 inkscape:r_cx="true"
259 inkscape:r_cy="true" />
260 <path
261 style="color:#000000;fill:url(#linearGradient1894);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block"
262 d="M 5.8674719,59.783199 L -29.241178,59.84715 C -2.6592192,60.465334 2.5633795,63.385727 5.8035217,63.236509 L 5.8674719,59.783199 z "
263 id="path1893"
264 sodipodi:nodetypes="cccc" />
265 </g>
266 </svg>
@@ -1,346 +1,354
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "elffilewidget.h"
22 #include "elffilewidget.h"
23 #include "ui_elffilewidget.h"
23 #include "ui_elffilewidget.h"
24 #include <QtWidgets/QTableWidgetItem>
24 #include <QtWidgets/QTableWidgetItem>
25 #include <QtWidgets/QFileDialog>
25 #include <QtWidgets/QFileDialog>
26 #include "qhexedit.h"
26 #include "qhexedit.h"
27 #include "qtablewidgetintitem.h"
27 #include "qtablewidgetintitem.h"
28 #include "../srec/srecfile.h"
28 #include "../srec/srecfile.h"
29 #include "../BinFile/binaryfile.h"
29 #include "../BinFile/binaryfile.h"
30
30
31 elfFileWidget::elfFileWidget(QWidget *parent) :
31 elfFileWidget::elfFileWidget(QWidget *parent) :
32 abstractBinFileWidget(parent),
32 abstractBinFileWidget(parent),
33 ui(new Ui::elfFileWidget)
33 ui(new Ui::elfFileWidget)
34 {
34 {
35 ui->setupUi(this);
35 ui->setupUi(this);
36 exportToSREC_action = new QAction(tr("Export to SREC"),this);
36 exportToSREC_action = new QAction(tr("Export to SREC"),this);
37 exportToBIN_action = new QAction(tr("Export to Binary"),this);
37 exportToBIN_action = new QAction(tr("Export to Binary"),this);
38 viewSymbolInHexViewer_action = new QAction(tr("View in Hexviewer"),this);
38 viewSymbolInHexViewer_action = new QAction(tr("View in Hexviewer"),this);
39 connect(this->ui->sectionsList,SIGNAL(cellActivated(int,int)),this,SLOT(sectionCellActivated(int,int)));
39 connect(this->ui->sectionsList,SIGNAL(cellActivated(int,int)),this,SLOT(sectionCellActivated(int,int)));
40 this->ui->sectionsList->addAction(exportToSREC_action);
40 this->ui->sectionsList->addAction(exportToSREC_action);
41 this->ui->sectionsList->addAction(exportToBIN_action);
41 this->ui->sectionsList->addAction(exportToBIN_action);
42 this->ui->symbolsList->addAction(viewSymbolInHexViewer_action);
42 this->ui->symbolsList->addAction(viewSymbolInHexViewer_action);
43 this->ui->symbolsList->addAction(exportToSREC_action);
43 this->ui->symbolsList->addAction(exportToSREC_action);
44 this->ui->symbolsList->addAction(exportToBIN_action);
44 this->ui->symbolsList->addAction(exportToBIN_action);
45 connect(this->exportToBIN_action,SIGNAL(triggered()),this,SLOT(exportToBIN()));
45 connect(this->exportToBIN_action,SIGNAL(triggered()),this,SLOT(exportToBIN()));
46 connect(this->exportToSREC_action,SIGNAL(triggered()),this,SLOT(exportToSREC()));
46 connect(this->exportToSREC_action,SIGNAL(triggered()),this,SLOT(exportToSREC()));
47 connect(this->ui->symbolsFilter,SIGNAL(textChanged(QString)),this,SLOT(filterSymbols(QString)));
47 connect(this->ui->symbolsFilter,SIGNAL(textChanged(QString)),this,SLOT(filterSymbols(QString)));
48 connect(this->ui->caseSensitive,SIGNAL(toggled(bool)),this,SLOT(filterSymbolsCaseUpdate(bool)));
48 connect(this->ui->caseSensitive,SIGNAL(toggled(bool)),this,SLOT(filterSymbolsCaseUpdate(bool)));
49 connect(this->viewSymbolInHexViewer_action,SIGNAL(triggered()),this,SLOT(viewSymbolInHexViewer()));
49 connect(this->viewSymbolInHexViewer_action,SIGNAL(triggered()),this,SLOT(viewSymbolInHexViewer()));
50 this->p_hexviewer = new QHexEdit();
50 this->p_hexviewer = new QHexEdit();
51 this->p_hexviewer->setWindowTitle("SocExplorer Hexadecimal viewer");
51 this->p_hexviewer->setWindowTitle("SocExplorer Hexadecimal viewer");
52 this->setWindowTitle("SocExplorer Elf viewer");
52 this->setWindowTitle("SocExplorer Elf viewer");
53 }
53 }
54
54
55
55
56
56
57 elfFileWidget::~elfFileWidget()
57 elfFileWidget::~elfFileWidget()
58 {
58 {
59 delete ui;
59 delete ui;
60 delete p_hexviewer;
60 delete p_hexviewer;
61 }
61 }
62
62
63
63
64
64
65 void elfFileWidget::setFile(ElfFile *file)
65 void elfFileWidget::setFile(abstractBinFile *file)
66 {
66 {
67 this->p_elf = file;
67 this->p_elf = (ElfFile*)file;
68 if(p_elf->isopened() && p_elf->iself())
68 if(p_elf->isopened() && p_elf->iself())
69 {
69 {
70 this->ui->classLabel->setText(p_elf->getClass());
70 this->ui->classLabel->setText(p_elf->getClass());
71 this->ui->VersionLabel->setText(QString::number(p_elf->getVersion()));
71 this->ui->VersionLabel->setText(QString::number(p_elf->getVersion()));
72 this->ui->machineLabel->setText(p_elf->getArchitecture());
72 this->ui->machineLabel->setText(p_elf->getArchitecture());
73 this->ui->endiannesLabel->setText(p_elf->getEndianness());
73 this->ui->endiannesLabel->setText(p_elf->getEndianness());
74 this->ui->abiLabel->setText(p_elf->getABI());
74 this->ui->abiLabel->setText(p_elf->getABI());
75 this->ui->entryPointLabel->setText(QString("0x%1").arg((uint)p_elf->getEntryPointAddress(),8,16));
75 this->ui->entryPointLabel->setText(QString("0x%1").arg((uint)p_elf->getEntryPointAddress(),8,16));
76 this->ui->typeLabel->setText(p_elf->getType());
76 this->ui->typeLabel->setText(p_elf->getType());
77 this->ui->sectionCountLabel->setText(QString::number(p_elf->getSectionCount()));
77 this->ui->sectionCountLabel->setText(QString::number(p_elf->getSectionCount()));
78 this->ui->symbolCountLabel->setText(QString::number(p_elf->getSymbolCount()));
78 this->ui->symbolCountLabel->setText(QString::number(p_elf->getSymbolCount()));
79 }
79 }
80 reloadFile();
80 reloadFile();
81 }
81 }
82
82
83 void elfFileWidget::reloadFile()
83 void elfFileWidget::reloadFile()
84 {
84 {
85 updateSymbols();
85 updateSymbols();
86 updateSections();
86 updateSections();
87 }
87 }
88
88
89
89
90
90
91 void elfFileWidget::updateSymbols()
91 void elfFileWidget::updateSymbols()
92 {
92 {
93 this->ui->symbolsList->clear();
93 this->ui->symbolsList->clear();
94 this->ui->symbolsList->setRowCount(p_elf->getSymbolCount());
94 this->ui->symbolsList->setRowCount(p_elf->getSymbolCount());
95 this->ui->symbolsList->setHorizontalHeaderLabels(QStringList()<<"Index"<<"Value"<<"Size"<<"Type"<<"Link"<<"Section"<<"Name");
95 this->ui->symbolsList->setHorizontalHeaderLabels(QStringList()<<"Index"<<"Value"<<"Size"<<"Type"<<"Link"<<"Section"<<"Name");
96 for(int i=0;i<p_elf->getSymbolCount();i++)
96 for(int i=0;i<p_elf->getSymbolCount();i++)
97 {
97 {
98 QTableWidgetItem *newItem = (QTableWidgetItem*)new QTableWidgetIntItem(QString("%1").arg(i),DecimalItem);
98 QTableWidgetItem *newItem = (QTableWidgetItem*)new QTableWidgetIntItem(QString("%1").arg(i),DecimalItem);
99 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
99 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
100 this->ui->symbolsList->setItem(i, 0, newItem);
100 this->ui->symbolsList->setItem(i, 0, newItem);
101
101
102 newItem = (QTableWidgetItem*)new QTableWidgetIntItem(QString("0x%1").arg(p_elf->getSymbolAddress(i),8,16).replace(" ","0"),HexaDecimalItem);
102 newItem = (QTableWidgetItem*)new QTableWidgetIntItem(QString("0x%1").arg(p_elf->getSymbolAddress(i),8,16).replace(" ","0"),HexaDecimalItem);
103 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
103 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
104 this->ui->symbolsList->setItem(i, 1, newItem);
104 this->ui->symbolsList->setItem(i, 1, newItem);
105
105
106 newItem = (QTableWidgetItem*)new QTableWidgetIntItem(QString("%1").arg(p_elf->getSymbolSize(i)),DecimalItem);
106 newItem = (QTableWidgetItem*)new QTableWidgetIntItem(QString("%1").arg(p_elf->getSymbolSize(i)),DecimalItem);
107 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
107 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
108 this->ui->symbolsList->setItem(i, 2, newItem);
108 this->ui->symbolsList->setItem(i, 2, newItem);
109
109
110 newItem = new QTableWidgetItem(p_elf->getSymbolType(i));
110 newItem = new QTableWidgetItem(p_elf->getSymbolType(i));
111 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
111 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
112 this->ui->symbolsList->setItem(i, 3, newItem);
112 this->ui->symbolsList->setItem(i, 3, newItem);
113
113
114 newItem = new QTableWidgetItem(p_elf->getSymbolLinkType(i));
114 newItem = new QTableWidgetItem(p_elf->getSymbolLinkType(i));
115 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
115 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
116 this->ui->symbolsList->setItem(i, 4, newItem);
116 this->ui->symbolsList->setItem(i, 4, newItem);
117
117
118 newItem = new QTableWidgetItem(p_elf->getSymbolSectionName(i));
118 newItem = new QTableWidgetItem(p_elf->getSymbolSectionName(i));
119 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
119 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
120 this->ui->symbolsList->setItem(i, 5, newItem);
120 this->ui->symbolsList->setItem(i, 5, newItem);
121
121
122 newItem = new QTableWidgetItem(p_elf->getSymbolName(i));
122 newItem = new QTableWidgetItem(p_elf->getSymbolName(i));
123 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
123 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
124 this->ui->symbolsList->setItem(i, 6, newItem);
124 this->ui->symbolsList->setItem(i, 6, newItem);
125 }
125 }
126 this->ui->symbolsList->resizeColumnsToContents();
126 this->ui->symbolsList->resizeColumnsToContents();
127 }
127 }
128
128
129
129
130
130
131 void elfFileWidget::updateSections()
131 void elfFileWidget::updateSections()
132 {
132 {
133 this->ui->sectionsList->clear();
133 this->ui->sectionsList->clear();
134 this->ui->sectionsList->setRowCount(p_elf->getSectionCount());
134 this->ui->sectionsList->setRowCount(p_elf->getSectionCount());
135 this->ui->sectionsList->setHorizontalHeaderLabels(QStringList()<<"Index"<<"Name"<<"Address"<<"Size"<<"File Size"<<"Type");
135 this->ui->sectionsList->setHorizontalHeaderLabels(QStringList()<<"Index"<<"Name"<<"Address"<<"Size"<<"File Size"<<"Type");
136 for(int i=0;i<p_elf->getSectionCount();i++)
136 for(int i=0;i<p_elf->getSectionCount();i++)
137 {
137 {
138 QTableWidgetItem *newItem = (QTableWidgetItem*) new QTableWidgetIntItem(QString("%1").arg(i),DecimalItem);
138 QTableWidgetItem *newItem = (QTableWidgetItem*) new QTableWidgetIntItem(QString("%1").arg(i),DecimalItem);
139 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
139 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
140 this->ui->sectionsList->setItem(i,0, newItem);
140 this->ui->sectionsList->setItem(i,0, newItem);
141
141
142 newItem = new QTableWidgetItem(p_elf->getSectionName(i));
142 newItem = new QTableWidgetItem(p_elf->getSectionName(i));
143 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
143 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
144 this->ui->sectionsList->setItem(i, 1, newItem);
144 this->ui->sectionsList->setItem(i, 1, newItem);
145
145
146 newItem = (QTableWidgetItem*) new QTableWidgetIntItem(QString("0x%1").arg(p_elf->getSectionPaddr(i),8,16).replace(" ","0"),HexaDecimalItem);
146 newItem = (QTableWidgetItem*) new QTableWidgetIntItem(QString("0x%1").arg(p_elf->getSectionPaddr(i),8,16).replace(" ","0"),HexaDecimalItem);
147 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
147 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
148 this->ui->sectionsList->setItem(i, 2, newItem);
148 this->ui->sectionsList->setItem(i, 2, newItem);
149
149
150 newItem = (QTableWidgetItem*) new QTableWidgetIntItem(QString("%1").arg(p_elf->getSectionMemsz(i)),DecimalItem);
150 newItem = (QTableWidgetItem*) new QTableWidgetIntItem(QString("%1").arg(p_elf->getSectionMemsz(i)),DecimalItem);
151 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
151 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
152 this->ui->sectionsList->setItem(i, 3, newItem);
152 this->ui->sectionsList->setItem(i, 3, newItem);
153
153
154 newItem = (QTableWidgetItem*) new QTableWidgetIntItem(QString("%1").arg(p_elf->getSectionDatasz(i)),DecimalItem);
154 newItem = (QTableWidgetItem*) new QTableWidgetIntItem(QString("%1").arg(p_elf->getSectionDatasz(i)),DecimalItem);
155 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
155 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
156 this->ui->sectionsList->setItem(i, 4, newItem);
156 this->ui->sectionsList->setItem(i, 4, newItem);
157
157
158 newItem = new QTableWidgetItem(p_elf->getSectionType(i));
158 newItem = new QTableWidgetItem(p_elf->getSectionType(i));
159 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
159 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
160 this->ui->sectionsList->setItem(i, 5, newItem);
160 this->ui->sectionsList->setItem(i, 5, newItem);
161 }
161 }
162 this->ui->sectionsList->resizeColumnsToContents();
162 this->ui->sectionsList->resizeColumnsToContents();
163 }
163 }
164
164
165 void elfFileWidget::sectionCellActivated(int row, int column)
165 void elfFileWidget::sectionCellActivated(int row, int column)
166 {
166 {
167 Q_UNUSED(column)
167 Q_UNUSED(column)
168 char* buff=NULL;
168 char* buff=NULL;
169 int sectionIndex = p_elf->getSectionIndex(this->ui->sectionsList->item(row,1)->text());
169 int sectionIndex = p_elf->getSectionIndex(this->ui->sectionsList->item(row,1)->text());
170 if(sectionIndex!=-1)
170 if(sectionIndex!=-1)
171 {
171 {
172 QString type = p_elf->getSectionType(sectionIndex);
172 QString type = p_elf->getSectionType(sectionIndex);
173 if(!p_elf->sectionIsNobits(sectionIndex))
173 if(!p_elf->sectionIsNobits(sectionIndex))
174 {
174 {
175 this->p_elf->getSectionData(sectionIndex,&buff);
175 this->p_elf->getSectionData(sectionIndex,&buff);
176 this->ui->sectionsHexView->setData(QByteArray(buff,this->p_elf->getSectionDatasz(sectionIndex)));
176 this->ui->sectionsHexView->setData(QByteArray(buff,this->p_elf->getSectionDatasz(sectionIndex)));
177 this->ui->sectionsHexView->setAddressOffset(this->p_elf->getSectionPaddr(sectionIndex));
177 this->ui->sectionsHexView->setAddressOffset(this->p_elf->getSectionPaddr(sectionIndex));
178 }
178 }
179 }
179 }
180 }
180 }
181
181
182 void elfFileWidget::exportToSREC()
182 void elfFileWidget::exportToSREC()
183 {
183 {
184 QList<codeFragment *> fragments;
184 QList<codeFragment *> fragments;
185 if(this->ui->tabWidget->currentWidget()==this->ui->symbolsTab)
185 if(this->ui->tabWidget->currentWidget()==this->ui->symbolsTab)
186 {
186 {
187 fragments = getSelectedSymbolsFragments();
187 fragments = getSelectedSymbolsFragments();
188 }
188 }
189 if(this->ui->tabWidget->currentWidget()==this->ui->sectionsTab)
189 if(this->ui->tabWidget->currentWidget()==this->ui->sectionsTab)
190 {
190 {
191 QStringList sectionList=getSelectedSectionsNames();
191 QStringList sectionList=getSelectedSectionsNames();
192 if(sectionList.count()>0)
192 if(sectionList.count()>0)
193 fragments = p_elf->getFragments(sectionList);
193 fragments = p_elf->getFragments(sectionList);
194 }
194 }
195 if(fragments.count()>0)
195 if(fragments.count()>0)
196 {
196 {
197 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
197 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
198 NULL,
198 NULL,
199 tr("SREC Files (*.srec)"));
199 tr("SREC Files (*.srec)"));
200 if(!fileName.isEmpty())
200 if(!fileName.isEmpty())
201 {
201 {
202 srecFile::toSrec(fragments,fileName);
202 srecFile::toSrec(fragments,fileName);
203 }
203 }
204 }
204 }
205
205
206 }
206 }
207
207
208 void elfFileWidget::exportToBIN()
208 void elfFileWidget::exportToBIN()
209 {
209 {
210 QList<codeFragment *> fragments;
210 QList<codeFragment *> fragments;
211 if(this->ui->tabWidget->currentWidget()==this->ui->symbolsTab)
211 if(this->ui->tabWidget->currentWidget()==this->ui->symbolsTab)
212 {
212 {
213 fragments = getSelectedSymbolsFragments();
213 fragments = getSelectedSymbolsFragments();
214 }
214 }
215 if(this->ui->tabWidget->currentWidget()==this->ui->sectionsTab)
215 if(this->ui->tabWidget->currentWidget()==this->ui->sectionsTab)
216 {
216 {
217 QStringList sectionList=getSelectedSectionsNames();
217 QStringList sectionList=getSelectedSectionsNames();
218 if(sectionList.count()>0)
218 if(sectionList.count()>0)
219 fragments = p_elf->getFragments(sectionList);
219 fragments = p_elf->getFragments(sectionList);
220 }
220 }
221 if(fragments.count()>0)
221 if(fragments.count()>0)
222 {
222 {
223 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
223 QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
224 NULL,
224 NULL,
225 tr("Binary Files (*.bin)"));
225 tr("Binary Files (*.bin)"));
226 if(!fileName.isEmpty())
226 if(!fileName.isEmpty())
227 {
227 {
228 binaryFile::toBinary(fragments,fileName);
228 binaryFile::toBinary(fragments,fileName);
229 }
229 }
230 }
230 }
231
231
232 }
232 }
233
233
234 void elfFileWidget::viewSymbolInHexViewer()
234 void elfFileWidget::viewSymbolInHexViewer()
235 {
235 {
236 int row=this->ui->symbolsList->item(this->ui->symbolsList->currentRow(),0)->text().toInt();
236 int row=this->ui->symbolsList->item(this->ui->symbolsList->currentRow(),0)->text().toInt();
237 int section = p_elf->getSectionIndex(p_elf->getSymbolSectionName(row));
237 int section = p_elf->getSectionIndex(p_elf->getSymbolSectionName(row));
238 qint64 address = p_elf->getSymbolAddress(row);
238 if(section!=-1)
239 qint64 secAddress = p_elf->getSectionPaddr(section);
240 qint64 size = p_elf->getSymbolSize(row);
241 char* buff=NULL;
242 char* symBuff=NULL;
243 if(size && !p_elf->sectionIsNobits(section))
244 {
239 {
245 if(section!=-1)
240 qint64 address = p_elf->getSymbolAddress(row);
241 qint64 secAddress = p_elf->getSectionPaddr(section);
242 qint64 size = p_elf->getSymbolSize(row);
243 char* buff=NULL;
244 char* symBuff=NULL;
245 if(size && !p_elf->sectionIsNobits(section))
246 {
246 {
247 symBuff = (char*)malloc(size);
247 if(section!=-1)
248 this->p_elf->getSectionData(section,&buff);
248 {
249 memcpy(symBuff,buff+(address-secAddress),size);
249 symBuff = (char*)malloc(size);
250 this->p_hexviewer->setData(QByteArray(symBuff,size));
250 this->p_elf->getSectionData(section,&buff);
251 this->p_hexviewer->setAddressOffset(address);
251 memcpy(symBuff,buff+(address-secAddress),size);
252 this->p_hexviewer->show();
252 this->p_hexviewer->setData(QByteArray(symBuff,size));
253 this->p_hexviewer->setAddressOffset(address);
254 this->p_hexviewer->show();
255 }
253 }
256 }
254 }
257 }
258
255 }
259 }
256
260
257 void elfFileWidget::filterSymbols(const QString &pattern)
261 void elfFileWidget::filterSymbols(const QString &pattern)
258 {
262 {
259 Qt::MatchFlags flag = Qt::MatchContains | Qt::MatchStartsWith | Qt::MatchEndsWith | Qt::MatchRegExp | Qt::MatchWildcard | Qt::MatchWrap |Qt::MatchRecursive;
263 Qt::MatchFlags flag = Qt::MatchContains | Qt::MatchStartsWith | Qt::MatchEndsWith | Qt::MatchRegExp | Qt::MatchWildcard | Qt::MatchWrap |Qt::MatchRecursive;
260 if(this->ui->caseSensitive->isChecked())
264 if(this->ui->caseSensitive->isChecked())
261 flag |= Qt::MatchCaseSensitive;
265 flag |= Qt::MatchCaseSensitive;
262 if(pattern.isEmpty())
266 if(pattern.isEmpty())
263 {
267 {
264 for(int i=0;i<this->ui->symbolsList->rowCount();i++)
268 for(int i=0;i<this->ui->symbolsList->rowCount();i++)
265 this->ui->symbolsList->setRowHidden(i,false);
269 this->ui->symbolsList->setRowHidden(i,false);
266 }
270 }
267 else
271 else
268 {
272 {
269 for(int i=0;i<this->ui->symbolsList->rowCount();i++)
273 for(int i=0;i<this->ui->symbolsList->rowCount();i++)
270 this->ui->symbolsList->setRowHidden(i,true);
274 this->ui->symbolsList->setRowHidden(i,true);
271 QList<QTableWidgetItem*> items = this->ui->symbolsList->findItems(pattern,flag);
275 QList<QTableWidgetItem*> items = this->ui->symbolsList->findItems(pattern,flag);
272 for(int i=0;i<items.count();i++)
276 for(int i=0;i<items.count();i++)
273 this->ui->symbolsList->setRowHidden(items.at(i)->row(),false);
277 this->ui->symbolsList->setRowHidden(items.at(i)->row(),false);
274 }
278 }
275 }
279 }
276
280
277 void elfFileWidget::filterSymbolsCaseUpdate(bool toggled)
281 void elfFileWidget::filterSymbolsCaseUpdate(bool toggled)
278 {
282 {
279 Q_UNUSED(toggled)
283 Q_UNUSED(toggled)
280 this->filterSymbols(this->ui->symbolsFilter->text());
284 this->filterSymbols(this->ui->symbolsFilter->text());
281 }
285 }
282
286
283 QList<codeFragment *> elfFileWidget::getSelectedSymbolsFragments()
287 QList<codeFragment *> elfFileWidget::getSelectedSymbolsFragments()
284 {
288 {
285 QList<codeFragment *> fragments;
289 QList<codeFragment *> fragments;
286 codeFragment * fragment;
290 codeFragment * fragment;
287 if(p_elf->isopened())
291 if(p_elf->isopened())
288 {
292 {
289 QList<QTableWidgetItem*> items = this->ui->symbolsList->selectedItems();
293 QList<QTableWidgetItem*> items = this->ui->symbolsList->selectedItems();
290 for(int i=0;i<items.count();i++)
294 for(int i=0;i<items.count();i++)
291 {
295 {
292 int row=this->ui->symbolsList->item(items.at(i)->row(),0)->text().toInt();
296 int row=this->ui->symbolsList->item(items.at(i)->row(),0)->text().toInt();
293 int section = p_elf->getSectionIndex(p_elf->getSymbolSectionName(row));
297 int section = p_elf->getSectionIndex(p_elf->getSymbolSectionName(row));
294 qint64 address = p_elf->getSymbolAddress(row);
298 if(section!=-1)
295 qint64 secAddress = p_elf->getSectionPaddr(section);
296 qint64 size = p_elf->getSymbolSize(row);
297 char* buff=NULL;
298 if(size && !p_elf->sectionIsNobits(section))
299 {
299 {
300 if(section!=-1)
300 qint64 address = p_elf->getSymbolAddress(row);
301 qint64 secAddress = p_elf->getSectionPaddr(section);
302 qint64 size = p_elf->getSymbolSize(row);
303 char* buff=NULL;
304 if(size && !p_elf->sectionIsNobits(section))
301 {
305 {
302 fragment= new codeFragment();
306 if(section!=-1)
303 fragment->data = (char*)malloc(size);
307 {
304 fragment->address = address;
308 fragment= new codeFragment();
305 fragment->size = size;
309 fragment->data = (char*)malloc(size);
306 this->p_elf->getSectionData(section,&buff);
310 fragment->address = address;
307 memcpy(fragment->data,buff+(address-secAddress),size);
311 fragment->size = size;
308 fragments.append(fragment);
312 this->p_elf->getSectionData(section,&buff);
313 memcpy(fragment->data,buff+(address-secAddress),size);
314 fragments.append(fragment);
315 }
309 }
316 }
310 }
317 }
318
311 }
319 }
312 }
320 }
313 return fragments;
321 return fragments;
314
322
315 }
323 }
316
324
317
325
318
326
319 QStringList elfFileWidget::getSelectedSectionsNames()
327 QStringList elfFileWidget::getSelectedSectionsNames()
320 {
328 {
321 QStringList sectionList;
329 QStringList sectionList;
322 QList<QTableWidgetItem*> items = this->ui->sectionsList->selectedItems();
330 QList<QTableWidgetItem*> items = this->ui->sectionsList->selectedItems();
323 for(int i=0;i<items.count();i++)
331 for(int i=0;i<items.count();i++)
324 {
332 {
325 QString section = p_elf->getSectionName(items.at(i)->row());
333 QString section = p_elf->getSectionName(items.at(i)->row());
326 if(!sectionList.contains(section))
334 if(!sectionList.contains(section))
327 {
335 {
328 sectionList.append(section);
336 sectionList.append(section);
329 }
337 }
330 }
338 }
331 return sectionList;
339 return sectionList;
332 }
340 }
333
341
334
342
335
343
336
344
337
345
338
346
339
347
340
348
341
349
342
350
343
351
344
352
345
353
346
354
@@ -1,66 +1,66
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef ELFFILEWIDGET_H
22 #ifndef ELFFILEWIDGET_H
23 #define ELFFILEWIDGET_H
23 #define ELFFILEWIDGET_H
24
24
25 #include <QtWidgets/QWidget>
25 #include <QtWidgets/QWidget>
26 #include "elffile.h"
26 #include "elffile.h"
27 #include <QtWidgets/QAction>
27 #include <QtWidgets/QAction>
28 #include <qhexedit.h>
28 #include <qhexedit.h>
29
29
30 namespace Ui {
30 namespace Ui {
31 class elfFileWidget;
31 class elfFileWidget;
32 }
32 }
33
33
34 class elfFileWidget : public abstractBinFileWidget
34 class elfFileWidget : public abstractBinFileWidget
35 {
35 {
36 Q_OBJECT
36 Q_OBJECT
37
37
38 public:
38 public:
39 elfFileWidget(QWidget *parent = 0);
39 explicit elfFileWidget(QWidget *parent = 0);
40 ~elfFileWidget();
40 ~elfFileWidget();
41
41
42 public slots:
42 public slots:
43 void setFile(ElfFile* file);
43 void setFile(abstractBinFile* file);
44 void reloadFile();
44 void reloadFile();
45 void updateSymbols();
45 void updateSymbols();
46 void updateSections();
46 void updateSections();
47
47
48 private slots:
48 private slots:
49 void sectionCellActivated(int row, int column);
49 void sectionCellActivated(int row, int column);
50 void exportToSREC();
50 void exportToSREC();
51 void exportToBIN();
51 void exportToBIN();
52 void viewSymbolInHexViewer();
52 void viewSymbolInHexViewer();
53 void filterSymbols(const QString& pattern);
53 void filterSymbols(const QString& pattern);
54 void filterSymbolsCaseUpdate(bool toggled);
54 void filterSymbolsCaseUpdate(bool toggled);
55 private:
55 private:
56 QList<codeFragment*> getSelectedSymbolsFragments();
56 QList<codeFragment*> getSelectedSymbolsFragments();
57 Ui::elfFileWidget *ui;
57 Ui::elfFileWidget *ui;
58 QStringList getSelectedSectionsNames();
58 QStringList getSelectedSectionsNames();
59 ElfFile* p_elf;
59 ElfFile* p_elf;
60 QAction* exportToSREC_action;
60 QAction* exportToSREC_action;
61 QAction* exportToBIN_action;
61 QAction* exportToBIN_action;
62 QAction* viewSymbolInHexViewer_action;
62 QAction* viewSymbolInHexViewer_action;
63 QHexEdit* p_hexviewer;
63 QHexEdit* p_hexviewer;
64 };
64 };
65
65
66 #endif // ELFFILEWIDGET_H
66 #endif // ELFFILEWIDGET_H
@@ -1,62 +1,185
1 #include "genericbinaryfilewidget.h"
1 #include "genericbinaryfilewidget.h"
2 #include "ui_genericbinaryfilewidget.h"
2 #include "ui_genericbinaryfilewidget.h"
3 #include <QFileDialog>
3 #include <QFileDialog>
4 #include <QFile>
4 #include <QFile>
5 #include "srec/srecfile.h"
5 #include "srec/srecfile.h"
6 #include "srec/srecfilewidget.h"
7 #include "BinFile/binaryfile.h"
8 #include "BinFile/binaryfilewidget.h"
9 #include "elf/elffile.h"
10 #include "elf/elffilewidget.h"
11
6
12
7 genericBinaryFileWidget::genericBinaryFileWidget(QWidget *parent) :
13 genericBinaryFileWidget::genericBinaryFileWidget(QWidget *parent) :
8 QWidget(parent),
14 QWidget(parent),
9 ui(new Ui::genericBinaryFileWidget)
15 ui(new Ui::genericBinaryFileWidget)
10 {
16 {
11 ui->setupUi(this);
17 ui->setupUi(this);
18 connect(this->ui->openFileQpb,SIGNAL(clicked()),this,SLOT(openFile()));
19 connect(this->ui->removeFileQpb,SIGNAL(clicked()),this,SLOT(removeFiles()));
20 connect(this->ui->fileList,SIGNAL(cellActivated(int,int)),this,SLOT(fileCellActivated(int,int)));
12 }
21 }
13
22
14 genericBinaryFileWidget::~genericBinaryFileWidget()
23 genericBinaryFileWidget::~genericBinaryFileWidget()
15 {
24 {
16 delete ui;
25 delete ui;
17 }
26 }
18
27
19 void genericBinaryFileWidget::openFile()
28 void genericBinaryFileWidget::openFile()
20 {
29 {
21 QStringList filesNames = QFileDialog::getOpenFileNames(
30 QStringList filesNames = QFileDialog::getOpenFileNames(
22 this,
31 this,
23 "Select one or more files to open",
32 "Select one or more files to open",
24 NULL,
33 NULL,
25 "Binary Files (*.bin);;SREC Files (*.srec);;Elf Files (*)");
34 "Binary Files (*.bin);;SREC Files (*.srec);;Elf Files (*)");
26
35
27 for(int i=0;i<filesNames.count();i++)
36 for(int i=0;i<filesNames.count();i++)
28 {
37 {
38 bool fileOpened = false;
39 for(int l=0;l<files.count();l++)
40 {
41 if(filesNames.at(i)==files.at(l)->fileName)
42 {
43 fileOpened = true;
44 }
45 }
29 QFile file(filesNames.at(i));
46 QFile file(filesNames.at(i));
30 if(file.open(QIODevice::ReadOnly))
47 if(!fileOpened && file.open(QIODevice::ReadOnly))
31 {
48 {
32 char magic[4];
49 char magic[4];
33 file.read(magic,4);
50 file.read(magic,4);
34 QString line;
51 QString line;
35 switch((int)magic[0])
52 switch((int)magic[0])
36 {
53 {
37 case 'e':
54 case 0x7F:
38 if((magic[1]=='l') && (magic[2]=='f'))
55 if((magic[1]=='E') && (magic[2]=='L') && (magic[3]=='F'))
39 {
56 {
40 files.append(new FileListElement(filesNames.at(i),false,Type_Elf,NULL));
57 files.append(new FileListElement(filesNames.at(i),false,Type_Elf,NULL,NULL));
41 }
58 }
42 break;
59 break;
43 case 'S':
60 case 'S':
44 file.seek(0);
61 file.seek(0);
45 line = file.readLine();
62 line = file.readLine();
46 if(srecFile::checkSum(line))
63 if(srecFile::checkSum(line))
47 {
64 {
48 files.append(new FileListElement(filesNames.at(i),false,Type_SREC,NULL));
65 files.append(new FileListElement(filesNames.at(i),false,Type_SREC,NULL,NULL));
49 }
66 }
50 break;
67 break;
51 default:
68 default:
52 files.append(new FileListElement(filesNames.at(i),false,Type_Bin,NULL));
69 files.append(new FileListElement(filesNames.at(i),false,Type_Bin,NULL,NULL));
53 break;
70 break;
54 }
71 }
55 }
72 }
56 }
73 }
74 updateFileList();
57
75
58 }
76 }
59
77
78 void genericBinaryFileWidget::updateFileList()
79 {
80 this->ui->fileList->clear();
81 this->ui->fileList->setRowCount(files.count());
82 this->ui->fileList->setHorizontalHeaderLabels(QStringList()<<"File"<<"Type");
83 for(int i=0;i<files.count();i++)
84 {
85 QTableWidgetItem *newItem = new QTableWidgetItem(files.at(i)->fileName);
86 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
87 this->ui->fileList->setItem(i, 0, newItem);
88
89 newItem = new QTableWidgetItem(files.at(i)->type());
90 newItem->setFlags(newItem->flags() ^ Qt::ItemIsEditable);
91 this->ui->fileList->setItem(i, 1, newItem);
92 }
93 this->ui->fileList->resizeColumnsToContents();
94 }
95
96 void genericBinaryFileWidget::removeFiles()
97 {
98 QList<QTableWidgetItem*> items = this->ui->fileList->selectedItems();
99 for(int i=0;i<items.count();i++)
100 {
101 QString filename = this->ui->fileList->item(items.at(i)->row(),0)->text();
102 for(int l=0;l<files.count();l++)
103 {
104 if(files.at(l)->fileName==filename)
105 {
106 if(files.at(l)->isOpened)
107 {
108 for(int m=0;m<this->ui->fileViewerTab->count();m++)
109 {
110 if(this->ui->fileViewerTab->widget(m)==this->files.at(l)->viewer)
111 {
112 this->ui->fileViewerTab->removeTab(m);
113 }
114 }
115 delete this->files.at(l)->viewer;
116 delete this->files.at(l)->parser;
117 }
118 delete files.at(l);
119 files.removeAt(l);
120 }
121 }
122 }
123 updateFileList();
124 }
125
126 void genericBinaryFileWidget::fileCellActivated(int row, int column)
127 {
128 Q_UNUSED(column)
129 QString fileName = this->ui->fileList->item(row,0)->text();
130 if(fileName!="")
131 {
132 for(int l=0;l<files.count();l++)
133 {
134 FileListElement* file = files.at(l);
135 if(file->fileName==fileName)
136 {
137 if(!file->isOpened)
138 {
139 if(file->parser==NULL)
140 {
141 switch (file->FileType)
142 {
143 case Type_Bin:
144 file->parser = new binaryFile(file->fileName);
145 if(file->viewer==NULL)
146 {
147 file->viewer = new binaryFileWidget();
148 file->viewer->setFile(file->parser);
149 this->ui->fileViewerTab->addTab(file->viewer,file->fileName);
150 }
151 file->isOpened = true;
152 break;
153 case Type_Elf:
154 file->parser = new ElfFile(file->fileName);
155 if(file->viewer==NULL)
156 {
157 file->viewer = new elfFileWidget();
158 file->viewer->setFile(file->parser);
159 this->ui->fileViewerTab->addTab(file->viewer,file->fileName);
160 }
161 file->isOpened = true;
162 break;
163 case Type_SREC:
164 file->parser = new srecFile(file->fileName);
165 if(file->viewer==NULL)
166 {
167 file->viewer = new srecFileWidget();
168 file->viewer->setFile(file->parser);
169 this->ui->fileViewerTab->addTab(file->viewer,file->fileName);
170 }
171 file->isOpened = true;
172 break;
173 default:
174 break;
175 }
176 }
177 }
178 }
179 }
180 }
181 }
182
60
183
61
184
62
185
@@ -1,42 +1,63
1 #ifndef GENERICBINARYFILEWIDGET_H
1 #ifndef GENERICBINARYFILEWIDGET_H
2 #define GENERICBINARYFILEWIDGET_H
2 #define GENERICBINARYFILEWIDGET_H
3
3
4 #include <QWidget>
4 #include <QWidget>
5 #include <QString>
5 #include <QString>
6 #include <QStringList>
6 #include <QStringList>
7 #include <abstractbinfile.h>
7 #include <abstractbinfile.h>
8
8
9 namespace Ui {
9 namespace Ui {
10 class genericBinaryFileWidget;
10 class genericBinaryFileWidget;
11 }
11 }
12
12
13 typedef enum {Type_SREC,Type_Bin,Type_Elf}FileTypeEnum;
13 typedef enum {Type_SREC,Type_Bin,Type_Elf}FileTypeEnum;
14 class FileListElement
14 class FileListElement
15 {
15 {
16 public:
16 public:
17 FileListElement() {}
17 FileListElement() {}
18 FileListElement(QString fileName,bool isOpened,FileTypeEnum FileType,abstractBinFileWidget* viewer)
18 FileListElement(QString fileName,bool isOpened,FileTypeEnum FileType,abstractBinFileWidget* viewer=0,abstractBinFile* parser=0)
19 :fileName(fileName),isOpened(isOpened),FileType(FileType),viewer(viewer){}
19 :fileName(fileName),isOpened(isOpened),FileType(FileType),viewer(viewer),parser(parser){}
20 QString type()
21 {
22 switch (this->FileType) {
23 case Type_SREC:
24 return "Srec";
25 break;
26 case Type_Bin:
27 return "Binary";
28 break;
29 case Type_Elf:
30 return "Elf";
31 break;
32 default:
33 return "Unknow";
34 break;
35 }
36 }
20 QString fileName;
37 QString fileName;
21 bool isOpened;
38 bool isOpened;
22 FileTypeEnum FileType;
39 FileTypeEnum FileType;
23 abstractBinFileWidget* viewer;
40 abstractBinFileWidget* viewer;
41 abstractBinFile* parser;
24 };
42 };
25
43
26 class genericBinaryFileWidget : public QWidget
44 class genericBinaryFileWidget : public QWidget
27 {
45 {
28 Q_OBJECT
46 Q_OBJECT
29
47
30 public:
48 public:
31 explicit genericBinaryFileWidget(QWidget *parent = 0);
49 explicit genericBinaryFileWidget(QWidget *parent = 0);
32 ~genericBinaryFileWidget();
50 ~genericBinaryFileWidget();
33
51
34 public slots:
52 public slots:
35 void openFile();
53 void openFile();
54 void updateFileList();
55 void removeFiles();
56 void fileCellActivated(int row, int column);
36
57
37 private:
58 private:
38 Ui::genericBinaryFileWidget *ui;
59 Ui::genericBinaryFileWidget *ui;
39 QList<FileListElement*> files;
60 QList<FileListElement*> files;
40 };
61 };
41
62
42 #endif // GENERICBINARYFILEWIDGET_H
63 #endif // GENERICBINARYFILEWIDGET_H
@@ -1,103 +1,103
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
2 <ui version="4.0">
3 <class>genericBinaryFileWidget</class>
3 <class>genericBinaryFileWidget</class>
4 <widget class="QWidget" name="genericBinaryFileWidget">
4 <widget class="QWidget" name="genericBinaryFileWidget">
5 <property name="geometry">
5 <property name="geometry">
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>878</width>
9 <width>878</width>
10 <height>360</height>
10 <height>360</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="acceptDrops">
13 <property name="acceptDrops">
14 <bool>false</bool>
14 <bool>false</bool>
15 </property>
15 </property>
16 <property name="windowTitle">
16 <property name="windowTitle">
17 <string>Form</string>
17 <string>Form</string>
18 </property>
18 </property>
19 <layout class="QGridLayout" name="gridLayout_2">
19 <layout class="QGridLayout" name="gridLayout_2">
20 <item row="0" column="0">
20 <item row="0" column="0">
21 <widget class="QSplitter" name="splitter">
21 <widget class="QSplitter" name="splitter">
22 <property name="orientation">
22 <property name="orientation">
23 <enum>Qt::Horizontal</enum>
23 <enum>Qt::Horizontal</enum>
24 </property>
24 </property>
25 <widget class="QWidget" name="widget" native="true">
25 <widget class="QWidget" name="widget" native="true">
26 <layout class="QGridLayout" name="gridLayout">
26 <layout class="QGridLayout" name="gridLayout">
27 <item row="1" column="0">
27 <item row="1" column="0">
28 <widget class="QPushButton" name="openFileQpb">
28 <widget class="QPushButton" name="openFileQpb">
29 <property name="text">
29 <property name="text">
30 <string/>
30 <string/>
31 </property>
31 </property>
32 <property name="icon">
32 <property name="icon">
33 <iconset resource="../SocExplorerCommon.qrc">
33 <iconset resource="genericBinaryFiles.qrc">
34 <normaloff>:/images/add.svg</normaloff>:/images/add.svg</iconset>
34 <normaloff>:/img/ressources/Gnome-list-add.svg</normaloff>:/img/ressources/Gnome-list-add.svg</iconset>
35 </property>
35 </property>
36 <property name="iconSize">
36 <property name="iconSize">
37 <size>
37 <size>
38 <width>32</width>
38 <width>32</width>
39 <height>32</height>
39 <height>32</height>
40 </size>
40 </size>
41 </property>
41 </property>
42 </widget>
42 </widget>
43 </item>
43 </item>
44 <item row="1" column="1">
44 <item row="1" column="1">
45 <widget class="QPushButton" name="removeFileQpb">
45 <widget class="QPushButton" name="removeFileQpb">
46 <property name="text">
46 <property name="text">
47 <string/>
47 <string/>
48 </property>
48 </property>
49 <property name="icon">
49 <property name="icon">
50 <iconset resource="../SocExplorerCommon.qrc">
50 <iconset resource="genericBinaryFiles.qrc">
51 <normaloff>:/images/trash.svg</normaloff>:/images/trash.svg</iconset>
51 <normaloff>:/img/ressources/Gnome-user-trash.svg</normaloff>:/img/ressources/Gnome-user-trash.svg</iconset>
52 </property>
52 </property>
53 <property name="iconSize">
53 <property name="iconSize">
54 <size>
54 <size>
55 <width>32</width>
55 <width>32</width>
56 <height>32</height>
56 <height>32</height>
57 </size>
57 </size>
58 </property>
58 </property>
59 </widget>
59 </widget>
60 </item>
60 </item>
61 <item row="1" column="2">
61 <item row="1" column="2">
62 <spacer name="horizontalSpacer">
62 <spacer name="horizontalSpacer">
63 <property name="orientation">
63 <property name="orientation">
64 <enum>Qt::Horizontal</enum>
64 <enum>Qt::Horizontal</enum>
65 </property>
65 </property>
66 <property name="sizeHint" stdset="0">
66 <property name="sizeHint" stdset="0">
67 <size>
67 <size>
68 <width>40</width>
68 <width>40</width>
69 <height>20</height>
69 <height>20</height>
70 </size>
70 </size>
71 </property>
71 </property>
72 </spacer>
72 </spacer>
73 </item>
73 </item>
74 <item row="0" column="0" colspan="3">
74 <item row="0" column="0" colspan="3">
75 <widget class="QTableWidget" name="tableWidget">
75 <widget class="QTableWidget" name="fileList">
76 <column>
76 <column>
77 <property name="text">
77 <property name="text">
78 <string>File</string>
78 <string>File</string>
79 </property>
79 </property>
80 </column>
80 </column>
81 <column>
81 <column>
82 <property name="text">
82 <property name="text">
83 <string>Type</string>
83 <string>Type</string>
84 </property>
84 </property>
85 </column>
85 </column>
86 </widget>
86 </widget>
87 </item>
87 </item>
88 </layout>
88 </layout>
89 </widget>
89 </widget>
90 <widget class="QTabWidget" name="fileViewerTab">
90 <widget class="QTabWidget" name="fileViewerTab">
91 <property name="currentIndex">
91 <property name="currentIndex">
92 <number>-1</number>
92 <number>-1</number>
93 </property>
93 </property>
94 </widget>
94 </widget>
95 </widget>
95 </widget>
96 </item>
96 </item>
97 </layout>
97 </layout>
98 </widget>
98 </widget>
99 <resources>
99 <resources>
100 <include location="../SocExplorerCommon.qrc"/>
100 <include location="genericBinaryFiles.qrc"/>
101 </resources>
101 </resources>
102 <connections/>
102 <connections/>
103 </ui>
103 </ui>
General Comments 0
You need to be logged in to leave comments. Login now