Skip to content

Commit

Permalink
feat: add array debug support
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronostasys committed Oct 19, 2023
1 parent c921e9d commit 0a668a7
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 4 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,80 @@ All notable changes to the "pivot-lang-support" extension will be documented in

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [0.0.20]

- add debug support for array types

## [0.0.19]

- add special stype for captured variables
- add highlight for `var` keyword


## [0.0.18]

- add run & debug commands

## [0.0.17]

- generator keyword support

## [0.0.16]

- better debug support for union types

## [0.0.15]

- add trait snippet

## [0.0.14]

- add github action
- add active events back

## [0.0.13]

- support highlight for `is`, `type` and `as` keyword
- add union snippet && macro snippet

## [0.0.12]

- support highlight for `where` and `macro` keyword

## [0.0.11]

- support highlight for `pub` keyword

## [0.0.10]

- auto insert `///` in the start of new line when typing in a doc comment

## [0.0.9]

- add highlight for `trait` keyword
- add semantic highlight config for `for` keyword in impl

## [0.0.8]

- add ability to config log level
- add license
- add repo link

## [0.0.7]

- better debug support

## [0.0.6]

- update client package version to support inlay hints

## [0.0.5]

- add restart command
- add break|continue|self to keywords
- add impl|while snippet

## [0.0.4]

- more accurate keyword highlighting
- add true|false to keywords

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pivot-lang-support",
"displayName": "pivot-lang support",
"description": "",
"version": "0.0.19",
"version": "0.0.20",
"publisher": "pivot-langAuthors",
"license": "MIT",
"repository": {
Expand Down
70 changes: 68 additions & 2 deletions pl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
for docs, see:
https://lldb.llvm.org/use/variable.html
"""

from __future__ import print_function, division
import lldb

Expand Down Expand Up @@ -28,6 +33,64 @@ def get_child_index(self, name):



# class PLHashTableProvider(object):

# def __init__(self, valobj:lldb.SBValue, dict={}):
# self.valobj = valobj

# def update(self):
# return True

# def has_children(self):
# return True

# def num_children(self):
# return self.valobj.GetChildAtIndex(3).GetValueAsUnsigned(0)

# def get_child_at_index(self, index):
# # if index > 0:
# # return None
# # tag = self.valobj.GetChildAtIndex(0).GetValueAsUnsigned(0)
# # child = self.valobj.GetChildAtIndex(1).GetChildAtIndex(tag)

# return self.valobj.GetChildAtIndex(1)

# def get_child_index(self, name):
# return 0


class PLArrayProvider(object):

def __init__(self, valobj:lldb.SBValue, dict={}):
self.valobj = valobj

def update(self):
return True

def has_children(self):
return True

def num_children(self):
return self.valobj.GetChildAtIndex(2).GetValueAsUnsigned(0)

def get_child_at_index(self, index):
arr = self.valobj.GetChildMemberWithName('_arr')

if index == 0:

return arr.CreateChildAtOffset("[0]", 0, arr.type.GetPointeeType())

"""
lldb will auto dereference the pointer before get child if the pointee type is not a primitive
so we may not use `GetChildAtIndex` here to get the array element
"""
bytes = lldb.SBType(self.valobj.GetChildMemberWithName('_arr').type.GetPointeeType()).GetByteSize()
return arr.CreateChildAtOffset("[{}]".format(index), index*bytes, arr.type.GetPointeeType())

def get_child_index(self, name):
return -1


def get_summary(valobj:lldb.SBValue,internal_dict,options):
if "NULL" in valobj.__str__():
return '<null>'
Expand All @@ -36,7 +99,10 @@ def get_summary(valobj:lldb.SBValue,internal_dict,options):


def __lldb_init_module(debugger, dict):
debugger.HandleCommand('type synthetic add --python-class pl.PLUnionProvider -x union[:<.>,]*')
debugger.HandleCommand('type summary add -F pl.get_summary -x union[:<.>,]*')
debugger.HandleCommand('type synthetic add --python-class pl.PLUnionProvider -x union[:<.>,\|]*')
# debugger.HandleCommand('type summary add -F pl.get_summary -x union[:<.>,]*')
# debugger.HandleCommand('type summary add --summary-string "HashTable" -x HashTable[:<.>,\|]*')
# debugger.HandleCommand('type synthetic add --python-class pl.PLHashTableProvider -x HashTable[:<.>,\|]*')
debugger.HandleCommand('type synthetic add --python-class pl.PLArrayProvider -x \[.+\]*')


0 comments on commit 0a668a7

Please sign in to comment.