代码之家  ›  专栏  ›  技术社区  ›  David Citron

Solaris pstack输出:“SYS#0”是什么意思?

  •  2
  • David Citron  · 技术社区  · 16 年前

    我在堆栈顶部遇到了“SYS#0”,并且找不到任何关于这意味着什么的文档。

    • 操作系统:Solaris 9
    • 拱门:斯巴克
    • 内存管理器libcacad_32.so from Hoard 3.5.1

    我们使用“gcore”生成一个核心文件。查看针对核心文件运行“pstack”命令的输出,唯一一个正在执行任何有趣操作的线程在其调用堆栈的最顶端有以下内容:

    ff309858 SYS#0    ()
    ff309848 void MyHashMap<const void*,unsigned,AlignedMmapInstance<65536U>::SourceHeap>::set(const void*,unsigned) (ff31eed4, 9bf20000, 10000, 40, 9bf1fff0, ff31e738) + 134
    ...
    

    该LWP的PFLAG显示:

    /8:   flags = PR_STOPPED|PR_ISTOP|PR_ASLEEP
    why = PR_REQUESTED
    sigmask = 0xfffffeff,0x00003fff
    

    我在Sun文档中找不到任何关于此语法的提及。

    编辑: 在进行gcore之前,该过程似乎已暂停。“SYS#0”与进程挂起是否存在某种关联?

    编辑: g1 登记 should contain

    1 回复  |  直到 12 年前
        1
  •  2
  •   Martin Carpenter    16 年前

    试试这个:

    $ cat foo.c
    #include <stdio.h>
    
    int main(int argc, char *argv[]) {
    
        char buf[1024];
        proc_sysname(0, buf, 1024);
        printf("%s\n", buf);
    
    }
    $ gcc -ofoo -lproc foo.c
    $ ./foo
    SYS#0
    $
    

    SYS#0 因此是表示系统调用零的字符串。如果你往里看 <sys/syscall.h> (系统调用表)您将发现以下内容:

    /* syscall enumeration MUST begin with 1 */
    
    /*
     * SunOS/SPARC uses 0 for the indirect system call SYS_syscall
     * but this doesn't count because it is just another way
     * to specify the real system call number.
     */
    
    #define SYS_syscall 0
    

    syscall(SYS_syscall, foo, bar, ...) 相当于直接呼叫 syscall(foo, bar, ...) .