2020-03-31 11:48:38 +00:00
|
|
|
#include <string.h>
|
2021-06-04 04:35:53 +00:00
|
|
|
#include "ruamoko/qwaq/debugger/typeencodings.h"
|
|
|
|
#include "ruamoko/qwaq/debugger/views/nameview.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "ruamoko/qwaq/debugger/views/pointerview.h"
|
2021-06-04 04:35:53 +00:00
|
|
|
#include "ruamoko/qwaq/ui/tableview.h"
|
2020-03-31 11:48:38 +00:00
|
|
|
|
|
|
|
@implementation PointerView
|
|
|
|
|
2021-06-01 14:52:04 +00:00
|
|
|
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
2020-03-31 11:48:38 +00:00
|
|
|
{
|
2021-06-04 04:35:53 +00:00
|
|
|
if (!(self = [super initWithDef:def type:type])) {
|
2020-03-31 11:48:38 +00:00
|
|
|
return nil;
|
|
|
|
}
|
2021-06-01 14:52:04 +00:00
|
|
|
self.data = (unsigned *)(data + def.offset);
|
2020-03-31 11:48:38 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2021-06-01 14:52:04 +00:00
|
|
|
+(PointerView *)withDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
2020-03-31 11:48:38 +00:00
|
|
|
{
|
2021-06-01 14:52:04 +00:00
|
|
|
return [[[self alloc] initWithDef:def in:data type:type] autorelease];
|
2020-03-31 11:48:38 +00:00
|
|
|
}
|
|
|
|
|
2021-06-04 04:35:53 +00:00
|
|
|
-(void)dealloc
|
|
|
|
{
|
|
|
|
if (ptr_data) {
|
|
|
|
obj_free (ptr_data);
|
|
|
|
}
|
|
|
|
[ptr_view release];
|
2021-09-26 01:07:34 +00:00
|
|
|
[super dealloc];
|
2021-06-04 04:35:53 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 11:48:38 +00:00
|
|
|
-draw
|
|
|
|
{
|
|
|
|
[super draw];
|
2021-06-04 04:35:53 +00:00
|
|
|
string val = sprintf ("%s [0x%x]", type.encoding, data[0]);
|
2020-04-01 10:57:24 +00:00
|
|
|
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
2020-03-31 11:48:38 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2021-06-04 04:35:53 +00:00
|
|
|
-fetchData
|
|
|
|
{
|
|
|
|
if (!ptr_type) {
|
|
|
|
qdb_def_t def = { 0, 0, 0, (unsigned)type.fldptr.aux_type };
|
|
|
|
ptr_type = type.fldptr.aux_type;
|
|
|
|
ptr_size = [TypeEncodings typeSize:ptr_type];
|
|
|
|
ptr_data = obj_malloc (ptr_size);
|
|
|
|
ptr_view = [[DefView withDef:def
|
|
|
|
type:ptr_type
|
|
|
|
in:ptr_data
|
|
|
|
target:target] retain];
|
|
|
|
}
|
|
|
|
invalid = 1;
|
|
|
|
if (!ptr_view || ptr != (unsigned) data[0]) {
|
|
|
|
invalid = qdb_get_data (target, data[0], ptr_size, ptr_data) < 0;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(int) rows
|
|
|
|
{
|
|
|
|
if (invalid) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
return 1 + [ptr_view rows];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(View *) viewAtRow:(int) row forColumn:(TableViewColumn *)column
|
|
|
|
{
|
|
|
|
if (row == 0) {
|
|
|
|
if ([column name] == "name") {
|
|
|
|
return [NameView withName:qdb_get_string (target, def.name)];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
if (invalid) {
|
|
|
|
if ([column name] == "name") {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
return [NameView withName:"Invalid pointer"];
|
|
|
|
}
|
|
|
|
return [ptr_view viewAtRow:row - 1 forColumn:column];
|
|
|
|
}
|
|
|
|
|
2020-03-31 11:48:38 +00:00
|
|
|
@end
|