Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6765df9

Browse files
committed
Add configure --enable-profiling to enable GCC profiling. Patches from
Korry Douglas and Nikhil S
1 parent879caf1 commit6765df9

File tree

5 files changed

+116
-4
lines changed

5 files changed

+116
-4
lines changed

‎configure

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ ac_includes_default="\
314314
# include <unistd.h>
315315
#endif"
316316

317-
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug DTRACE DTRACEFLAGS enable_dtrace CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_ldap with_bonjour with_openssl XML2_CONFIG with_zlib EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS LDAP_LIBS_FE LDAP_LIBS_BE HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
317+
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug enable_profiling DTRACE DTRACEFLAGS enable_dtrace CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_ldap with_bonjour with_openssl XML2_CONFIG with_zlib EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS LDAP_LIBS_FE LDAP_LIBS_BE HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
318318
ac_subst_files=''
319319

320320
# Initialize some variables set by options.
@@ -865,6 +865,7 @@ Optional Features:
865865
--disable-rpath do not embed shared library search path in executables
866866
--disable-spinlocks do not use spinlocks
867867
--enable-debug build with debugging symbols (-g)
868+
--enable-profiling build with profiling enabled
868869
--enable-dtrace build with DTrace support
869870
--enable-depend turn on automatic dependency tracking
870871
--enable-cassert enable assertion checks (for debugging)
@@ -1948,6 +1949,37 @@ fi;
19481949

19491950

19501951

1952+
#
1953+
# --enable-profiling enables gcc profiling
1954+
#
1955+
1956+
pgac_args="$pgac_args enable_profiling"
1957+
1958+
# Check whether --enable-profiling or --disable-profiling was given.
1959+
if test "${enable_profiling+set}" = set; then
1960+
enableval="$enable_profiling"
1961+
1962+
case $enableval in
1963+
yes)
1964+
:
1965+
;;
1966+
no)
1967+
:
1968+
;;
1969+
*)
1970+
{ { echo "$as_me:$LINENO: error: no argument expected for --enable-profiling option" >&5
1971+
echo "$as_me: error: no argument expected for --enable-profiling option" >&2;}
1972+
{ (exit 1); exit 1; }; }
1973+
;;
1974+
esac
1975+
1976+
else
1977+
enable_profiling=no
1978+
1979+
fi;
1980+
1981+
1982+
19511983
#
19521984
# DTrace
19531985
#
@@ -3149,6 +3181,22 @@ if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
31493181
CFLAGS="$CFLAGS -g"
31503182
fi
31513183

3184+
# enable profiling if --enable-profiling
3185+
if test "$enable_profiling" = yes && test "$ac_cv_prog_cc_g" = yes; then
3186+
if test "$GCC" = yes; then
3187+
3188+
cat >>confdefs.h <<\_ACEOF
3189+
#define PROFILE_PID_DIR 1
3190+
_ACEOF
3191+
3192+
CFLAGS="$CFLAGS -pg"
3193+
else
3194+
{ { echo "$as_me:$LINENO: error: --enable-profiling is supported only when using GCC" >&5
3195+
echo "$as_me: error: --enable-profiling is supported only when using GCC" >&2;}
3196+
{ (exit 1); exit 1; }; }
3197+
fi
3198+
fi
3199+
31523200
{ echo "$as_me:$LINENO: using CFLAGS=$CFLAGS" >&5
31533201
echo "$as_me: using CFLAGS=$CFLAGS" >&6;}
31543202

@@ -23975,6 +24023,7 @@ s,@default_port@,$default_port,;t t
2397524023
s,@enable_shared@,$enable_shared,;t t
2397624024
s,@enable_rpath@,$enable_rpath,;t t
2397724025
s,@enable_debug@,$enable_debug,;t t
24026+
s,@enable_profiling@,$enable_profiling,;t t
2397824027
s,@DTRACE@,$DTRACE,;t t
2397924028
s,@DTRACEFLAGS@,$DTRACEFLAGS,;t t
2398024029
s,@enable_dtrace@,$enable_dtrace,;t t

‎configure.in

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.501 2007/02/07 00:28:54 petere Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.502 2007/02/21 15:12:39 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -205,6 +205,13 @@ PGAC_ARG_BOOL(enable, debug, no,
205205
[ --enable-debug build with debugging symbols (-g)])
206206
AC_SUBST(enable_debug)
207207

208+
#
209+
# --enable-profiling enables gcc profiling
210+
#
211+
PGAC_ARG_BOOL(enable, profiling, no,
212+
[ --enable-profiling build with profiling enabled ])
213+
AC_SUBST(enable_profiling)
214+
208215
#
209216
# DTrace
210217
#
@@ -297,6 +304,17 @@ if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
297304
CFLAGS="$CFLAGS -g"
298305
fi
299306

307+
# enable profiling if --enable-profiling
308+
if test "$enable_profiling" = yes && test "$ac_cv_prog_cc_g" = yes; then
309+
if test "$GCC" = yes; then
310+
AC_DEFINE([PROFILE_PID_DIR], 1,
311+
[Define to 1 to enable profiling. (--enable-profiling)])
312+
CFLAGS="$CFLAGS -pg"
313+
else
314+
AC_MSG_ERROR([--enable-profiling is supported only when using GCC])
315+
fi
316+
fi
317+
300318
AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
301319

302320
# We already have this in Makefile.win32, but configure needs it too

‎doc/src/sgml/installation.sgml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.284 2007/02/19 18:57:18 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.285 2007/02/21 15:12:39 momjian Exp $ -->
22

33
<chapter id="installation">
44
<title><![%standalone-include[<productname>PostgreSQL</>]]>
@@ -1040,6 +1040,18 @@ su - postgres
10401040
</listitem>
10411041
</varlistentry>
10421042

1043+
<varlistentry>
1044+
<term><option>--enable-profiling</option></term>
1045+
<listitem>
1046+
<para>
1047+
If using GCC, all programs and libraries are compiled so they
1048+
can be profiled. On backend exit, a subdirectory will be created
1049+
that contains the <filename>gmon.out</> file for use in profiling.
1050+
This option is for use only with GCC and when doing development work.
1051+
</para>
1052+
</listitem>
1053+
</varlistentry>
1054+
10431055
<varlistentry>
10441056
<term><option>--enable-cassert</option></term>
10451057
<listitem>

‎src/backend/storage/ipc/ipc.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.95 2007/01/05 22:19:37 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.96 2007/02/21 15:12:39 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -110,6 +110,36 @@ proc_exit(int code)
110110
on_proc_exit_list[on_proc_exit_index].arg);
111111

112112
elog(DEBUG3,"exit(%d)",code);
113+
114+
#ifdefPROFILE_PID_DIR
115+
{
116+
/*
117+
* If we are profiling ourself then gprof's mcleanup() is about
118+
* to write out a profile to ./gmon.out. Since mcleanup() always
119+
* uses a fixed file name, each backend will overwrite earlier
120+
* profiles. To fix that, we create a separate subdirectory for
121+
* each backend (./gprof/pid) and 'cd' to that subdirectory before
122+
* we exit() - that forces mcleanup() to write each profile into
123+
* its own directory. We end up with something like:
124+
*$PGDATA/gprof/8829/gmon.out
125+
*$PGDATA/gprof/8845/gmon.out
126+
*...
127+
*
128+
* Note that we do this here instead of in an on_proc_exit()
129+
* callback because we want to ensure that this code executes
130+
* last - we don't want to interfere with any other on_proc_exit()
131+
* callback.
132+
*/
133+
chargprofDirName[32];
134+
135+
snprintf(gprofDirName,32,"gprof/%d", (int)getpid());
136+
137+
mkdir("gprof",0777);
138+
mkdir(gprofDirName,0777);
139+
chdir(gprofDirName);
140+
}
141+
#endif
142+
113143
exit(code);
114144
}
115145

‎src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@
602602
/* A string containing the version number, platform, and C compiler */
603603
#undef PG_VERSION_STR
604604

605+
/* Define to 1 to enable profiling. (--enable-profiling) */
606+
#undef PROFILE_PID_DIR
607+
605608
/* Define to the necessary symbol if this constant uses a non-standard name on
606609
your system. */
607610
#undef PTHREAD_CREATE_JOINABLE

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp