microsoft / microsoft/vscode-cpptools
Can we reference the expression being evaluated within the natvis rule?
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 6.2k
- Fork
- 1.7k
- Merge trung bình
- 14 giờ 46 phút
- Pull request đã merge (30 ngày)
- 61
Mô tả
Are there any way to reference the expression being evaluated from the natvis rule?
Here are some examples what I am talking about.
Consider we have color_t type defined as typedef uint32_t color_t;, also let's suppose we have a special variable $_self which references current expression. Now we can write natvis rule:
<Type Name="color_t">
<DisplayString>A:{$_self >> 24} R:{($_self>>16) & 0xFF} G:{($_self>>8) & 0xFF} B: {$_self & 0xFF}</DisplayString>
</Type>
So we can see color information in a human readable format.
Another example. Consider we have some struct in C:
typedef struct
{
int state;
//other fields follow
}TCB;
Also there is global variable:
TCB* Running;
I want to make natvis rules that will show the state of the object based on the `state` field and `Running` global variable. If we would have a special variable `$_self` (as above). We could write:
<Type Name="TCB">
<DisplayString Condition="state==0">Empty</DisplayString>
<DisplayString Condition="state==0x80 && Running!=&$_self">Ready</DisplayString>
<DisplayString Condition="state==0x80 && Running==&$_self">Running</DisplayString>
</Type>
The last example could be realized for C++ language using this keyword, but not for C (or I just do not know how).
So are there any way to make such natvis rules? A there any possibility to add some special variable?
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Issue không cung cấp tệp, bài kiểm thử hay điểm bắt đầu nào. Hãy bắt đầu bằng cách tìm trong repository phần xử lý natvis của Type, DisplayString và Condition; được xem là hoàn tất khi xác định được liệu một self-expression có thể được expose trong cả quá trình đánh giá natvis của C và C++ hay không, hoặc ghi lại lý do tại sao không thể thực hiện việc đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, cpp
- Lĩnh vực
- devtools
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100