Bochs에서 gdb stub 사용 해보신분 계신가요?

atlacpi의 이미지

linux 1.0을 예로 들면

bootsect
setup
kernel

이렇게 3개의 program이 하나로 뭉쳐져 image가 되고, bochs에서도 이렇게 만든 image를 실행 시킵니다.

bochs의 gdb stub를 사용해 보면 bochs를 실행시키자 마자 gdb의 연결을 기다립니다. 그러면 linux1.0같은 경우는 bootsect시작부터 gdb와 연결이 되죠, 근데 여기서 문제가 생깁니다. gdb에서 debugging할려면 -g option을 주고 compile된 하나의 실행화일 이어야 한다는 겁니다.

linux1.0의 경우는 head.S + kernel code들이 하나의 프로그램으로 링크가 됩니다.

문제는 bochs에서는 bootsect에서 기다리고 있고, gdb는 head.S즉 kernel시작부분 부터 시작될거라는 예상으로 bochs와 연결을 합니다.

이렇게 되다 보니, gdb에서 bochs로 연결은 되지만, Run, Continue등이 안먹습니다. gdb는 다른프로그램인줄 알고 있으니..--;

혹시 이문제 해결하신분 계신가요? 이문제만 해결되면, ddd+bochs로 한컴퓨터에서 kernel만들고 debugging도 가능한데.. 그것두 source level로.. 히유.. print_out그만 했으면 좋겠습니다.--;

sliver의 이미지

혹시 커널을 개발하고 계신다면,

binary포맷으로 컴파일하지 마시고 elf포맷으로 컴파일하시고 grub을 부트로더로 사용하세요.

grub은 elf포맷도 로딩할 수 있거든요. bochs와 gdb를 연동해서 써본적은 없지만, 이렇게 하면 될것 같네요.

atlacpi의 이미지

elf format으로 link했습니다.

문제는 bochs는 bootsect에서 dbd가 연결되기를 기다린다는 겁니다.
gdb는 kernel이 시작될거라고 믿고 bochs에 연결하는거구요..

히유..--;

Vm~*

sliver의 이미지

저도 언젠가는 해야하기 때문에-_-; 해봤는데 잘 되는군요.

[Administrator@sliver mk3]$ gdb kernel
GNU gdb 2003-03-03-cvs (cygwin-special)
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 "i686-pc-cygwin"...
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x0000fff0 in ?? ()
(gdb) list init_thread()
6       #include "thread.h"
7       #include "pagemanager.h"
8
9
10      void init_thread()
11      {
12              // state : intLevel==1, interrupt disabled
13              Thread *thread1 = new Thread(0,1,&threadFunc1);
14              Thread *thread2 = new Thread(0,1,&threadFunc1);
15              Thread *thread3 = new Thread(0,1,&threadFunc1);
(gdb) break 10
Breakpoint 1 at 0x101394: file kernel.cc, line 10.
(gdb) c
Continuing.

Program received signal 0, Signal 0.
0x00101395 in init_thread() () at kernel.cc:11
11      {
Current language:  auto; currently c++
(gdb) c
Continuing.

Program received signal 0, Signal 0.
0x00102900 in threadFunc1() () at userproc.cc:28
28                      while(x--);
(gdb) quit
The program is running.  Exit anyway? (y or n) y

무엇이 안되는지 좀 더 자세히 말씀해 주세요.
atlacpi의 이미지

하하하 되는군요.. 조금만 도와주세요.. 저두 source level debugging 하고 싶어여.. ^^;

kernel image를 어떻게 만드셨는지 궁금합니다.

저는 linux 1.0처럼 만들었습니다.

nasm으로 bootsect, hw_init 를 만들었습니다.

bootsect <---> linux1.0의 bootsect.S에 대응
hw_init <---> linux1.0의 setup.S에 대응
kernel_img <---> tools/system에 대응

그리고 kernel_img는 elf format으로 만들고.
make_image라는 실행화일을 만들어 boot_sect, hw_init, kernel_img이런순서로 하나의 file로 만들었습니다. 이름은 image로하고..

이렇게 하고 bochs실행하면 gdb에서 연결을 기다립니다.
gdb실행은 kernel_img와 같이 실행합니다.
gdb실행후 bochs에 연결하면, 실행하일이 달라서 debugging할 수 없다는 메세지가 나오고.. 실행이 안되지요..

아무래도 님께서는 이 세부분을 하나의 실행화일로 만드신거 같습니다만..

bochs에서 실행할 최종 image를 만드신 순서나 방법같은걸 좀알려 주시겠습니까? 귀찮게 해드려서 죄송하네요.. 수고하세요.

Vm~*

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.