使用sourceinsight阅读内核代码的一些问题

工具栏格式乱了怎么办

https://blog.csdn.net/qq_23327993/article/details/115567723

Linux内核中有很多宏定义,sourceinsight不识别,导致解析出问题

https://blog.csdn.net/nust20/article/details/46486947
https://www.jianshu.com/p/0b4ad9532367
https://tjtech.me/how-to-fix-parse-too-complex-in-source-insight.html
https://blog.csdn.net/qq_41908302/article/details/131273274
https://blog.csdn.net/bestboyxie/article/details/53415487

修改:"Source Insight 4.0\c.tom"

;For Linux Kernel Code
__acquires(x)
__acquire(x)
__aligned(x)
__aligned_be64
__aligned_le64
__aligned_u64
__always_inline
__always_inline
__annotate_jump_table
__attribute__(x)
__bitwise
__bitwise__
__bss_decrypted
__builtin_warning
____cacheline_aligned
__cacheline_aligned
____cacheline_aligned_in_smp
__cacheline_aligned_in_smp
____cacheline_internodealigned_in_smp
__cacheline_internodealigned_in_smp
__chk_io_ptr(x)
__chk_user_ptr(x)
__compiler_offsetof(a,b)
__cond_lock(x,c)
__devexit
__devexitconst
__devexitdata
__devinit
__devinitconst
__devinitdata
__exit
__exit_call
__exitdata
__exit_refok
__exitused
__force
__head
__init
__initconst
__initdata
__initdata_refok
__init_refok
__init_thread_info
__iomem
__irq_entry
__lockfunc
__kernel
__kprobes
__meminit
__meminitconst
__meminitdata
__must_check
__naked
__nocast
__noreturn
__nosavedata
__page_aligned_data
__PAGE_ALIGNED_DATA
__page_aligned_bss
__PAGE_ALIGNED_BSS
__percpu
__prel64_initconst
__printf(x, y)
__pure
__rcu
__read_mostly
__ref
__refconst
__refconst
__refdata
__refdata
__reg_oper0
__reg_oper1
__releases(x)
__release(x)
__ro_after_init
__safe
__section(x)
__sched
__softirq_entry
__tracepoint_string
__used
__user
__xipram
CLASS_ATTR(_name, _mode, _show, _store) struct class_attribute class_attr_##_name
DECLARE_BITMAP(name,bits) unsigned long name[bits/32]
DECLARE_RWSEM(name) struct rw_semaphore name
DECLARE_WORK(n, f) struct work_struct n
DEFINE_IDA(name) struct ida name
DEFINE_MUTEX(mutexname) struct mutex mutexname
DEFINE_RWLOCK(x) rwlock_t x
DEFINE_SPINLOCK(x) spinlock_t x
DEFINE_TIMER(_name, _function, _expires, _data) struct timer_list _name
DRIVER_ATTR(_name, _mode, _show, _store) struct driver_attribute driver_attr_##_name
EXPORT_SYMBOL_GPL_FUTURE(sym)
EXPORT_SYMBOL_GPL(sym)
EXPORT_SYMBOL(sym)
likely(x)
LIST_HEAD(name) struct list_head name
noinline
nokprobe_inline
NOKPROBE_SYMBOL(x)
SYSCALL_DEFINE0(name) long sys_##name(void)
SYSCALL_DEFINE1(name, t1, v1) long sys_##name(t1 v1)
SYSCALL_DEFINE2(name, t1, v1, t2, v2) long sys_##name(t1 v1, t2 v2)
SYSCALL_DEFINE3(name, t1, v1, t2, v2, t3, v3) long sys_##name(t1 v1, t2 v2, t3 v3)
SYSCALL_DEFINE4(name, t1, v1, t2, v2, t3, v3, t4, v4) long sys_##name(t1 v1, t2 v2, t3 v3, t4 v4)
SYSCALL_DEFINE5(name, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5) long sys_##name(t1 v1, t2 v2, t3 v3, t4 v4, t5 v5)
SYSCALL_DEFINE6(name, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6) long sys_##name(t1 v1, t2 v2, t3 v3, t4 v4, t5 v5, t6 v6)
unlikely(x)

精准导入需要的源文件

设置宏定义的值

Project -> Default Project Settings -> Conditions:
image

或者:

Options->Preferences->Languages->Conditional Parsing:
image

下面这个工具可以根据内核的配置文件生成SI可以解析的配置,批量导入宏定义的值:
https://github.com/yeyuzhen/ConvertLinuxKernelConfig2SourceInsightConditionsXml

生成xml文件后,点击上面的import按钮导入即可:
image

扩展语言包

posted @ 2024-09-18 11:31  摩斯电码  阅读(59)  评论(0编辑  收藏  举报