mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 18:01:15 +00:00
[qwaq] Show dereferenced data for poitner defs
The code currently assumes a single value is referenced rather than the beginning of an array.
This commit is contained in:
parent
22b9bb29f6
commit
f50d27ec11
18 changed files with 121 additions and 33 deletions
|
@ -231,8 +231,9 @@ spawn_progs (qwaq_thread_t *thread)
|
|||
}
|
||||
pr_argv = PR_Zone_Malloc (pr, (pr_argc + 1) * 4);
|
||||
pr_argv[0] = PR_SetTempString (pr, name);
|
||||
for (i = 1; i < pr_argc; i++)
|
||||
for (i = 1; i < pr_argc; i++) {
|
||||
pr_argv[i] = PR_SetTempString (pr, thread->args.a[i]);
|
||||
}
|
||||
pr_argv[i] = 0;
|
||||
|
||||
PR_RESET_PARAMS (pr);
|
||||
|
|
|
@ -90,6 +90,14 @@ free_defs (LocalsData *self)
|
|||
if (data && func.local_size && func.local_data) {
|
||||
qdb_get_data (target, func.local_data, func.local_size, data);
|
||||
}
|
||||
if (aux_func) {
|
||||
def_rows[0] = 0;
|
||||
for (int i = 0; i < aux_func.num_locals; i++) {
|
||||
[def_views[i] fetchData];
|
||||
def_rows[i + 1] = [def_views[i] rows];
|
||||
}
|
||||
prefixsum (def_rows, aux_func.num_locals + 1);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -111,14 +119,12 @@ free_defs (LocalsData *self)
|
|||
row:(int)row
|
||||
{
|
||||
View *view = nil;
|
||||
int *index = bsearch (&row, def_rows, aux_func.num_locals, 1, nil);
|
||||
int *index = fbsearch (&row, def_rows, aux_func.num_locals, 1, nil);
|
||||
|
||||
if (index) {
|
||||
if ([column name] == "name") {
|
||||
view = [def_views[*index] nameViewAtRow: row - *index];
|
||||
} else {
|
||||
view = [def_views[*index] dataViewAtRow: row - *index];
|
||||
}
|
||||
DefView *dv = def_views[index - def_rows];
|
||||
int r = row - *index;
|
||||
view = [dv viewAtRow: r forColumn:column];
|
||||
}
|
||||
[view resizeTo:{[column width], 1}];
|
||||
return view;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "ruamoko/qwaq/ui/view.h"
|
||||
#include "ruamoko/qwaq/debugger/debug.h"
|
||||
|
||||
@class TableViewColumn;
|
||||
|
||||
@interface DefView : View
|
||||
{
|
||||
qdb_def_t def;
|
||||
|
@ -13,10 +15,11 @@
|
|||
}
|
||||
+(DefView *)withDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type;
|
||||
+(DefView *)withDef:(qdb_def_t)def in:(void *)data target:(qdb_target_t)target;
|
||||
-initWithDef:(qdb_def_t)def;
|
||||
+(DefView *)withDef:(qdb_def_t)def type:(qfot_type_t *)type in:(void *)data target:(qdb_target_t)target;
|
||||
-initWithDef:(qdb_def_t)def type:(qfot_type_t *)type;
|
||||
-fetchData;
|
||||
-(int) rows;
|
||||
-(View *) nameViewAtRow:(int) row;
|
||||
-(View *) dataViewAtRow:(int) row;
|
||||
-(View *) viewAtRow:(int) row forColumn:(TableViewColumn *)column;
|
||||
@end
|
||||
|
||||
#endif//__qwaq_debugger_defview_h
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "ruamoko/qwaq/debugger/typeencodings.h"
|
||||
#include "ruamoko/qwaq/debugger/views/defview.h"
|
||||
#include "ruamoko/qwaq/debugger/views/nameview.h"
|
||||
#include "ruamoko/qwaq/ui/tableview.h"
|
||||
|
||||
static string meta_views[] = {
|
||||
"BasicView",
|
||||
|
@ -23,12 +24,13 @@ static string meta_views[] = {
|
|||
return self;
|
||||
}
|
||||
|
||||
-initWithDef:(qdb_def_t)def
|
||||
-initWithDef:(qdb_def_t)def type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
self.def = def;
|
||||
self.type = type;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -44,11 +46,10 @@ static string meta_views[] = {
|
|||
}
|
||||
|
||||
+(DefView *)withDef:(qdb_def_t)def
|
||||
type:(qfot_type_t *)type
|
||||
in:(void *)data
|
||||
target:(qdb_target_t)target
|
||||
{
|
||||
qfot_type_t *type = [TypeEncodings getType:def.type_encoding
|
||||
fromTarget:target];
|
||||
string metaname = nil;
|
||||
if (type.meta == ty_alias) {
|
||||
type = type.alias.aux_type;
|
||||
|
@ -64,18 +65,34 @@ static string meta_views[] = {
|
|||
return [NameView withName:"Invalid Meta"];
|
||||
}
|
||||
|
||||
+(DefView *)withDef:(qdb_def_t)def
|
||||
in:(void *)data
|
||||
target:(qdb_target_t)target
|
||||
{
|
||||
qfot_type_t *type = [TypeEncodings getType:def.type_encoding
|
||||
fromTarget:target];
|
||||
return [[DefView withDef:def
|
||||
type:type
|
||||
in:data
|
||||
target:target] retain];
|
||||
}
|
||||
|
||||
-fetchData
|
||||
{
|
||||
// most def views do not need to update themselves
|
||||
return self;
|
||||
}
|
||||
|
||||
-(int) rows
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
-(View *) nameViewAtRow:(int) row
|
||||
{
|
||||
return [NameView withName:qdb_get_string (target, def.name)];
|
||||
}
|
||||
|
||||
-(View *) dataViewAtRow:(int) row
|
||||
-(View *) viewAtRow:(int) row forColumn:(TableViewColumn *)column
|
||||
{
|
||||
if ([column name] == "name") {
|
||||
return [NameView withName:qdb_get_string (target, def.name)];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (double *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (entity *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (unsigned *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (float *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (unsigned *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (int *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithName:(string)name
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:nil])) {
|
||||
return nil;
|
||||
}
|
||||
self.name = name;
|
||||
|
|
|
@ -6,6 +6,12 @@
|
|||
@interface PointerView : DefView
|
||||
{
|
||||
unsigned *data;
|
||||
int invalid;
|
||||
unsigned ptr;
|
||||
qfot_type_t *ptr_type;
|
||||
int ptr_size;
|
||||
void *ptr_data;
|
||||
DefView *ptr_view;
|
||||
}
|
||||
+(PointerView *)withDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type;
|
||||
@end
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
#include <string.h>
|
||||
#include "ruamoko/qwaq/debugger/typeencodings.h"
|
||||
#include "ruamoko/qwaq/debugger/views/nameview.h"
|
||||
#include "ruamoko/qwaq/debugger/views/pointerview.h"
|
||||
#include "ruamoko/qwaq/ui/tableview.h"
|
||||
|
||||
@implementation PointerView
|
||||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (unsigned *)(data + def.offset);
|
||||
|
@ -17,12 +20,64 @@
|
|||
return [[[self alloc] initWithDef:def in:data type:type] autorelease];
|
||||
}
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
if (ptr_data) {
|
||||
obj_free (ptr_data);
|
||||
}
|
||||
[ptr_view release];
|
||||
}
|
||||
|
||||
-draw
|
||||
{
|
||||
[super draw];
|
||||
string val = sprintf ("FIXME [%x]", data[0]);
|
||||
string val = sprintf ("%s [0x%x]", type.encoding, data[0]);
|
||||
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
||||
return self;
|
||||
}
|
||||
|
||||
-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];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (quaternion *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (int *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (unsigned *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (vector *)(data + def.offset);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||
{
|
||||
if (!(self = [super initWithDef:def])) {
|
||||
if (!(self = [super initWithDef:def type:type])) {
|
||||
return nil;
|
||||
}
|
||||
self.data = (unsigned *) (data + def.offset);
|
||||
|
|
Loading…
Reference in a new issue