pro*c里使用__LINE__和__FILE__打印日志与实际的pc对应不起来

LionSoul 2010-07-09 12:12:29
在pro*c里使用__FILE__和__LINE__打印日志时,打印的是预编译后.c对应的行和文件名,使用#line也只能打印接下来几行是正确的,大家是怎么解决的?????急急
...全文
199 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
huliquns 2011-02-23
  • 打赏
  • 举报
回复
有同样的疑问
LionSoul 2010-07-09
  • 打赏
  • 举报
回复
谢谢mymtom,你把我的问题解决了,谢谢!!!!!!!!!!!!!!!非常感谢
mymtom 2010-07-09
  • 打赏
  • 举报
回复

$ cat -n hello.pc
1 #include <assert.h>
2 #include <stdio.h>
3
4 EXEC SQL INCLUDE sqlca;
5
6 int
7 main(int argc, char *argv[])
8 {
9 EXEC SQL BEGIN DECLARE SECTION;
10 char name[20];
11 char addr[80];
12 EXEC SQL END DECLARE SECTION;
13 assert(0);
14 return 0;
15 }
$ proc lines=yes ltype=none iname=hello.pc

Pro*C/C++: Release 9.2.0.1.0 - Production on Fri Jul 9 10:00:14 2010

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

System default option values taken from: /home1/oracle9i/precomp/admin/pcscfg.cfg

$ cc -g -o hello hello.c
$ ./hello
Assertion failed: 0, file hello.pc, line 13
Abort(coredump)
$ gdb hello core
HP gdb 3.3 for PA-RISC 1.1 or 2.0 (narrow), HP-UX 11.00.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 3.3 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Core was generated by `hello'.
Program terminated with signal 6, Aborted.

warning: The shared libraries were not privately mapped; setting a
breakpoint in a shared library will not work until you rerun the program.

#0 0xc020c4b0 in kill+0x10 () from /usr/lib/libc.2
(gdb) where
#0 0xc020c4b0 in kill+0x10 () from /usr/lib/libc.2
#1 0xc01a6c74 in raise+0x24 () from /usr/lib/libc.2
#2 0xc01e70e0 in abort_C+0x160 () from /usr/lib/libc.2
#3 0xc01e713c in abort+0x1c () from /usr/lib/libc.2
#4 0xc01756c8 in _assert+0x178 () from /usr/lib/libc.2
#5 0x2a08 in main (argc=1, argv=0x7a000f7c) at hello.pc:13
(gdb) list
4 EXEC SQL INCLUDE sqlca;
5
6 int
7 main(int argc, char *argv[])
8 {
9 EXEC SQL BEGIN DECLARE SECTION;
10 char name[20];
11 char addr[80];
12 EXEC SQL END DECLARE SECTION;
13 assert(0);
(gdb) q
$
mymtom 2010-07-09
  • 打赏
  • 举报
回复
加上 lines=yes 参数
proc lines=yes ltype=none iname=yourfile.pc
qingtianhit 2010-07-09
  • 打赏
  • 举报
回复
你可以把上线时候的.c文件记录下来的,或者根据日志信息输出的信息内容来判断。别的办法应该也有,不过不知道你写日志的函数怎么封装的...
LionSoul 2010-07-09
  • 打赏
  • 举报
回复
调试的时候看.c文件可以找出错误的位置,但是系统上线后如果系统有错,就只能看到.pc文件了,所以还是得想办法解决啊
qingtianhit 2010-07-09
  • 打赏
  • 举报
回复
这个貌似没法解决的,你最终编译链接的其实就是.c文件,所以记录下的就是.c文件的行数,调试的话就直接看.c文件,然后找到对应代码文件所在的位置...
npngsc 2010-07-09
  • 打赏
  • 举报
回复
pro*c是啥文件?不明白

69,381

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧