2020-03-31 11:48:38 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <types.h>
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "ruamoko/qwaq/debugger/views/defview.h"
|
|
|
|
#include "ruamoko/qwaq/debugger/views/nameview.h"
|
|
|
|
#include "ruamoko/qwaq/debugger/localsdata.h"
|
|
|
|
#include "ruamoko/qwaq/debugger/typeencodings.h"
|
2020-03-31 11:48:38 +00:00
|
|
|
|
|
|
|
@implementation LocalsData
|
|
|
|
|
|
|
|
-initWithTarget:(qdb_target_t) target
|
|
|
|
{
|
|
|
|
if (!(self = [super init])) {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
self.target = target;
|
|
|
|
|
|
|
|
qdb_def_t encodings_def = qdb_find_global (target, ".type_encodings");
|
|
|
|
qdb_get_data (target, encodings_def.offset, sizeof(target_encodings),
|
|
|
|
&target_encodings);
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
+(LocalsData *)withTarget:(qdb_target_t)target
|
|
|
|
{
|
|
|
|
return [[[self alloc] initWithTarget:target] autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)dealloc
|
|
|
|
{
|
|
|
|
if (defs) {
|
|
|
|
obj_free (defs);
|
|
|
|
defs = nil;
|
|
|
|
}
|
|
|
|
if (data) {
|
|
|
|
obj_free (data);
|
|
|
|
data = nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-setFunction:(unsigned) fnum
|
|
|
|
{
|
|
|
|
if (current_fnum == fnum) {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
current_fnum =fnum;
|
|
|
|
|
|
|
|
if (defs) {
|
|
|
|
obj_free (defs);
|
|
|
|
defs = nil;
|
|
|
|
}
|
|
|
|
if (data) {
|
|
|
|
obj_free (data);
|
|
|
|
data = nil;
|
|
|
|
}
|
|
|
|
func = qdb_get_function (target, fnum);
|
|
|
|
aux_func = qdb_get_auxfunction (target, fnum);
|
|
|
|
if (aux_func) {
|
|
|
|
defs = qdb_get_local_defs (target, fnum);
|
|
|
|
}
|
2020-04-01 15:51:22 +00:00
|
|
|
if (func && func.local_size) {
|
2020-03-31 11:48:38 +00:00
|
|
|
data = obj_malloc (func.local_size);
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2020-03-31 14:23:18 +00:00
|
|
|
-fetchData
|
|
|
|
{
|
2020-04-02 10:31:11 +00:00
|
|
|
if (data && func.local_size && func.local_data) {
|
|
|
|
qdb_get_data (target, func.local_data, func.local_size, data);
|
|
|
|
}
|
2020-03-31 14:23:18 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2020-03-31 11:48:38 +00:00
|
|
|
-(int)numberOfRows:(TableView *)tableview
|
|
|
|
{
|
|
|
|
if (aux_func) {
|
|
|
|
return aux_func.num_locals;
|
|
|
|
} else if (func) {
|
|
|
|
return (func.local_size + 3) / 4;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(View *)tableView:(TableView *)tableview
|
|
|
|
forColumn:(TableViewColumn *)column
|
|
|
|
row:(int)row
|
|
|
|
{
|
|
|
|
View *view;
|
|
|
|
|
|
|
|
if ([column name] == "name") {
|
|
|
|
view = [NameView withName:qdb_get_string (target, defs[row].name)];
|
|
|
|
} else {
|
2020-03-31 14:23:18 +00:00
|
|
|
qfot_type_t *type = [TypeEncodings getType:defs[row].type_encoding
|
|
|
|
fromTarget:target];
|
2020-03-31 11:48:38 +00:00
|
|
|
unsigned offset = defs[row].offset;
|
2020-03-31 15:03:53 +00:00
|
|
|
view = [DefView withType:type at:offset in:data target:target];
|
2020-03-31 11:48:38 +00:00
|
|
|
}
|
|
|
|
[view resizeTo:{[column width], 1}];
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|