I want to debug the nginx program with gdb, but there is a problem in the process of using gdb. Could you take a look at it?

I want to debug the nginx program with gdb, but there is a problem in the process. Could you take a look at it?

Operation flow

1. First, the-g parameter of make is configured to make cc-g
2.gdb objs/nginx start debugging
3.b src/core/nginx.c:91 break point to the first line of the function, and there must be

of argc.

question

1. Sometimes the breakpoint is invalid and elusive, and I feel that I have used a fake gdb, such as entering the r command, and the execution is completed without interruption. Use print var, to say

(gdb) print argc
No symbol "argc" in current context.
The

2.list parameter shows the file source code, but it shows this:

(gdb) list
1    /* Startup code compliant to the ELF x86-64 ABI.
2       Copyright (C) 2001-2012 Free Software Foundation, Inc.
3       This file is part of the GNU C Library.
4       Contributed by Andreas Jaeger <aj@suse.de>, 2001.
5
6       The GNU C Library is free software; you can redistribute it and/or
7       modify it under the terms of the GNU Lesser General Public
8       License as published by the Free Software Foundation; either
9       version 2.1 of the License, or (at your option) any later version.
10
(gdb) list main
No line number known for main.

according to the configuration of directory, on the Internet, it still can"t be solved. Do I use

?
(gdb) directory src/core/
Mar.28,2021

compiled and developed version of nginx, here take the nginx source image on github as an example

git clone https://github.com/nginx/nginx.git
cd nginx
CFLAGS="-g -O0" ./auto/configure --with-debug --prefix=../etc
make
make install

modify the nginx.conf configuration file to listen on port 8080 and enable development mode

worker_processes  1;
+master_process off;
+daemon off;

http {
   server {
       -listen       80;
       +listen       8080;

run nginx at this time, and then open http://localhost:8080/ in a browser to confirm that the website is running

.
../etc/sbin/nginx

finally rerun nginx using gdb

xxx/nginx > gdb ../etc/sbin/nginx
Reading symbols from ../etc/sbin/nginx...done.

(gdb) b main
Breakpoint 1 at 0xNNNN: file src/core/nginx.c, line 196.

(gdb) r
Starting program: ../etc/sbin/nginx
[Thread debugging using libthread_db enabled]
Using host libthread_db library "xxx/lib/libthread_db.so.1".

(gdb) b main
Breakpoint 1, main (argc=1, argv=0xNNNN) at src/core/nginx.c:196

(gdb) list main
191    static char **ngx_os_environ;
192
193
194    int ngx_cdecl
195    main(int argc, char *const *argv)
196    {
197        ngx_buf_t        *b;
198        ngx_log_t        *log;
199        ngx_uint_t        i;
200        ngx_cycle_t      *cycle, init_cycle;

(gdb) print argc
$1 = 1

(gdb) print argv[0]
$2 = 0xNNNN "xxx/etc/sbin/nginx"

gdb prompt

  1. use help or help xxx to get command help.
  2. to add a function breakpoint, you can directly enter b < function name > without having to find out the file location of the function. The same goes for list .
< H2 > reference < / H2 >
  1. ide/installing-nginx/installing-nginx-open-source/-sharpsources" rel=" nofollow noreferrer "> https://docs.nginx.com/nginx/.
  2. https://nginx.org/en/docs/ngx.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be84d0-4692b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be84d0-4692b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?