Skip to content

Commit ff2bd6a

Browse files
committed
Bugfixes and enhaced search feature with n/p navigation keys
1 parent 54005c0 commit ff2bd6a

File tree

8 files changed

+189
-17
lines changed

8 files changed

+189
-17
lines changed

INSTALL

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Installation Instructions
22
*************************
33

4-
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
5-
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4+
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
5+
Inc.
66

77
Copying and distribution of this file, with or without modification,
88
are permitted in any medium without royalty provided the copyright
@@ -12,8 +12,8 @@ without warranty of any kind.
1212
Basic Installation
1313
==================
1414

15-
Briefly, the shell commands `./configure; make; make install' should
16-
configure, build, and install this package. The following
15+
Briefly, the shell command `./configure && make && make install'
16+
should configure, build, and install this package. The following
1717
more-detailed instructions are generic; see the `README' file for
1818
instructions specific to this package. Some packages provide this
1919
`INSTALL' file but do not implement all of the features documented
@@ -226,6 +226,11 @@ order to use an ANSI C compiler:
226226

227227
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
228228

229+
HP-UX `make' updates targets which have the same time stamps as
230+
their prerequisites, which makes it generally unusable when shipped
231+
generated files such as `configure' are involved. Use GNU `make'
232+
instead.
233+
229234
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
230235
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
231236
a workaround. If GNU CC is not installed, it is therefore recommended
@@ -304,9 +309,10 @@ causes the specified `gcc' to be used as the C compiler (unless it is
304309
overridden in the site shell script).
305310

306311
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
307-
an Autoconf bug. Until the bug is fixed you can use this workaround:
312+
an Autoconf limitation. Until the limitation is lifted, you can use
313+
this workaround:
308314

309-
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
315+
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
310316

311317
`configure' Invocation
312318
======================
@@ -362,4 +368,3 @@ operates.
362368

363369
`configure' also accepts some other, not widely useful, options. Run
364370
`configure --help' for more details.
365-

simtk/bitview.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ simtk_bitview_mark_region_noflip (const struct simtk_widget *widget,
143143
}
144144

145145
int
146-
simtk_bitview_mark_region (const struct simtk_widget *widget,
146+
simtk_bitview_mark_region (struct simtk_widget *widget,
147147
const char *name,
148148
uint64_t start,
149149
uint64_t length,
@@ -279,7 +279,6 @@ simtk_bitview_render_bits_noflip (struct simtk_widget *widget)
279279

280280
if (region != NULL)
281281
{
282-
283282
bgcolor = region->bgcolor;
284283

285284
paint = offset + p >= region->start && offset + p < region->start + region->length;

simtk/bitview.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ struct simtk_bitview_properties *simtk_bitview_properties_new (int, int, const v
7272
void simtk_bitview_properties_lock (const struct simtk_bitview_properties *);
7373
void simtk_bitview_properties_unlock (const struct simtk_bitview_properties *);
7474
void simtk_bitview_properties_destroy (struct simtk_bitview_properties *);
75+
void simtk_bitview_clear_regions (const struct simtk_widget *);
7576
int simtk_bitview_mark_region_noflip (const struct simtk_widget *,
7677
const char *,
7778
uint64_t,
7879
uint64_t,
7980
uint32_t,
8081
uint32_t);
81-
int simtk_bitview_mark_region (const struct simtk_widget *,
82+
int simtk_bitview_mark_region (struct simtk_widget *,
8283
const char *,
8384
uint64_t,
8485
uint64_t,

src/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ vix_LDFLAGS = @GLOBAL_LDFLAGS@
77

88
vix_LDADD = ../sim-static/libsim.la ../simtk/libsimtk.la ../util/libutil.la scripting/libscripting.la @GLOBAL_LDFLAGS@ @GUILE_LIBS@
99

10-
vix_SOURCES = console.c console.h main.c map.c map.h hexview.c hexview.h vix.h
10+
vix_SOURCES = console.c console.h main.c map.c region.c region.h map.h hexview.c hexview.h vix.h

src/hexview.c

+109-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <vix.h>
22
#include <simtk/simtk.h>
3+
#include <region.h>
34
#include "hexview.h"
45

56
struct simtk_hexview_properties *
@@ -17,6 +18,14 @@ simtk_hexview_properties_new (uint32_t vaddr, const void *base, uint32_t size)
1718
return NULL;
1819
}
1920

21+
if ((new->regions = file_region_tree_new ()) == NULL)
22+
{
23+
SDL_DestroyMutex (new->lock);
24+
free (new);
25+
26+
return NULL;
27+
}
28+
2029
new->map = base;
2130
new->map_size = size;
2231

@@ -40,6 +49,8 @@ simtk_hexview_properties_destroy (struct simtk_hexview_properties *prop)
4049
{
4150
SDL_DestroyMutex (prop->lock);
4251

52+
rbtree_destroy (prop->regions);
53+
4354
free (prop);
4455
}
4556

@@ -80,6 +91,61 @@ simtk_hexview_set_opaque (struct simtk_widget *widget, void *opaque)
8091
simtk_hexview_properties_unlock (prop);
8192
}
8293

94+
void
95+
simtk_hexview_clear_regions (const struct simtk_widget *widget)
96+
{
97+
struct simtk_hexview_properties *prop;
98+
99+
prop = simtk_hexview_get_properties (widget);
100+
101+
simtk_hexview_properties_lock (prop);
102+
103+
rbtree_clear (prop->regions);
104+
105+
simtk_hexview_properties_unlock (prop);
106+
}
107+
108+
int
109+
simtk_hexview_mark_region_noflip (const struct simtk_widget *widget,
110+
const char *name,
111+
uint64_t start,
112+
uint64_t length,
113+
uint32_t fgcolor,
114+
uint32_t bgcolor)
115+
{
116+
struct simtk_hexview_properties *prop;
117+
118+
int result;
119+
120+
prop = simtk_hexview_get_properties (widget);
121+
122+
simtk_hexview_properties_lock (prop);
123+
124+
result = file_region_register (prop->regions, name, start, length, fgcolor, bgcolor);
125+
126+
simtk_hexview_properties_unlock (prop);
127+
128+
return result;
129+
}
130+
131+
int
132+
simtk_hexview_mark_region (struct simtk_widget *widget,
133+
const char *name,
134+
uint64_t start,
135+
uint64_t length,
136+
uint32_t fgcolor,
137+
uint32_t bgcolor)
138+
139+
{
140+
int result;
141+
142+
result = simtk_hexview_mark_region_noflip (widget, name, start, length, fgcolor, bgcolor);
143+
144+
simtk_widget_switch_buffers (widget);
145+
146+
return result;
147+
}
148+
83149
#define HEX_MINIMAL 0x80
84150
#define ASCII_MINIMAL 0x80
85151

@@ -88,6 +154,11 @@ simtk_hexview_render_noflip (struct simtk_widget *widget)
88154
{
89155
struct simtk_hexview_properties *hprop;
90156
struct simtk_textview_properties *prop;
157+
struct file_region *region;
158+
159+
uint32_t hex_bgcolor, hex_fgcolor;
160+
uint32_t asc_bgcolor, asc_fgcolor;
161+
uint32_t offset;
91162

92163
unsigned int i;
93164
const void *addr;
@@ -97,6 +168,7 @@ simtk_hexview_render_noflip (struct simtk_widget *widget)
97168
uint8_t byte;
98169
uint32_t vaddr;
99170
unsigned int maxcols = 16;
171+
struct rbtree_node *node;
100172

101173
hprop = simtk_hexview_get_properties (widget);
102174
prop = simtk_textview_get_properties (widget);
@@ -105,6 +177,13 @@ simtk_hexview_render_noflip (struct simtk_widget *widget)
105177

106178
vaddr = hprop->vaddr + hprop->start;
107179
addr = hprop->map + hprop->start;
180+
181+
if ((node = file_region_find (hprop->regions, hprop->start)) != NULL)
182+
region = (struct file_region *) rbtree_node_data (node);
183+
else
184+
region = NULL;
185+
186+
offset = hprop->start;
108187

109188
for (i = hprop->start; i < hprop->map_size; ++i)
110189
{
@@ -121,13 +200,41 @@ simtk_hexview_render_noflip (struct simtk_widget *widget)
121200
simtk_textview_set_text (widget, 0, common_y, OPAQUE (0xff0000), 0x80000000, buffer, 10);
122201
}
123202

203+
if (region != NULL)
204+
if (offset >= region->start + region->length)
205+
{
206+
if ((node = rbtree_node_next (node)) != NULL)
207+
region = (struct file_region *) rbtree_node_data (node);
208+
else
209+
region = NULL;
210+
}
211+
124212
sprintf (buffer, "%02x ", byte = *((uint8_t *) addr));
213+
214+
if (region != NULL && offset >= region->start && offset < region->start + region->length)
215+
{
216+
hex_fgcolor = region->fgcolor;
217+
asc_fgcolor = region->fgcolor;
125218

126-
simtk_textview_set_text (widget, 3 * this_x + 10 , common_y, OPAQUE (RGB ((byte + HEX_MINIMAL) * 0xff / (0xff + HEX_MINIMAL), (byte + HEX_MINIMAL) * 0xa5 / (0xff + HEX_MINIMAL), 0)), 0x80000000, buffer, 3);
127-
simtk_textview_set_text (widget, 10 + 3 * maxcols + this_x, common_y, OPAQUE (RGB (0, (byte + ASCII_MINIMAL) * 0xff / (0xff + HEX_MINIMAL), 0)), 0x80000000, addr++, 1);
219+
hex_bgcolor = region->bgcolor;
220+
asc_bgcolor = region->bgcolor;
221+
}
222+
else
223+
{
224+
hex_fgcolor = OPAQUE (RGB ((byte + HEX_MINIMAL) * 0xff / (0xff + HEX_MINIMAL), (byte + HEX_MINIMAL) * 0xa5 / (0xff + HEX_MINIMAL), 0));
225+
hex_bgcolor = 0x80000000;
226+
227+
asc_fgcolor = OPAQUE (RGB (0, (byte + ASCII_MINIMAL) * 0xff / (0xff + HEX_MINIMAL), 0));
228+
asc_bgcolor = 0x80000000;
229+
}
230+
231+
simtk_textview_set_text (widget, 3 * this_x + 10 , common_y, hex_fgcolor, hex_bgcolor, buffer, 3);
232+
233+
simtk_textview_set_text (widget, 10 + 3 * maxcols + this_x, common_y, asc_fgcolor, asc_bgcolor, addr++, 1);
128234

129235
++this_x;
130236
++vaddr;
237+
++offset;
131238
}
132239

133240
simtk_hexview_properties_unlock (hprop);

src/hexview.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <unistd.h>
55
#include <fcntl.h>
66
#include <sys/types.h>
7+
#include <rbtree.h>
78

89
struct simtk_hexview_properties
910
{
@@ -18,7 +19,8 @@ struct simtk_hexview_properties
1819
const void *map;
1920
const uint8_t *bytes;
2021
};
21-
22+
23+
rbtree_t *regions;
2224
void *opaque;
2325
};
2426

@@ -29,6 +31,20 @@ void simtk_heview_properties_destroy (struct simtk_hexview_properties *);
2931

3032
struct simtk_hexview_properties *simtk_hexview_get_properties (const struct simtk_widget *);
3133

34+
void simtk_hexview_clear_regions (const struct simtk_widget *);
35+
int simtk_hexview_mark_region_noflip (const struct simtk_widget *,
36+
const char *,
37+
uint64_t,
38+
uint64_t,
39+
uint32_t,
40+
uint32_t);
41+
int simtk_hexview_mark_region (struct simtk_widget *,
42+
const char *,
43+
uint64_t,
44+
uint64_t,
45+
uint32_t,
46+
uint32_t);
47+
3248
void *simtk_hexview_get_opaque (const struct simtk_widget *);
3349
void simtk_hexview_set_opaque (struct simtk_widget *, void *);
3450
void simtk_hexview_render (struct simtk_widget *);

0 commit comments

Comments
 (0)