Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The number of arguments is unimportant unless some of them are correct. -- Ralph Hartley


devel / comp.os.msdos.djgpp / Re: gprof report incomplete

SubjectAuthor
* gprof report incompleteBen Collver
`* Re: gprof report incompleteEli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com]
 `- Re: gprof report incompleteBen Collver

1
gprof report incomplete

<slrntee0oh.lbr.bencollver@svadhyaya.localdomain>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=203&group=comp.os.msdos.djgpp#203

  copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: bencoll...@tilde.pink (Ben Collver)
Newsgroups: comp.os.msdos.djgpp
Subject: gprof report incomplete
Date: Sun, 31 Jul 2022 22:34:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 79
Message-ID: <slrntee0oh.lbr.bencollver@svadhyaya.localdomain>
Injection-Date: Sun, 31 Jul 2022 22:34:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="751ef69a8ccef7ae698861047f95b1a1";
logging-data="542046"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185msZsReTCe8Kuyn+NqWNdAmOb3ZmGcIA="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:cubJS+aOtsk5dKBQxiEqXn404lE=
 by: Ben Collver - Sun, 31 Jul 2022 22:34 UTC

I am trying to use gprof in DJGPP 2.05. I wrote a small test program
named hello.c. On Linux, gprof correctly reports 10 calls to
function helloworld. With DJGPP, gprof reports an undefined number
of calls to __dpmi_int and nothing else.

I have included the program source and output below [1].

I reviewed the DJGPP FAQ chapter 13 to verify that i ran gprof
correctly. https://www.delorie.com/djgpp/v2faq/faq13_1.html

I am not sure how to troubleshoot this further. Any other ideas?

Thanks!
-Ben

[1]
bash-5.1$ cat hello.c
#include <stdio.h>

void helloworld(void) {
printf("hello world\r\n");
}

int main(int argc, char *argv[]) {
int i;
for (i = 0; i < 10; i++) {
helloworld();
}
} bash-5.1$ gcc -pg -o hello hello.c
bash-5.1$ ./hello
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
bash-5.1$ gprof hello|head
Flat profile:

Each sample counts as 0.01 seconds.
no time accumulated

% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 10 0.00 0.00 helloworld
% the percentage of the total running time of the

C:\>gcc --version
gcc.exe (GCC) 7.2.0
....
C:\>gcc -pg -o hello.exe hello.c
C:\>hello.exe
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
C:\>gprof hello.exe | head
Flat profile:

Each sample counts as 0.0555556 seconds.
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
100.00 0.11 0.11 __dpmi_int

% the percentage of the total running time of the
time program used by this function.
C:\>

Re: gprof report incomplete

<834jyw43ec.fsf@gnu.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=205&group=comp.os.msdos.djgpp#205

  copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 01 Aug 2022 11:19:15 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
mime-version; bh=13WnBvZM/SMveyXTzjj3fRiTsm2F3vgvyYJ549XRkTQ=; b=i3FKEA4EFWuS
1ZUQ7qxXFhSME4PDJrjjsjgwpZ9u8j3WI/bkNTs0P/AHX4eWpSvwbDSkE3ixsqm34nr8Co0IvBqC3
7DWcJTBfVElYJgGgypJ0QmXao0RWywTUfLP+awTlzdQI19wtCOve4+WCXL8v345v/hyAV1ySnI3kL
k+VDIKXBmHTrAjDCMojYBGORvxFMsc96YPB2jByktOEN9zQFF0gEdc5FX+H0lwpS8Z0tSpi/zQ9eH
LXGb27mL3XLWyg146I0e3U70gWCLkJXXdyTF6jy3Ea9blYWGpGtmTtA9rlNrvJfdtgNe4QvV5HGjY
Bnp3/hJ3AJxzJV2e091eVA==;
Date: Mon, 01 Aug 2022 14:19:39 +0300
Message-Id: <834jyw43ec.fsf@gnu.org>
From: djg...@delorie.com (Eli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com])
To: djgpp@delorie.com
In-Reply-To: <slrntee0oh.lbr.bencollver@svadhyaya.localdomain>
(djgpp@delorie.com)
Subject: Re: gprof report incomplete
References: <slrntee0oh.lbr.bencollver@svadhyaya.localdomain>
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 19
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-RWLdDneMCHtE16AjVplV4ZRRK5sHA7rqcsOmuWnr/RX6V+WQjDUk9/F1QR5/s78oeVTf1CZYJnuYN+0!5bK3Pj7xaIodbC9r+FxhDb9OpBIJE9EvX4yzl1rg0g6k
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Eli Zaretskii (eliz@ - Mon, 1 Aug 2022 11:19 UTC

> From: "Ben Collver (bencollver@tilde.pink) [via djgpp@delorie.com]" <djgpp@delorie.com>
> Date: Sun, 31 Jul 2022 22:34:45 -0000 (UTC)
>
> I am trying to use gprof in DJGPP 2.05. I wrote a small test program
> named hello.c. On Linux, gprof correctly reports 10 calls to
> function helloworld. With DJGPP, gprof reports an undefined number
> of calls to __dpmi_int and nothing else.

I think this is more or less expected, given that (a) the profile
timer has a relatively low frequency in DJGPP (just 18.2 Hz), that
(b) the heavy processing of printf is in triggering switch from
protected mode to real mode and invoking a DOS interrupt (which
is what __dpmi_int does), and (c) that the profile timer is
effectively disabled during the time the CPU is in real mode.

> I am not sure how to troubleshoot this further. Any other ideas?

Why is it important to profile such toy programs? What real-life
problem did you encounter that led you to try the above?

Re: gprof report incomplete

<slrntefrv5.qd7.bencollver@svadhyaya.localdomain>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=206&group=comp.os.msdos.djgpp#206

  copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: bencoll...@tilde.pink (Ben Collver)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: gprof report incomplete
Date: Mon, 1 Aug 2022 15:25:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 87
Message-ID: <slrntefrv5.qd7.bencollver@svadhyaya.localdomain>
References: <slrntee0oh.lbr.bencollver@svadhyaya.localdomain>
<834jyw43ec.fsf@gnu.org>
Injection-Date: Mon, 1 Aug 2022 15:25:13 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="751ef69a8ccef7ae698861047f95b1a1";
logging-data="1057338"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2BAcvmxm8kC2lP0Nf5U0qEq1835pPLY0="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:al4ZGZW85D1d7X7r5dgXhiyZJUE=
 by: Ben Collver - Mon, 1 Aug 2022 15:25 UTC

On 2022-08-01, Eli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com]
<djgpp@delorie.com> wrote:
> Why is it important to profile such toy programs? What real-life
> problem did you encounter that led you to try the above?

Thank you for your response. The "real-life problem" happened when i
tried to profile a game named Angband 4.2.4. I compiled and linked
angband with -pg and when i ran angband.exe i got the error below [1].
I am also including a short gdb trace below [2] and the definition of
the argv0 variable below [3].

This crash only happens when i build angband with -pg. It does not
happen in a normal build nor in a debug build.

I wrote the toy program in an attempt to simplify the situation and get
more familiar with gprof.

-Ben

[1]
Exiting due to signal SIGSEGV
Page fault at eip=00150b91, error=0004
eax=00181afc ebx=00000000 ecx=00000000 edx=002e7b84 esi=0022e198
edi=0000000c
ebp=0022db88 esp=0022db60 program=C:\GAMES\ANGBAND\ANGBAND.EXE
cs: sel=00a7 base=00400000 limit=002effff
ds: sel=00af base=00400000 limit=002effff
es: sel=00af base=00400000 limit=002effff
fs: sel=008f base=00005920 limit=0000ffff
gs: sel=00bf base=00000000 limit=0010ffff
ss: sel=00af base=00400000 limit=002effff
App stack: [0022dbf8..001adbfc] Exceptn stack: [001adb48..001abc08]

Call frame traceback EIPs:
0x00150b91

[2]
(gdb) l main
313 * Note the special "--" option which terminates the processing
of
314 * standard options. All non-standard options (if any) are
passed
315 * directly to the "init_xxx()" function.
316 */
317 int main(int argc, char *argv[])
318 {
319 int i;
320 bool new_game = alse, select_game = false;
321 bool done = false;
322
(gdb) l
323 const char *mstr = NULL;
324 bool args = true;
325
326 /* Save the "program name" XXX XXX XXX */
327 argv0 = argv[0];
328
....
(gdb) b 327
Breakpoint 1 at 0x150b91: file main.c, line 327.
(gdb) r
Starting program: c:/games/angband/angband.exe

Breakpoint 1, main (argc=1, argv=0x22e3b0) at main.c:327
327 argv0 = argv[0];
(gdb) p argv
$1 = (char **) 0x22e3b0
(gdb) p argv[0]
$2 = 0x22e350 "c:/games/angband/angband.exe"
(gdb) p argv0
$3 = 0x0
(gdb) p &argv0
$4 = (char **) 0x1a6444 <argv0>
(gdb) s

Thread 1 received signal SIGSEGV, Segmentation fault.
main (argc=1, argv=0x22e3b0) at main.c:327
327 argv0 = argv[0];
(gdb) _

[3]
From src/z-util.c:

/**
* Convenient storage of the program name
*/
char *argv0 = NULL;

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor