TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Debugging C with Cosmopolitan Libc

191 点作者 ahgamut超过 2 年前

8 条评论

abainbridge超过 2 年前
&gt; Cosmopolitan Libc allows you to log every function call over the program’s execution – just pass --ftrace at the end of your program, like this:<p>&gt; .&#x2F;hex16.com .&#x2F;missing.txt --ftrace<p>That seems like magic. It seems you have to build with a special flag that tells GCC to put a nop at the start of each function. Then, before main runs, Cosmopolitan sees the --ftrace on the command line, and modifies the code in memory to replace those nops with calls to something that does the logging. See <a href="https:&#x2F;&#x2F;justine.lol&#x2F;ftrace&#x2F;" rel="nofollow">https:&#x2F;&#x2F;justine.lol&#x2F;ftrace&#x2F;</a>.
评论 #33316711 未加载
评论 #33317272 未加载
评论 #33316223 未加载
评论 #33316158 未加载
andrewmcwatters超过 2 年前
I&#x27;m fascinated specifically with how Justine must have collected the knowledge to write Cosmopolitan. I know some guys who play around with PEs and virtual memory manually, but I always wonder what sort of interests lead you to discovering this sort of thing.<p>I suspect the combination of interests is a little out there. For instance, with game cheat developers, you tend to first at least have some interest in C++, then understanding memory scanning, then signature scanning, trampolining, and all of a sudden you have the skillset ingredients for authoring some rudimentary cheats. Advanced skills come with driver development, which you then pick up to figure out how to evade anti-cheat technology, etc.<p>But very few developers I know say, oh yeah, I was just interested directly in this sort of thing from the get-go and decided to pick up all of the specific skills to go straight to cheat development.<p>Usually, it&#x27;s the guys who already have game development experience.<p>What in the world did Justine see before Cosmopolitan? Maybe debugging tech? An interest in creating her own libc and understanding syscalls? Just fascinating.
评论 #33317207 未加载
评论 #33319032 未加载
mgaunard超过 2 年前
What&#x27;s the advantage over calling gdb yourself?
评论 #33313065 未加载
评论 #33314228 未加载
myuzio超过 2 年前
If anyone&#x27;s interested in how this actually works, take a look at this (originally linked) article: <a href="https:&#x2F;&#x2F;justine.lol&#x2F;ape.html" rel="nofollow">https:&#x2F;&#x2F;justine.lol&#x2F;ape.html</a><p>This reminds me a little bit about how &quot;Wine&quot; works, but because the support doesn&#x27;t involve &quot;everything an OS has to provide&quot; the footprint is smaller.
a-dub超过 2 年前
so where does the machine code for the TUI live? does it get compiled into your binary? how big is it?
评论 #33313924 未加载
gavinray超过 2 年前
I&#x27;ve read that you can use Cosmopolitan to write C++ as well.<p>Can you use similar features with C++ development?
评论 #33319310 未加载
saagarjha超过 2 年前
Perhaps I am missing something but what does this have to with Cosmopolitan?
评论 #33312435 未加载
评论 #33312414 未加载
renox超过 2 年前
I wonder if it would be possible to have a kind of logging function which would work similarly as the --ftrace? That would reduce significantly the no-trace cpu cost.