public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Re: ptype of prototype of a funtion
@ 2004-03-17  5:19 Michael Elizabeth Chastain
  0 siblings, 0 replies; 13+ messages in thread
From: Michael Elizabeth Chastain @ 2004-03-17  5:19 UTC (permalink / raw)
  To: mukeshgct; +Cc: gdb

Hello Murugesan,

Yes, this is everything I need, thanks.

The function PEM_write_PKCS8 is in a library.  Debugging information
("gcc -g ...") takes more disk space, so most libraries are built
without debugging information.

You can look at the place where you obtained the "crypto" lib and
the "ssl" lib and see if there are debugging versions available.
If you built these libraries yourself from source code, then you
can rebuild them with -g ("CFLAGS=-g").  If you did not build these
libraries yourself, then you have to find the person who installed
these libraries and ask them for a debugging version.

Usually, you can debug your program effectively even if the libraries
do not have debugging information.  You just can't debug the
library itself.

Michael C

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
@ 2004-03-18 19:52 Michael Elizabeth Chastain
  0 siblings, 0 replies; 13+ messages in thread
From: Michael Elizabeth Chastain @ 2004-03-18 19:52 UTC (permalink / raw)
  To: gdb, mukeshgct

Hello,

> test.c: In function `main':
> test.c:10: warning: passing arg 3 of `PEM_read_bio_PKCS8_PRIV_KEY_INFO' from
> incompatible pointer type

gcc produces this warning because your source code does not match the
function prototype in the appropriate header (*.h) file.

gdb does not use the information in the header file; it works from
the information in the library (*.a or *.so file).

You need to find a local C programming expert and get some advice.
This isn't a gdb problem.

Michael C

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
  2004-03-17  5:58     ` murugesan
@ 2004-03-18  4:46       ` murugesan
  0 siblings, 0 replies; 13+ messages in thread
From: murugesan @ 2004-03-18  4:46 UTC (permalink / raw)
  To: gdb

After realising the prototype I am passing the correct parameter but it
produces warning


Here goes my script

# cat dinesh
Script started on Thu Mar 18 10:58:12 2004


# gcc -g test.c /home/dinesh/openssl-0.9.7c/libcrypto.sl.0.9.7
/home/dinesh/openssl-0.9.7c/libssl.sl.0.9.7
test.c: In function `main':
test.c:10: warning: passing arg 3 of `PEM_read_bio_PKCS8_PRIV_KEY_INFO' from
incompatible pointer type


# gdb -q a.out
(gdb) break main
Breakpoint 1 at 0x2800: file test.c, line 9.
(gdb) r
Starting program: /home/dinesh/openssl_test/a.out

Breakpoint 1, main () at test.c:9
9               bp=BIO_new_file(PATH"/pkcs8","r");
(gdb) n
10              PEM_read_bio_PKCS8_PRIV_KEY_INFO(bp,&pkcs8,&num, "test");
(gdb) ptype PEM_read_bio_PKCS8_PRIV_KEY_INFO
type = struct pkcs8_priv_key_info_st {
    int broken;
    struct asn1_string_st *version;
    struct X509_algor_st *pkeyalg;
    struct asn1_type_st *pkey;
    struct stack_st *attributes;
} *(struct bio_st *, struct pkcs8_priv_key_info_st **, int *, signed char *)
(gdb) q
The program is running.  Exit anyway? (y or n) y


# cat test.c
#include <openssl/pem.h>
#define PATH "./my_temp"
main()
{
        BIO *bp;
        FILE *fp;
        PKCS8_PRIV_KEY_INFO *pkcs8;
        int num;
        PEM_read_bio_PKCS8_PRIV_KEY_INFO(bp,&pkcs8,&num, "test");
}
#

script done on Thu Mar 18 10:58:52 2004

// For simplicity the program has been reduced ( parameters has not been
initialized )

Regards,
Murugesan

============================================================================
=======================
----- Original Message -----
From: murugesan
To: Ramana Radhakrishnan
Cc: gdb@sources.redhat.com
Sent: Wednesday, March 17, 2004 11:28 AM
Subject: Re: ptype of prototype of a funtion


Cool!! This is working


I have been using the one which has not been built with debug option.
I have the 2 OpenSSL 1 being built with debug option ( in different dir
) and the other without debug option ( in default location )

Thanks Ramana & Elizabeth for reminding me.

Regards,
Murugesan.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
  2004-03-17  4:35   ` Ramana Radhakrishnan
@ 2004-03-17  5:58     ` murugesan
  2004-03-18  4:46       ` murugesan
  0 siblings, 1 reply; 13+ messages in thread
From: murugesan @ 2004-03-17  5:58 UTC (permalink / raw)
  To: Ramana Radhakrishnan; +Cc: gdb

Cool!! This is working


I have been using the one which has not been built with debug option.
I have the 2 OpenSSL 1 being built with debug option ( in different dir
) and the other without debug option ( in default location )

Thanks Ramana & Elizabeth for reminding me.

Regards,
Murugesan.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
  2004-03-17  4:20 ` murugesan
@ 2004-03-17  4:35   ` Ramana Radhakrishnan
  2004-03-17  5:58     ` murugesan
  0 siblings, 1 reply; 13+ messages in thread
From: Ramana Radhakrishnan @ 2004-03-17  4:35 UTC (permalink / raw)
  To: murugesan; +Cc: Michael Elizabeth Chastain, gdb


># gdb a.out
>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.
>..
>(gdb) break main
>Breakpoint 1 at 0x2790: file dinesh.c, line 11.
>(gdb) r
>Starting program: /home/murugesh/openssl_test/a.out
>
>Breakpoint 1, main (argc=1, argv=0x7dbf07c4) at dinesh.c:11
>11              MKDIR(PATH);
>(gdb) s
>12              fp=fopen(PATH"/out","w");
>(gdb)
>13              if(!fp)
>(gdb)
>19                      if(PEM_write_PKCS8(fp,NULL)==0)
>(gdb) ptype PEM_write_PKCS8
>type = int ()
>(gdb) ptype PEM_write_PKCS8()
>type = int
>(gdb) whatis PEM_write_PKCS8()
>type = int
>(gdb) whatis PEM_write_PKCS8
>type = <text variable, no debug info>
>  
>
I hope libcrypto, libssl have been compiled with debug info ? This seems 
to indicate a lack of debug info for the same ?

cheers
ramana

>(gdb) The program is running.  Exit anyway? (y or n) y
>#
>
>script done on Wed Mar 17 09:32:26 2004
>
>
>I think I have covered all the answers for your questions.
>
>Thanks,
>Murugesan
>
>
>=========================================================================================================
>On Tue, 2004-03-16 at 19:46, Michael Elizabeth Chastain wrote:
>  
>
>>Hello Murugesan,
>>
>>  gdb>ptype fun
>>  type = int ()
>>
>>Okay, I have some questions:
>>
>>  What computer and operating system are you using?
>>  What compiler are you using to compile 'fun'?
>>  What version of the compiler are you using?
>>  What command line switches do you use to compile your program?
>>  What command line switches do you use to link your program?
>>
>>Can you make a small sample program which shows this problem?
>>Then use the 'script' command.  'cat' the program,
>>compile and link the program, run gdb on the program,
>>exit 'script', and mail us the typescript.
>>
>>Michael C
>>    
>>
>
>  
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
  2004-03-16 14:16 Michael Elizabeth Chastain
@ 2004-03-17  4:20 ` murugesan
  2004-03-17  4:35   ` Ramana Radhakrishnan
  0 siblings, 1 reply; 13+ messages in thread
From: murugesan @ 2004-03-17  4:20 UTC (permalink / raw)
  To: Michael Elizabeth Chastain; +Cc: gdb

Hello Michael,
	Here goes what you wanted.

# cat dinesh
Script started on Wed Mar 17 09:31:16 2004
# cat dinesh.c
#include <openssl/ssl.h>
#include <openssl/rsa.h>

#define PATH "./dinesh_p_v"
#define MKDIR(PATH) mkdir(PATH,0755)
#define I_LIKE_DINESH 0

int main(int argc, char* argv[])
{
        FILE *fp;
        MKDIR(PATH);
        fp=fopen(PATH"/out","w");
        if(!fp)
        {
                fprintf(stderr,"\nError in creating the file
"PATH"/out\n");
        }
        else
        {
                if(PEM_write_PKCS8(fp,NULL)==0)
                {
                        fprintf(stderr,"\nError in calling the function
PEM_write\n");
                }
        }
        fclose(fp);
        fp=fopen(PATH"/out","r");
        if(PEM_read_PKCS8(fp,NULL,NULL,NULL)!=NULL)
        {
                fprintf(stderr,"\nError in calling the function
PEM_read\n");
        }
        fclose(fp);
        return I_LIKE_DINESH;
}
# gcc --version
gcc (GCC) 3.1
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
# gcc -g dinesh.c -lcrypto -lssl
# gdb a.out
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.
..
(gdb) break main
Breakpoint 1 at 0x2790: file dinesh.c, line 11.
(gdb) r
Starting program: /home/murugesh/openssl_test/a.out

Breakpoint 1, main (argc=1, argv=0x7dbf07c4) at dinesh.c:11
11              MKDIR(PATH);
(gdb) s
12              fp=fopen(PATH"/out","w");
(gdb)
13              if(!fp)
(gdb)
19                      if(PEM_write_PKCS8(fp,NULL)==0)
(gdb) ptype PEM_write_PKCS8
type = int ()
(gdb) ptype PEM_write_PKCS8()
type = int
(gdb) whatis PEM_write_PKCS8()
type = int
(gdb) whatis PEM_write_PKCS8
type = <text variable, no debug info>
(gdb) The program is running.  Exit anyway? (y or n) y
#

script done on Wed Mar 17 09:32:26 2004


I think I have covered all the answers for your questions.

Thanks,
Murugesan


=========================================================================================================
On Tue, 2004-03-16 at 19:46, Michael Elizabeth Chastain wrote:
> Hello Murugesan,
> 
>   gdb>ptype fun
>   type = int ()
> 
> Okay, I have some questions:
> 
>   What computer and operating system are you using?
>   What compiler are you using to compile 'fun'?
>   What version of the compiler are you using?
>   What command line switches do you use to compile your program?
>   What command line switches do you use to link your program?
> 
> Can you make a small sample program which shows this problem?
> Then use the 'script' command.  'cat' the program,
> compile and link the program, run gdb on the program,
> exit 'script', and mail us the typescript.
> 
> Michael C


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
@ 2004-03-16 14:16 Michael Elizabeth Chastain
  2004-03-17  4:20 ` murugesan
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Elizabeth Chastain @ 2004-03-16 14:16 UTC (permalink / raw)
  To: drow, mukeshgct; +Cc: gdb

Hello Murugesan,

  gdb>ptype fun
  type = int ()

Okay, I have some questions:

  What computer and operating system are you using?
  What compiler are you using to compile 'fun'?
  What version of the compiler are you using?
  What command line switches do you use to compile your program?
  What command line switches do you use to link your program?

Can you make a small sample program which shows this problem?
Then use the 'script' command.  'cat' the program,
compile and link the program, run gdb on the program,
exit 'script', and mail us the typescript.

Michael C

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
@ 2004-03-16 11:31 murugesan
  0 siblings, 0 replies; 13+ messages in thread
From: murugesan @ 2004-03-16 11:31 UTC (permalink / raw)
  To: gdb

Thanks muthukumar.
But 'whatis fun' is returning me

(gdb) whatis fun
type = <text variable, no debug info>

Is there any other way. The function defn/prototype is not found in the
source. The function is in the library that has been built from the source.
I was able to find that the function name has been in a file named
libeay.num
and this file name has been used in a pearl file.

Regards,
Murugesan

============================================================================
===============
----- Original Message -----
From: Muthukumar
To: murugesan ; Daniel Jacobowitz
Cc: gdb@sources.redhat.com
Sent: Tuesday, March 16, 2004 4:09 PM
Subject: Re: ptype of prototype of a funtion
>>
> gdb>ptype fun
> type = int ()
>
> But 'ptype fun' just displays the return type followed by paranthesis.
>
> Also,
>
> gdb>ptype fun()
> type = int
> What a great! the paranthesis is missing.

You can get also the function information using thr "whatis" command too.
as .,
whatis fun (or) whatis fun()

> But I am unable to get the parameter type.
> Is there really a way to find the parameter type ?

If you are attempting to know about the function parameters then they are
only known to the function loop only.
not to the main function.Because they may be local to the function not as
global.
At that time you have to get the function parameter informations by going
into the function and put the command
ptype or whatis for the particular parameter type.

For example:
main()

If you get the information with ptype then
gdb> ptype main
type = int ()

If you change the code as
/* Global variables */
int argc;
char argv[];
main(argc,argv)

If you get the information with ptype / whatis then
gdb> ptype main
type = int (int, int)

>
> Thanks,
> Murugesan
>


Regards,
Muthukumar.

============================================================================
===============
>
> ----- Original Message -----
> From: Daniel Jacobowitz
> To: murugesan
> Cc: gdb@sources.redhat.com
> Sent: Friday, March 12, 2004 9:09 PM
> Subject: Re: ptype of prototype of a funtion
>
>
> On Fri, Mar 12, 2004 at 01:23:59PM +0530, murugesan wrote:
> > Hello all,
> >     ptype fun(NULL,NULL)
> > This gives me the return type of the function fun
> >     Is there a way to get  the prototype of a function i gdb.
> >
> > I don't know the type of the parameters of fun which can have the value
> > NULL. [ (void*)0 ]
> >
> > thanks in advance for the help.
>
> How about 'ptype fun'?
>
> --
> Daniel Jacobowitz
> MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
  2004-03-16  3:58   ` murugesan
@ 2004-03-16 10:39     ` Muthukumar
  0 siblings, 0 replies; 13+ messages in thread
From: Muthukumar @ 2004-03-16 10:39 UTC (permalink / raw)
  To: murugesan, Daniel Jacobowitz; +Cc: gdb




>>
> gdb>ptype fun
> type = int ()
>
> But 'ptype fun' just displays the return type followed by paranthesis.
>
> Also,
>
> gdb>ptype fun()
> type = int
> What a great! the paranthesis is missing.

You can get also the function information using thr "whatis" command too.
as .,
whatis fun (or) whatis fun()

> But I am unable to get the parameter type.
> Is there really a way to find the parameter type ?

If you are attempting to know about the function parameters then they are only known to the function loop only.
not to the main function.Because they may be local to the function not as global.
At that time you have to get the function parameter informations by going into the function and put the command
ptype or whatis for the particular parameter type.

For example:
main()

If you get the information with ptype then
gdb> ptype main
type = int ()

If you change the code as
/* Global variables */
int argc;
char argv[];
main(argc,argv)

If you get the information with ptype / whatis then
gdb> ptype main
type = int (int, int)

>
> Thanks,
> Murugesan
>


Regards,
Muthukumar.

===========================================================================================
>
> ----- Original Message -----
> From: Daniel Jacobowitz
> To: murugesan
> Cc: gdb@sources.redhat.com
> Sent: Friday, March 12, 2004 9:09 PM
> Subject: Re: ptype of prototype of a funtion
>
>
> On Fri, Mar 12, 2004 at 01:23:59PM +0530, murugesan wrote:
> > Hello all,
> >     ptype fun(NULL,NULL)
> > This gives me the return type of the function fun
> >     Is there a way to get  the prototype of a function i gdb.
> >
> > I don't know the type of the parameters of fun which can have the value
> > NULL. [ (void*)0 ]
> >
> > thanks in advance for the help.
>
> How about 'ptype fun'?
>
> --
> Daniel Jacobowitz
> MontaVista Software                         Debian GNU/Linux Developer
>
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
  2004-03-12 15:39 ` Daniel Jacobowitz
@ 2004-03-16  3:58   ` murugesan
  2004-03-16 10:39     ` Muthukumar
  0 siblings, 1 reply; 13+ messages in thread
From: murugesan @ 2004-03-16  3:58 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

Thanks Daniel and Michael.

gdb>ptype fun
type = int ()

But 'ptype fun' just displays the return type followed by paranthesis.

Also,

gdb>ptype fun()
type = int 
What a great! the paranthesis is missing.
But I am unable to get the parameter type.
Is there really a way to find the parameter type ?

Thanks,
Murugesan


----- Original Message ----- 
From: Daniel Jacobowitz 
To: murugesan 
Cc: gdb@sources.redhat.com 
Sent: Friday, March 12, 2004 9:09 PM
Subject: Re: ptype of prototype of a funtion


On Fri, Mar 12, 2004 at 01:23:59PM +0530, murugesan wrote:
> Hello all,
>     ptype fun(NULL,NULL)
> This gives me the return type of the function fun
>     Is there a way to get  the prototype of a function i gdb.
> 
> I don't know the type of the parameters of fun which can have the value
> NULL. [ (void*)0 ]
> 
> thanks in advance for the help.

How about 'ptype fun'?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
  2004-03-12  7:53 murugesan
@ 2004-03-12 15:39 ` Daniel Jacobowitz
  2004-03-16  3:58   ` murugesan
  0 siblings, 1 reply; 13+ messages in thread
From: Daniel Jacobowitz @ 2004-03-12 15:39 UTC (permalink / raw)
  To: murugesan; +Cc: gdb

On Fri, Mar 12, 2004 at 01:23:59PM +0530, murugesan wrote:
> Hello all,
>     ptype fun(NULL,NULL)
> This gives me the return type of the function fun
>     Is there a way to get  the prototype of a function i gdb.
> 
> I don't know the type of the parameters of fun which can have the value
> NULL. [ (void*)0 ]
> 
> thanks in advance for the help.

How about 'ptype fun'?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: ptype of prototype of a funtion
@ 2004-03-12 15:39 Michael Elizabeth Chastain
  0 siblings, 0 replies; 13+ messages in thread
From: Michael Elizabeth Chastain @ 2004-03-12 15:39 UTC (permalink / raw)
  To: gdb, mukeshgct

> Is there a way to get  the prototype of a function i gdb.

If your compiler emits information for the function arguments,
then the gdb command 'ptype' will print that information.

Try compiling and linking your program with the "-g" flag to
get more debugging information.

Michael C
GDB QA Guy

^ permalink raw reply	[flat|nested] 13+ messages in thread

* ptype of prototype of a funtion
@ 2004-03-12  7:53 murugesan
  2004-03-12 15:39 ` Daniel Jacobowitz
  0 siblings, 1 reply; 13+ messages in thread
From: murugesan @ 2004-03-12  7:53 UTC (permalink / raw)
  To: gdb

Hello all,
    ptype fun(NULL,NULL)
This gives me the return type of the function fun
    Is there a way to get  the prototype of a function i gdb.

I don't know the type of the parameters of fun which can have the value
NULL. [ (void*)0 ]

thanks in advance for the help.

Regards,
Murugesan


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-03-18 19:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-17  5:19 ptype of prototype of a funtion Michael Elizabeth Chastain
  -- strict thread matches above, loose matches on Subject: below --
2004-03-18 19:52 Michael Elizabeth Chastain
2004-03-16 14:16 Michael Elizabeth Chastain
2004-03-17  4:20 ` murugesan
2004-03-17  4:35   ` Ramana Radhakrishnan
2004-03-17  5:58     ` murugesan
2004-03-18  4:46       ` murugesan
2004-03-16 11:31 murugesan
2004-03-12 15:39 Michael Elizabeth Chastain
2004-03-12  7:53 murugesan
2004-03-12 15:39 ` Daniel Jacobowitz
2004-03-16  3:58   ` murugesan
2004-03-16 10:39     ` Muthukumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).