Skip to content

Commit

Permalink
kram - more lldb formatter cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alecazam committed Oct 22, 2024
1 parent 10736d6 commit 94c8f63
Showing 1 changed file with 18 additions and 68 deletions.
86 changes: 18 additions & 68 deletions scripts/simdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,37 @@
# simd library

# the vector ext allow various forms of addressing, but they require python eval to do so.
# but everything else fails.
# but everything else fails. Only the EvaluateExpression returns the values.

def float2_summary(valobj, internal_dict):
frame = valobj.GetFrame()

name = valobj.GetName()
x_value = frame.EvaluateExpression('{0}.x'.format(name))
y_value = frame.EvaluateExpression('{0}.y'.format(name))
x = x_value.GetValue()
y = y_value.GetValue()
x = frame.EvaluateExpression('{0}.x'.format(name)).GetValue()
y = frame.EvaluateExpression('{0}.y'.format(name)).GetValue()
return '({0},{1})'.format(x, y)

def float3_summary(valobj, internal_dict):
frame = valobj.GetFrame()
name = valobj.GetName()
x_value = frame.EvaluateExpression('{0}.x'.format(name))
y_value = frame.EvaluateExpression('{0}.y'.format(name))
z_value = frame.EvaluateExpression('{0}.z'.format(name))
x = x_value.GetValue()
y = y_value.GetValue()
z = z_value.GetValue()
x = frame.EvaluateExpression('{0}.x'.format(name)).GetValue()
y = frame.EvaluateExpression('{0}.y'.format(name)).GetValue()
z = frame.EvaluateExpression('{0}.z'.format(name)).GetValue()
return '({0},{1},{2})'.format(x, y, z)

def float4_summary(valobj, internal_dict):
frame = valobj.GetFrame()
name = valobj.GetName()
x_value = frame.EvaluateExpression('{0}.x'.format(name))
y_value = frame.EvaluateExpression('{0}.y'.format(name))
z_value = frame.EvaluateExpression('{0}.z'.format(name))
w_value = frame.EvaluateExpression('{0}.w'.format(name))
x = x_value.GetValue()
y = y_value.GetValue()
z = z_value.GetValue()
w = w_value.GetValue()
x = frame.EvaluateExpression('{0}.x'.format(name)).GetValue()
y = frame.EvaluateExpression('{0}.y'.format(name)).GetValue()
z = frame.EvaluateExpression('{0}.z'.format(name)).GetValue()
w = frame.EvaluateExpression('{0}.w'.format(name)).GetValue()
return '({0},{1},{2},{3})'.format(x, y, z, w)

def float2x2_summary(valobj, internal_dict):
frame = valobj.GetFrame()
name = valobj.GetName()

# columns = frame.EvaluateExpression('{0}.columns'.format(name))
#
# x = columns.GetValueAtIndex(0)
# y = columns.GetValueAtIndex(1)


structVar = valobj.GetChildAtIndex(0)

x = structVar.GetChildAtIndex(0)
Expand All @@ -62,11 +49,6 @@ def float3x3_summary(valobj, internal_dict):
frame = valobj.GetFrame()
name = valobj.GetName()

#columns = frame.EvaluateExpression('{0}.columns'.format(name))
#x = columns.GetValueAtIndex(0)
#y = columns.GetValueAtIndex(1)
#z = columns.GetValueAtIndex(2)

structVar = valobj.GetChildAtIndex(0)

x = structVar.GetChildAtIndex(0)
Expand All @@ -84,20 +66,13 @@ def float4x4_summary(valobj, internal_dict):
name = valobj.GetName()

structVar = valobj.GetChildAtIndex(0)
#structVar = frame.FindVariable(name)
#columns = structVar.GetChildMemberWithName("columns")

#x = structVar.GetChildMemberWithName("columns").GetValueAtIndex(0)
#y = structVar.GetChildMemberWithName("columns").GetValueAtIndex(1)
#z = structVar.GetChildMemberWithName("columns").GetValueAtIndex(2)
#w = structVar.GetChildMemberWithName("columns").GetValueAtIndex(3)

x = structVar.GetChildAtIndex(0)
y = structVar.GetChildAtIndex(1)
z = structVar.GetChildAtIndex(2)
w = structVar.GetChildAtIndex(3)

# how to make this work? Just reports "None" is the frame incorrect?
# TODO: how to make this work? Just reports "None" is the frame incorrect?
# x = float4_summary(x, internal_dict)
# y = float4_summary(y, internal_dict)
# z = float4_summary(z, internal_dict)
Expand All @@ -108,17 +83,8 @@ def float4x4_summary(valobj, internal_dict):


def __lldb_init_module(debugger, internal_dict):

# v.x produces
# summay string error. These are using clang vector math ext

# type summary add --summary-string "${var[0-1]}" simd_float2

# This doesn't work
#debugger.HandleCommand("type summary add --summary-string \"${var[0]},${var[1]}\" simd_float2")
#debugger.HandleCommand("type summary add --summary-string \"${var[0]},${var[1]},${var[2]}\" simd_float3")
#debugger.HandleCommand("type summary add --summary-string \"${var[0]},${var[1]},${var[2]},${var[3]}\" simd_float4")


# simd library, many more types here
debugger.HandleCommand("type summary add -F simdk.float2_summary simd_float2")
debugger.HandleCommand("type summary add -F simdk.float3_summary simd_float3")
debugger.HandleCommand("type summary add -F simdk.float4_summary simd_float4")
Expand All @@ -128,12 +94,7 @@ def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("type summary add -F simdk.float3x3_summary simd_float3x3")
debugger.HandleCommand("type summary add -F simdk.float2x2_summary simd_float2x2")

# debugger.HandleCommand("type summary add --summary-string \"${var.columns[0]}\n${var.columns[1]}\n${var.columns[2]}\n${var.columns[3]}\" simd_float4x4")

#type summary add --summary-string "${var.columns[0]}, ${var.columns[1]}, ${var.columns[2]}, ${var.columns[3]}" simd::float4x4

#type summary add --summary-string "${var.columns[0]}\n${var.columns[1]}\n${var.columns[2]}" simd_float3x3
#type summary add --summary-string "${var.columns[0]}\n${var.columns[1]}\n${var.columns[2]}" simd::float3x3
# TODO: add char, short, int8a, float8a, ...

# simdk library

Expand All @@ -155,7 +116,7 @@ def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("type summary add -F simdk.float4_summary float4a")

debugger.HandleCommand("type summary add -F simdk.float4x4_summary simdk::float4x4")
debugger.HandleCommand("type summary add -F simdk.float3x3_summary simdk::float3x4")
debugger.HandleCommand("type summary add -F simdk.float3x4_summary simdk::float3x4")
debugger.HandleCommand("type summary add -F simdk.float3x3_summary simdk::float3x3")
debugger.HandleCommand("type summary add -F simdk.float2x2_summary simdk::float2x2")

Expand All @@ -167,18 +128,7 @@ def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("type summary add -F simdk.float4_summary double4a")

debugger.HandleCommand("type summary add -F simdk.float4x4_summary simdk::double4x4")
debugger.HandleCommand("type summary add -F simdk.float3x3_summary simdk::double3x4")
debugger.HandleCommand("type summary add -F simdk.float3x4_summary simdk::double3x4")
debugger.HandleCommand("type summary add -F simdk.float3x3_summary simdk::double3x3")
debugger.HandleCommand("type summary add -F simdk.float2x2_summary simdk::double2x2")


#type summary add --summary-string "${var[0]},${var[1]}" float2a
#type summary add --summary-string "${var[0]},${var[1]},${var[2]}}" float3a
#type summary add --summary-string "${var[0]},${var[1]},${var[2]},${var[3]}" float4a

#type summary add -F simdk.float2_summary float2a
#type summary add -F simdk.float3_summary float3a
#type summary add -F simdk.float4_summary float4a

#type summary add --summary-string "${var.columns[0]}\n${var.columns[1]}\n${var.columns[2]}\n${var.columns[3]}" simdk::float4x4
#type summary add --summary-string "${var.columns[0]}\n${var.columns[1]}\n${var.columns[2]}" simdk::float3x3

0 comments on commit 94c8f63

Please sign in to comment.