gdbserver 질문입니다.

harisoo의 이미지

gdbserver와 gdb사용법에 대해 의문이 들어 질문 올립니다.

gdbserver를 이용하지 않고 gdb a.out을 하면 모든 명령이 잘 먹습니다.

그런데 gdbserver로 실행을 시키고

gdb로 원격접속을 하니 제대로 명령이 먹지 않네요.

하다못해 브레이크 포인트라도 걸어야 하는데 브레이크포인터 설정도 안대고, 무엇이 잘못인지 모르겟습니다.

gnu에서 5.3버전을 받아서 제컴에서 컴파일해서 나온 gdb,gdbserver로 사용을 햇습니다.

아래는 제 화면입니다.
---서버쪽 화면
[root@localhost aaa]# ./gdbserver 192.168.1.20:5000 ts
Process ts created; pid = 26231
Remote debugging from host 192.168.1.20
input:1234567
1073828704

---클라이언트화면
[root@localhost test]# gdb ts
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...ts: 그런 파일이나 디렉토리?
?없음.

(gdb) target remote 192.168.1.20:5000
Remote debugging using 192.168.1.20:5000
0x40000be0 in ?? ()
(gdb) l
No symbol table is loaded. Use the "file" command.
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x4000c6a0 in ?? ()
(gdb) l
No symbol table is loaded. Use the "file" command.
(gdb) bt
#0 0x4000c6a0 in ?? ()
#1 0x42029c20 in ?? ()
#2 0x420155d8 in ?? ()
(gdb) file ts
A program is being debugged already. Kill it? (y or n) n
Program not killed.

--실험코드

#include <stdio.h>
 
int main( int argc, char *argv[] ) {
        int i;
        scanf("%d",i);
        printf("%d\n",i):
        return 0;
}
김유석의 이미지

바이너리를 컴파일 하실때 -g 옵션을 주셨나요? 혹은 -g 옵션을 주셨는데 strip 을 하신 건 아닐까요?

voider의 이미지

이건 gdb 가 실행파일 아키텍쳐를 잘못파악했을때 발생하는 문제 같습니다.
-- 아쉬운 하루 되세요 --

-- 아쉬운 하루 되세요 --

thyoo의 이미지

윗분 말씀대로입니다.

target하고 host machine 다른 모양이군요.
cross compiler 만들 듯이 cross gdb로 컴파일하세요.
___________________________________
Less is More (Robert Browning)

___________________________________
Less is More (Robert Browning)

harisoo의 이미지

왜냐하면 gnu에서 5.3버전으로 받아서

컴파일후에

제 컴에서 서버 돌리고
원격접속을 했습니다.

타켓이 다를 이유가 없다고 봅니다.

혹시 컴파일할때 타켓을 지정해야 하는가요?

그냥 ./configure하고 메이크 했습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.