需要有关“设置字节序”的信息在Solaris机器上

发布于 2024-09-02 00:20:22 字数 100 浏览 7 评论 0原文

任何1都可以告诉或显示我在solaris机器上的gdb中“设置endian little”之前和之后任何程序的行为差异吗?

我想知道改变后的效果。

谢谢!

Can any 1 please tell or show the difference in the behaviour of any program before and after I "set endian little" in gdb on solaris machine?

I want to know the effect of changing it.

Thanks!

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

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

发布评论

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

评论(2

弥繁 2024-09-09 00:20:22

在进行本机(而不是远程)调试时,您应该永远不必设置字节序。

不过,您可以观察到这样做的不良影响:(

这是在 Linux/x86 计算机上,但我希望您在 Solaris/x86 和 Solaris/SPARC 上会得到类似的结果)。

int main()
{
  int x = 0x1020304;
  return x;
}


gdb -q a.out
Reading symbols from /tmp/a.out...done.
(gdb) b 4
Breakpoint 1 at 0x804835c: file t.c, line 4.
(gdb) r

Breakpoint 1, main () at t.c:4
4     return x;
(gdb) show endian
The target endianness is set automatically (currently little endian)
(gdb) p &x
$1 = (int *) 0xffffce60
(gdb) p/x *(int*)0xffffce60
$2 = 0x1020304
(gdb) set endian big
The target is assumed to be big endian
(gdb) p/x *(int*)0xffffce60
$3 = 0x4030201

You should never have to set endianness when doing native (as opposed to remote) debugging.

You can however observe the ill effects of doing that:

(This is on Linux/x86 machine, but I expect you'll get similar results on Solaris/x86 and Solaris/SPARC).

int main()
{
  int x = 0x1020304;
  return x;
}


gdb -q a.out
Reading symbols from /tmp/a.out...done.
(gdb) b 4
Breakpoint 1 at 0x804835c: file t.c, line 4.
(gdb) r

Breakpoint 1, main () at t.c:4
4     return x;
(gdb) show endian
The target endianness is set automatically (currently little endian)
(gdb) p &x
$1 = (int *) 0xffffce60
(gdb) p/x *(int*)0xffffce60
$2 = 0x1020304
(gdb) set endian big
The target is assumed to be big endian
(gdb) p/x *(int*)0xffffce60
$3 = 0x4030201
不必你懂 2024-09-09 00:20:22

为了完全回答您的问题,此设置对调试程序绝对没有任何影响,仅对 gdb 输出产生影响,正如 Employed Russian 已经指出的那样。

To fully answer your question, this setting will have absolutely no effect whatsoever on the debugged program, only on gdb output as Employed Russian already stated.

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