有没有成熟的解决方案来创建带有 ELF 符号和 C 语法命令解析器的即时 shell?

发布于 2024-11-26 17:20:32 字数 333 浏览 2 评论 0原文

我需要在每个c exe(linux环境)中创建一个调试shell,我的解决方案如下:

  1. 从exe文件中读取elf符号,在其中构建一个符号->地址表 记忆;
  2. 运行一个调用 readline 的线程来接受用户输入,一些事情 就像 ac 函数调用一样;
  3. 使用 Lex & yacc 解析函数名和arg列表;
  4. 在符号表中查找函数的地址;
  5. 使用参数列表调用函数;
  6. 每个编写的函数都可以立即作为 shell 命令输入。

我不认为这是一个新鲜的想法,我的问题是:是否已经实现了成熟的代码? 感谢您的帮助!

I need to make a debug shell inside each c exe(linux enviroment), and my solution is as follows:

  1. Read elf symbols from exe file, build a symbol->address table in
    memory;
  2. Run a thread calling readline to accept user input, some thing
    like a c function call;
  3. use Lex & yacc to parse the function name and arg list;
  4. Find address of the function in the symbol table;
  5. Call the function with args list;
  6. Every function written can be input as shell command instantly.

I don't think this is a fresh idea, and my question is: Are there any mature codes implemented already?
Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山色无中 2024-12-03 17:20:32

当然。如果您曾经使用过 VxWorks,您会发现 WindShell 正是您所需要的。我已经将类似的 shell 移植到 Linux 上。您可以从以下位置下载源代码:
https://sourceforge.net/projects/zprj/

注意:请勿将源代码用于商业用途产品,因为它们是从 WindShell 移植的。如果你确实想要一个商业领域的 shell,那么你应该使用 LEX/YACC 开发一个 shell。

Sure. If you had working with VxWorks, you'll find WindShell is what you're looking for. I had port a similar shell to Linux. You can download the source from:
https://sourceforge.net/projects/zprj/

Note: don't use the source in commercial products, since they are ported from WindShell. If you do want a shell in commercial fields, then you shall develop one with LEX/YACC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文